summaryrefslogtreecommitdiffstats
path: root/extensions
diff options
context:
space:
mode:
authorrdevlin.cronin@chromium.org <rdevlin.cronin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-06-12 20:54:13 +0000
committerrdevlin.cronin@chromium.org <rdevlin.cronin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-06-12 20:54:13 +0000
commit6d8a0b0937f27a61a84bc7d19bc7c689a714aa45 (patch)
tree157bfbb0a910e6f4246b3e4a28050d7db941b7df /extensions
parent586d6f15802e4f1a873b2d0709d1b5f32da2bc7f (diff)
downloadchromium_src-6d8a0b0937f27a61a84bc7d19bc7c689a714aa45.zip
chromium_src-6d8a0b0937f27a61a84bc7d19bc7c689a714aa45.tar.gz
chromium_src-6d8a0b0937f27a61a84bc7d19bc7c689a714aa45.tar.bz2
Move Extension-Controlled Preference functions from ExtPrefs to PreferenceAPI
Move [Set|Remove]ExtensionControlledPref and [Can|Does]ExtensionControlPref functions from ExtensionPrefs to PreferenceAPI, since these functions were only ever used in APIs. This required restructing the ExtensionPrefs unittests slightly, so that derived testing classes (tests for ExtensionSorting) don't inherit controlled pref methods, and the functions are isolated in APIs. BUG=180083 Review URL: https://chromiumcodereview.appspot.com/15582003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@205924 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'extensions')
-rw-r--r--extensions/browser/extension_prefs_scope.h28
-rw-r--r--extensions/browser/pref_names.cc37
-rw-r--r--extensions/browser/pref_names.h42
3 files changed, 107 insertions, 0 deletions
diff --git a/extensions/browser/extension_prefs_scope.h b/extensions/browser/extension_prefs_scope.h
new file mode 100644
index 0000000..3747ee8
--- /dev/null
+++ b/extensions/browser/extension_prefs_scope.h
@@ -0,0 +1,28 @@
+// Copyright 2013 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 EXTENSIONS_BROWSER_EXTENSION_PREFS_SCOPE_H_
+#define EXTENSIONS_BROWSER_EXTENSION_PREFS_SCOPE_H_
+
+#include "base/basictypes.h"
+
+namespace extensions {
+
+// Scope for a preference.
+enum ExtensionPrefsScope {
+ // Regular profile and incognito.
+ kExtensionPrefsScopeRegular,
+ // Regular profile only.
+ kExtensionPrefsScopeRegularOnly,
+ // Incognito profile; preference is persisted to disk and remains active
+ // after a browser restart.
+ kExtensionPrefsScopeIncognitoPersistent,
+ // Incognito profile; preference is kept in memory and deleted when the
+ // incognito session is terminated.
+ kExtensionPrefsScopeIncognitoSessionOnly
+};
+
+} // namespace extensions
+
+#endif // EXTENSIONS_BROWSER_EXTENSION_PREFS_SCOPE_H_
diff --git a/extensions/browser/pref_names.cc b/extensions/browser/pref_names.cc
new file mode 100644
index 0000000..56de339
--- /dev/null
+++ b/extensions/browser/pref_names.cc
@@ -0,0 +1,37 @@
+// Copyright 2013 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.
+
+#include "extensions/browser/pref_names.h"
+
+#include "base/logging.h"
+
+namespace extensions {
+namespace pref_names {
+
+bool ScopeToPrefName(ExtensionPrefsScope scope, std::string* result) {
+ switch (scope) {
+ case kExtensionPrefsScopeRegular:
+ *result = kPrefPreferences;
+ return true;
+ case kExtensionPrefsScopeRegularOnly:
+ *result = kPrefRegularOnlyPreferences;
+ return true;
+ case kExtensionPrefsScopeIncognitoPersistent:
+ *result = kPrefIncognitoPreferences;
+ return true;
+ case kExtensionPrefsScopeIncognitoSessionOnly:
+ return false;
+ }
+ NOTREACHED();
+ return false;
+}
+
+const char kPrefPreferences[] = "preferences";
+const char kPrefIncognitoPreferences[] = "incognito_preferences";
+const char kPrefRegularOnlyPreferences[] = "regular_only_preferences";
+const char kPrefContentSettings[] = "content_settings";
+const char kPrefIncognitoContentSettings[] = "incognito_content_settings";
+
+} // namespace pref_names
+} // namespace extensions
diff --git a/extensions/browser/pref_names.h b/extensions/browser/pref_names.h
new file mode 100644
index 0000000..f70b525
--- /dev/null
+++ b/extensions/browser/pref_names.h
@@ -0,0 +1,42 @@
+// Copyright 2013 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 EXTENSIONS_BROWSER_PREF_NAMES_H_
+#define EXTENSIONS_BROWSER_PREF_NAMES_H_
+
+#include <string>
+
+#include "extensions/browser/extension_prefs_scope.h"
+
+namespace extensions {
+
+// Preference keys which are needed by both the ExtensionPrefs and by external
+// clients, such as APIs.
+namespace pref_names {
+
+// If the given |scope| is persisted, return true and populate |result| with the
+// appropriate pref name. If |scope| is not persisted, return false, and leave
+// |result| unchanged.
+bool ScopeToPrefName(ExtensionPrefsScope scope, std::string* result);
+
+// A preference that contains any extension-controlled preferences.
+extern const char kPrefPreferences[];
+
+// A preference that contains any extension-controlled incognito preferences.
+extern const char kPrefIncognitoPreferences[];
+
+// A preference that contains any extension-controlled regular-only preferences.
+extern const char kPrefRegularOnlyPreferences[];
+
+// A preference that contains extension-set content settings.
+extern const char kPrefContentSettings[];
+
+// A preference that contains extension-set content settings.
+extern const char kPrefIncognitoContentSettings[];
+
+} // namespace pref_names
+
+} // namespace extensions
+
+#endif // EXTENSIONS_BROWSER_PREF_NAMES_H_