Roll src/third_party/WebKit f36d5e0:68b67cd (svn 193299:193303)
[chromium-blink-merge.git] / components / user_prefs / user_prefs.h
blob3e72d7aed1bc5f0bfa4bb5af060edb740b85f028
1 // 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.
5 #ifndef COMPONENTS_USER_PREFS_USER_PREFS_H_
6 #define COMPONENTS_USER_PREFS_USER_PREFS_H_
8 #include "base/basictypes.h"
9 #include "base/supports_user_data.h"
10 #include "components/user_prefs/user_prefs_export.h"
12 class PrefService;
14 namespace content {
15 class BrowserContext;
18 namespace user_prefs {
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().
24 // It is up to the embedder to create and own the PrefService and
25 // attach it to BrowserContext using the UserPrefs::Set() function.
26 class 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);
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);
36 private:
37 explicit UserPrefs(PrefService* prefs);
38 ~UserPrefs() override;
40 // Non-owning; owned by embedder.
41 PrefService* prefs_;
43 DISALLOW_COPY_AND_ASSIGN(UserPrefs);
46 } // namespace user_prefs
48 #endif // COMPONENTS_USER_PREFS_USER_PREFS_H_