blob: 191974808712133e6c417d79af5e884f357859e1 [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"
9#include "base/memory/scoped_ptr.h"
10#include "base/supports_user_data.h"
11#include "components/user_prefs/user_prefs_export.h"
12
13class PrefService;
14
15namespace content {
16class BrowserContext;
17}
18
19namespace components {
20
21// Components may use preferences associated with a given user. These
22// hang off of content::BrowserContext and can be retrieved using
23// UserPrefs::Get().
24//
25// It is up to the embedder tof create and own the PrefService and
26// attach it to BrowserContext using the UserPrefs::Set() function.
27class USER_PREFS_EXPORT UserPrefs : public base::SupportsUserData::Data {
28 public:
29 // Retrieves the PrefService for a given BrowserContext, or NULL if
30 // none is attached.
31 static PrefService* Get(content::BrowserContext* context);
32
33 // Hangs the specified |prefs| off of |context|. Should be called
34 // only once per BrowserContext.
35 static void Set(content::BrowserContext* context, PrefService* prefs);
36
37 private:
38 UserPrefs(PrefService* prefs);
39 virtual ~UserPrefs();
40
41 // Non-owning; owned by embedder.
42 PrefService* prefs_;
43
44 DISALLOW_COPY_AND_ASSIGN(UserPrefs);
45};
46
47} // namespace components
48
49#endif // COMPONENTS_USER_PREFS_USER_PREFS_H_