1 // Copyright 2015 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 CHROME_BROWSER_EXTENSIONS_API_SETTINGS_PRIVATE_SETTINGS_PRIVATE_DELEGATE_H_
6 #define CHROME_BROWSER_EXTENSIONS_API_SETTINGS_PRIVATE_SETTINGS_PRIVATE_DELEGATE_H_
11 #include "base/callback.h"
12 #include "base/macros.h"
13 #include "base/memory/scoped_ptr.h"
14 #include "chrome/browser/extensions/api/settings_private/prefs_util.h"
15 #include "chrome/common/extensions/api/settings_private.h"
16 #include "components/keyed_service/core/keyed_service.h"
17 #include "extensions/browser/extension_function.h"
25 namespace extensions
{
27 using TypedPrefMap
= std::map
<std::string
, api::settings_private::PrefType
>;
29 // Manages all the pref service interactions.
30 // Use SettingsPrivateDelegateFactory to create a SettingsPrivateDelegate
32 class SettingsPrivateDelegate
: public KeyedService
{
34 explicit SettingsPrivateDelegate(Profile
* profile
);
35 ~SettingsPrivateDelegate() override
;
37 // Sets the pref with the given name and value in the proper PrefService.
38 virtual PrefsUtil::SetPrefResult
SetPref(
39 const std::string
& name
, const base::Value
* value
);
41 // Gets the value of the pref with the given |name|.
42 virtual scoped_ptr
<base::Value
> GetPref(const std::string
& name
);
44 // Gets the values of all whitelisted prefs.
45 virtual scoped_ptr
<base::Value
> GetAllPrefs();
48 Profile
* profile_
; // weak; not owned by us
49 scoped_ptr
<PrefsUtil
> prefs_util_
;
52 DISALLOW_COPY_AND_ASSIGN(SettingsPrivateDelegate
);
55 } // namespace extensions
57 #endif // CHROME_BROWSER_EXTENSIONS_API_SETTINGS_PRIVATE_SETTINGS_PRIVATE_DELEGATE_H_