summaryrefslogtreecommitdiff
path: root/extensions
diff options
context:
space:
mode:
authorTorne (Richard Coles) <torne@google.com>2013-06-19 11:58:07 +0100
committerTorne (Richard Coles) <torne@google.com>2013-06-19 11:58:07 +0100
commit7d4cd473f85ac64c3747c96c277f9e506a0d2246 (patch)
treef5fecd524f5ac22cd38bcc6713b81f666730d5a1 /extensions
parent84f2b2352908c30e40ae12ffe850dd8470f6c048 (diff)
downloadchromium_org-7d4cd473f85ac64c3747c96c277f9e506a0d2246.tar.gz
Merge from Chromium at DEPS revision r207203
This commit was generated by merge_to_master.py. Change-Id: I5fbb6854d092096c4d39edc2865a48be1b53c418
Diffstat (limited to 'extensions')
-rw-r--r--extensions/OWNERS1
-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
-rw-r--r--extensions/common/matcher/url_matcher_factory.cc10
-rw-r--r--extensions/common/matcher/url_matcher_unittest.cc22
6 files changed, 124 insertions, 16 deletions
diff --git a/extensions/OWNERS b/extensions/OWNERS
index 07b50068af..199c3a7531 100644
--- a/extensions/OWNERS
+++ b/extensions/OWNERS
@@ -1,5 +1,4 @@
# This should match chrome/browser/extensions/OWNERS
-aa@chromium.org
asargent@chromium.org
benwells@chromium.org
erikkay@chromium.org
diff --git a/extensions/browser/extension_prefs_scope.h b/extensions/browser/extension_prefs_scope.h
new file mode 100644
index 0000000000..3747ee817f
--- /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 0000000000..56de3397d9
--- /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 0000000000..f70b525b15
--- /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_
diff --git a/extensions/common/matcher/url_matcher_factory.cc b/extensions/common/matcher/url_matcher_factory.cc
index eb1548ca89..6eec2e6ab1 100644
--- a/extensions/common/matcher/url_matcher_factory.cc
+++ b/extensions/common/matcher/url_matcher_factory.cc
@@ -224,14 +224,14 @@ scoped_ptr<URLMatcherSchemeFilter> URLMatcherFactory::CreateURLMatcherScheme(
if (!helpers::GetAsStringVector(value, &schemas)) {
*error = ErrorUtils::FormatErrorMessage(kVectorOfStringsExpected,
keys::kSchemesKey);
- return scoped_ptr<URLMatcherSchemeFilter>(NULL);
+ return scoped_ptr<URLMatcherSchemeFilter>();
}
for (std::vector<std::string>::const_iterator it = schemas.begin();
it != schemas.end(); ++it) {
if (ContainsUpperCase(*it)) {
*error = ErrorUtils::FormatErrorMessage(kLowerCaseExpected,
"Scheme");
- return scoped_ptr<URLMatcherSchemeFilter>(NULL);
+ return scoped_ptr<URLMatcherSchemeFilter>();
}
}
return scoped_ptr<URLMatcherSchemeFilter>(
@@ -246,7 +246,7 @@ scoped_ptr<URLMatcherPortFilter> URLMatcherFactory::CreateURLMatcherPorts(
const base::ListValue* value_list = NULL;
if (!value->GetAsList(&value_list)) {
*error = kInvalidPortRanges;
- return scoped_ptr<URLMatcherPortFilter>(NULL);
+ return scoped_ptr<URLMatcherPortFilter>();
}
for (ListValue::const_iterator i = value_list->begin();
@@ -262,12 +262,12 @@ scoped_ptr<URLMatcherPortFilter> URLMatcherFactory::CreateURLMatcherPorts(
!range->GetInteger(0, &from) ||
!range->GetInteger(1, &to)) {
*error = kInvalidPortRanges;
- return scoped_ptr<URLMatcherPortFilter>(NULL);
+ return scoped_ptr<URLMatcherPortFilter>();
}
ranges.push_back(URLMatcherPortFilter::CreateRange(from, to));
} else {
*error = kInvalidPortRanges;
- return scoped_ptr<URLMatcherPortFilter>(NULL);
+ return scoped_ptr<URLMatcherPortFilter>();
}
}
diff --git a/extensions/common/matcher/url_matcher_unittest.cc b/extensions/common/matcher/url_matcher_unittest.cc
index 15a41a16bf..1b194ed8b9 100644
--- a/extensions/common/matcher/url_matcher_unittest.cc
+++ b/extensions/common/matcher/url_matcher_unittest.cc
@@ -449,16 +449,18 @@ TEST(URLMatcherConditionSetTest, Matching) {
// Test scheme filters.
scoped_refptr<URLMatcherConditionSet> condition_set2(
- new URLMatcherConditionSet(1, conditions,
- scoped_ptr<URLMatcherSchemeFilter>(
- new URLMatcherSchemeFilter("https")),
- scoped_ptr<URLMatcherPortFilter>(NULL)));
+ new URLMatcherConditionSet(1,
+ conditions,
+ scoped_ptr<URLMatcherSchemeFilter>(
+ new URLMatcherSchemeFilter("https")),
+ scoped_ptr<URLMatcherPortFilter>()));
EXPECT_FALSE(condition_set2->IsMatch(matching_patterns, url1));
scoped_refptr<URLMatcherConditionSet> condition_set3(
- new URLMatcherConditionSet(1, conditions,
- scoped_ptr<URLMatcherSchemeFilter>(
- new URLMatcherSchemeFilter("http")),
- scoped_ptr<URLMatcherPortFilter>(NULL)));
+ new URLMatcherConditionSet(1,
+ conditions,
+ scoped_ptr<URLMatcherSchemeFilter>(
+ new URLMatcherSchemeFilter("http")),
+ scoped_ptr<URLMatcherPortFilter>()));
EXPECT_TRUE(condition_set3->IsMatch(matching_patterns, url1));
// Test port filters.
@@ -466,8 +468,8 @@ TEST(URLMatcherConditionSetTest, Matching) {
ranges.push_back(URLMatcherPortFilter::CreateRange(80));
scoped_ptr<URLMatcherPortFilter> filter(new URLMatcherPortFilter(ranges));
scoped_refptr<URLMatcherConditionSet> condition_set4(
- new URLMatcherConditionSet(1, conditions,
- scoped_ptr<URLMatcherSchemeFilter>(NULL), filter.Pass()));
+ new URLMatcherConditionSet(
+ 1, conditions, scoped_ptr<URLMatcherSchemeFilter>(), filter.Pass()));
EXPECT_TRUE(condition_set4->IsMatch(matching_patterns, url1));
EXPECT_TRUE(condition_set4->IsMatch(matching_patterns, url3));
EXPECT_FALSE(condition_set4->IsMatch(matching_patterns, url4));