blob: 392e5dc7f23279c0d371baf1f1f0258ce6ebc87d [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
avi5dd91f82015-12-25 22:30:468#include "base/macros.h"
[email protected]75fee372013-03-06 00:42:449#include "base/supports_user_data.h"
dcheng40f883682015-07-25 05:22:4910#include "components/user_prefs/user_prefs_export.h"
[email protected]75fee372013-03-06 00:42:4411
12class PrefService;
13
[email protected]c7141feb2013-06-11 13:00:1614namespace user_prefs {
[email protected]75fee372013-03-06 00:42:4415
droger3b2d62d2015-04-16 08:04:3216// Components may use preferences associated with a given user. These hang off
17// of base::SupportsUserData and can be retrieved using UserPrefs::Get().
[email protected]75fee372013-03-06 00:42:4418//
droger3b2d62d2015-04-16 08:04:3219// It is up to the embedder to create and own the PrefService and attach it to
20// base::SupportsUserData using the UserPrefs::Set() function.
dcheng40f883682015-07-25 05:22:4921class USER_PREFS_EXPORT UserPrefs : public base::SupportsUserData::Data {
[email protected]75fee372013-03-06 00:42:4422 public:
avi8945fc92017-05-02 16:03:2323 ~UserPrefs() override;
24
droger3b2d62d2015-04-16 08:04:3225 // Retrieves the PrefService for a given context, or null if none is attached.
26 static PrefService* Get(base::SupportsUserData* context);
[email protected]75fee372013-03-06 00:42:4427
28 // Hangs the specified |prefs| off of |context|. Should be called
droger3b2d62d2015-04-16 08:04:3229 // only once per context.
30 static void Set(base::SupportsUserData* context, PrefService* prefs);
[email protected]75fee372013-03-06 00:42:4431
32 private:
[email protected]5a64e822013-03-08 14:12:5033 explicit UserPrefs(PrefService* prefs);
[email protected]75fee372013-03-06 00:42:4434
35 // Non-owning; owned by embedder.
36 PrefService* prefs_;
37
38 DISALLOW_COPY_AND_ASSIGN(UserPrefs);
39};
40
[email protected]c7141feb2013-06-11 13:00:1641} // namespace user_prefs
[email protected]75fee372013-03-06 00:42:4442
43#endif // COMPONENTS_USER_PREFS_USER_PREFS_H_