blob: ceea4f02f322501db29bdb39033849be22bb7857 [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
dcheng40f883682015-07-25 05:22:498#include "base/basictypes.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:
droger3b2d62d2015-04-16 08:04:3223 // Retrieves the PrefService for a given context, or null if none is attached.
24 static PrefService* Get(base::SupportsUserData* context);
[email protected]75fee372013-03-06 00:42:4425
26 // Hangs the specified |prefs| off of |context|. Should be called
droger3b2d62d2015-04-16 08:04:3227 // only once per context.
28 static void Set(base::SupportsUserData* context, PrefService* prefs);
[email protected]75fee372013-03-06 00:42:4429
30 private:
[email protected]5a64e822013-03-08 14:12:5031 explicit UserPrefs(PrefService* prefs);
dcheng00ea022b2014-10-21 11:24:5632 ~UserPrefs() override;
[email protected]75fee372013-03-06 00:42:4433
34 // Non-owning; owned by embedder.
35 PrefService* prefs_;
36
37 DISALLOW_COPY_AND_ASSIGN(UserPrefs);
38};
39
[email protected]c7141feb2013-06-11 13:00:1640} // namespace user_prefs
[email protected]75fee372013-03-06 00:42:4441
42#endif // COMPONENTS_USER_PREFS_USER_PREFS_H_