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

Unified Diff: extensions/browser/extension_pref_value_map.cc

Issue 184043024: Limit scope of settings API configuration and proxy permission (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Addressed Bernhard's comments Created 6 years, 10 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: extensions/browser/extension_pref_value_map.cc
diff --git a/extensions/browser/extension_pref_value_map.cc b/extensions/browser/extension_pref_value_map.cc
index 5cba7e510a2afac21c3827a9ae09a97369ae5457..384601e2ba4af9e2036a75a0c1e28ea38ddcfcc1 100644
--- a/extensions/browser/extension_pref_value_map.cc
+++ b/extensions/browser/extension_pref_value_map.cc
@@ -15,6 +15,8 @@ struct ExtensionPrefValueMap::ExtensionEntry {
base::Time install_time;
// Whether extension is enabled in the profile.
bool enabled;
+ // Whether the extension has access to the incognito profile.
+ bool incognito_enabled;
// Extension controlled preferences for the regular profile.
PrefValueMap regular_profile_preferences;
// Extension controlled preferences that should *only* apply to the regular
@@ -74,6 +76,9 @@ bool ExtensionPrefValueMap::CanExtensionControlPref(
return false;
}
+ if (incognito && !ext->second->incognito_enabled)
+ return false;
+
ExtensionEntryMap::const_iterator winner =
GetEffectivePrefValueController(pref_key, incognito, NULL);
if (winner == entries_.end())
@@ -115,7 +120,8 @@ bool ExtensionPrefValueMap::DoesExtensionControlPref(
void ExtensionPrefValueMap::RegisterExtension(const std::string& ext_id,
const base::Time& install_time,
- bool is_enabled) {
+ bool is_enabled,
+ bool is_incognito_enabled) {
if (entries_.find(ext_id) == entries_.end()) {
entries_[ext_id] = new ExtensionEntry;
@@ -124,6 +130,7 @@ void ExtensionPrefValueMap::RegisterExtension(const std::string& ext_id,
}
entries_[ext_id]->enabled = is_enabled;
+ entries_[ext_id]->incognito_enabled = is_incognito_enabled;
}
void ExtensionPrefValueMap::UnregisterExtension(const std::string& ext_id) {
@@ -154,6 +161,22 @@ void ExtensionPrefValueMap::SetExtensionState(const std::string& ext_id,
NotifyPrefValueChanged(keys);
}
+void ExtensionPrefValueMap::SetExtensionIncognitoState(
+ const std::string& ext_id,
+ bool is_incognito_enabled) {
+ ExtensionEntryMap::const_iterator i = entries_.find(ext_id);
+ // This may happen when sync sets the extension state for an
+ // extension that is not installed.
+ if (i == entries_.end())
+ return;
+ if (i->second->incognito_enabled == is_incognito_enabled)
+ return;
+ std::set<std::string> keys; // keys set by this extension
+ GetExtensionControlledKeys(*(i->second), &keys);
+ i->second->incognito_enabled = is_incognito_enabled;
+ NotifyPrefValueChanged(keys);
+}
+
PrefValueMap* ExtensionPrefValueMap::GetExtensionPrefValueMap(
const std::string& ext_id,
ExtensionPrefsScope scope) {
@@ -226,6 +249,13 @@ const base::Value* ExtensionPrefValueMap::GetEffectivePrefValue(
if (winner == entries_.end())
return NULL;
+ if (incognito && !winner->second->incognito_enabled) {
+ // Not reached because an extension w/o incognito_enabled cannot be the
+ // winning extension for incognito mode.
+ NOTREACHED();
Bernhard Bauer 2014/03/05 09:05:35 You are handling a DCHECK failure here, which you'
battre 2014/03/05 12:05:45 Done.
+ return NULL;
+ }
+
const base::Value* value = NULL;
const std::string& ext_id = winner->first;
@@ -274,11 +304,14 @@ ExtensionPrefValueMap::GetEffectivePrefValueController(
const std::string& ext_id = i->first;
const base::Time& install_time = i->second->install_time;
const bool enabled = i->second->enabled;
+ const bool incognito_enabled = i->second->incognito_enabled;
if (!enabled)
continue;
if (install_time < winners_install_time)
continue;
+ if (incognito && !incognito_enabled)
+ continue;
const base::Value* value = NULL;
const PrefValueMap* prefs = GetExtensionPrefValueMap(
« no previous file with comments | « extensions/browser/extension_pref_value_map.h ('k') | extensions/browser/extension_pref_value_map_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698