blob: 3e72d7aed1bc5f0bfa4bb5af060edb740b85f028 [file] [log] [blame]
[email protected]75fee372013-03-06 00:42:441// Copyright 2013 The Chromium Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#ifndef COMPONENTS_USER_PREFS_USER_PREFS_H_
6#define COMPONENTS_USER_PREFS_USER_PREFS_H_
7
8#include "base/basictypes.h"
[email protected]75fee372013-03-06 00:42:449#include "base/supports_user_data.h"
10#include "components/user_prefs/user_prefs_export.h"
11
12class PrefService;
13
14namespace content {
15class BrowserContext;
16}
17
[email protected]c7141feb2013-06-11 13:00:1618namespace user_prefs {
[email protected]75fee372013-03-06 00:42:4419
20// Components may use preferences associated with a given user. These
21// hang off of content::BrowserContext and can be retrieved using
22// UserPrefs::Get().
23//
[email protected]5a64e822013-03-08 14:12:5024// It is up to the embedder to create and own the PrefService and
[email protected]75fee372013-03-06 00:42:4425// attach it to BrowserContext using the UserPrefs::Set() function.
26class USER_PREFS_EXPORT UserPrefs : public base::SupportsUserData::Data {
27 public:
28 // Retrieves the PrefService for a given BrowserContext, or NULL if
29 // none is attached.
30 static PrefService* Get(content::BrowserContext* context);
31
32 // Hangs the specified |prefs| off of |context|. Should be called
33 // only once per BrowserContext.
34 static void Set(content::BrowserContext* context, PrefService* prefs);
35
36 private:
[email protected]5a64e822013-03-08 14:12:5037 explicit UserPrefs(PrefService* prefs);
dcheng00ea022b2014-10-21 11:24:5638 ~UserPrefs() override;
[email protected]75fee372013-03-06 00:42:4439
40 // Non-owning; owned by embedder.
41 PrefService* prefs_;
42
43 DISALLOW_COPY_AND_ASSIGN(UserPrefs);
44};
45
[email protected]c7141feb2013-06-11 13:00:1646} // namespace user_prefs
[email protected]75fee372013-03-06 00:42:4447
48#endif // COMPONENTS_USER_PREFS_USER_PREFS_H_