Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1001)

Unified Diff: chrome/browser/extensions/api/settings_private/prefs_util.h

Issue 1061613002: chrome.settingsPrivate: Implement onPrefsChanged event handling. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Respond to Steven's comments + add an APItest Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/extensions/api/settings_private/prefs_util.h
diff --git a/chrome/browser/extensions/api/settings_private/prefs_util.h b/chrome/browser/extensions/api/settings_private/prefs_util.h
new file mode 100644
index 0000000000000000000000000000000000000000..f94543d3fa3c6dcc83da12f4740b56d4c044970f
--- /dev/null
+++ b/chrome/browser/extensions/api/settings_private/prefs_util.h
@@ -0,0 +1,48 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_EXTENSIONS_API_SETTINGS_PRIVATE_PREFS_UTIL_H_
+#define CHROME_BROWSER_EXTENSIONS_API_SETTINGS_PRIVATE_PREFS_UTIL_H_
+
+#include <map>
+#include <string>
+
+#include "base/macros.h"
+#include "base/memory/scoped_ptr.h"
+#include "chrome/common/extensions/api/settings_private.h"
+
+class PrefService;
+class Profile;
+
+namespace extensions {
+
+namespace prefs_util {
+
+using TypedPrefMap = std::map<std::string, api::settings_private::PrefType>;
+
+// Gets the list of whitelisted pref keys -- that is, those which correspond to
+// prefs that clients of the settingsPrivate API may retrieve and manipulate.
+const TypedPrefMap& GetWhitelistedKeys();
+
+// Gets the value of the pref with the given |name|. (Returns a pointer to an
+// empty PrefObject if no pref is found for |name|.)
stevenjb 2015/04/06 23:33:38 nit: No () around 'Returns...', that is a key part
Oren Blasberg 2015/04/06 23:41:30 Done.
+scoped_ptr<api::settings_private::PrefObject> GetPref(Profile* profile,
+ const std::string& name);
+
+// Returns whether |pref_name| corresponds to a pref whose type is URL.
+bool IsPrefTypeURL(const std::string& pref_name);
+
+// Returns whether |pref_name| corresponds to a pref that is user modifiable
+// (i.e., not made restricted by a user or device policy).
+bool IsPrefUserModifiable(Profile* profile, const std::string& pref_name);
+
+// Returns a pointer to the appropriate PrefService instance for the given
+// |pref_name|.
+PrefService* FindServiceForPref(Profile* profile, const std::string& pref_name);
+
+} // namespace prefs_util
+
+} // namespace extensions
+
+#endif // CHROME_BROWSER_EXTENSIONS_API_SETTINGS_PRIVATE_PREFS_UTIL_H_

Powered by Google App Engine
This is Rietveld 408576698