Roll src/third_party/WebKit 9f7fb92:f103b33 (svn 202621:202622)
[chromium-blink-merge.git] / components / user_prefs / user_prefs.h
blobceea4f02f322501db29bdb39033849be22bb7857
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 user_prefs {
16 // Components may use preferences associated with a given user. These hang off
17 // of base::SupportsUserData and can be retrieved using UserPrefs::Get().
19 // It is up to the embedder to create and own the PrefService and attach it to
20 // base::SupportsUserData using the UserPrefs::Set() function.
21 class USER_PREFS_EXPORT UserPrefs : public base::SupportsUserData::Data {
22 public:
23 // Retrieves the PrefService for a given context, or null if none is attached.
24 static PrefService* Get(base::SupportsUserData* context);
26 // Hangs the specified |prefs| off of |context|. Should be called
27 // only once per context.
28 static void Set(base::SupportsUserData* context, PrefService* prefs);
30 private:
31 explicit UserPrefs(PrefService* prefs);
32 ~UserPrefs() override;
34 // Non-owning; owned by embedder.
35 PrefService* prefs_;
37 DISALLOW_COPY_AND_ASSIGN(UserPrefs);
40 } // namespace user_prefs
42 #endif // COMPONENTS_USER_PREFS_USER_PREFS_H_