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

Side by Side Diff: extensions/browser/extension_prefs.cc

Issue 396033002: Support "always allow" for runtime script execution (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 5 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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "extensions/browser/extension_prefs.h" 5 #include "extensions/browser/extension_prefs.h"
6 6
7 #include <iterator> 7 #include <iterator>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/prefs/pref_notifier.h" 10 #include "base/prefs/pref_notifier.h"
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 // the user to accept them once recognized. We store the active permission 141 // the user to accept them once recognized. We store the active permission
142 // permissions because they may differ from those defined in the manifest. 142 // permissions because they may differ from those defined in the manifest.
143 const char kPrefActivePermissions[] = "active_permissions"; 143 const char kPrefActivePermissions[] = "active_permissions";
144 const char kPrefGrantedPermissions[] = "granted_permissions"; 144 const char kPrefGrantedPermissions[] = "granted_permissions";
145 145
146 // The preference names for PermissionSet values. 146 // The preference names for PermissionSet values.
147 const char kPrefAPIs[] = "api"; 147 const char kPrefAPIs[] = "api";
148 const char kPrefManifestPermissions[] = "manifest_permissions"; 148 const char kPrefManifestPermissions[] = "manifest_permissions";
149 const char kPrefExplicitHosts[] = "explicit_host"; 149 const char kPrefExplicitHosts[] = "explicit_host";
150 const char kPrefScriptableHosts[] = "scriptable_host"; 150 const char kPrefScriptableHosts[] = "scriptable_host";
151 const char kPrefPersistedPermissions[] = "persisted_permissions";
151 152
152 // The preference names for the old granted permissions scheme. 153 // The preference names for the old granted permissions scheme.
153 const char kPrefOldGrantedFullAccess[] = "granted_permissions.full"; 154 const char kPrefOldGrantedFullAccess[] = "granted_permissions.full";
154 const char kPrefOldGrantedHosts[] = "granted_permissions.host"; 155 const char kPrefOldGrantedHosts[] = "granted_permissions.host";
155 const char kPrefOldGrantedAPIs[] = "granted_permissions.api"; 156 const char kPrefOldGrantedAPIs[] = "granted_permissions.api";
156 157
157 // A preference that indicates when an extension was installed. 158 // A preference that indicates when an extension was installed.
158 const char kPrefInstallTime[] = "install_time"; 159 const char kPrefInstallTime[] = "install_time";
159 160
160 // A preference which saves the creation flags for extensions. 161 // A preference which saves the creation flags for extensions.
(...skipping 962 matching lines...) Expand 10 before | Expand all | Expand 10 after
1123 return ReadPrefAsPermissionSet(extension_id, kPrefActivePermissions); 1124 return ReadPrefAsPermissionSet(extension_id, kPrefActivePermissions);
1124 } 1125 }
1125 1126
1126 void ExtensionPrefs::SetActivePermissions( 1127 void ExtensionPrefs::SetActivePermissions(
1127 const std::string& extension_id, 1128 const std::string& extension_id,
1128 const PermissionSet* permissions) { 1129 const PermissionSet* permissions) {
1129 SetExtensionPrefPermissionSet( 1130 SetExtensionPrefPermissionSet(
1130 extension_id, kPrefActivePermissions, permissions); 1131 extension_id, kPrefActivePermissions, permissions);
1131 } 1132 }
1132 1133
1134 bool ExtensionPrefs::GetPersistedPermissions(
1135 const std::string& extension_id,
1136 URLPatternSet* persisted_permissions) {
1137 CHECK(Extension::IdIsValid(extension_id));
1138 return ReadPrefAsURLPatternSet(extension_id,
1139 kPrefPersistedPermissions,
1140 persisted_permissions,
1141 UserScript::ValidUserScriptSchemes());
1142 }
1143
1144 void ExtensionPrefs::AddPersistedPermission(const Extension* extension,
1145 const URLPattern* pattern) {
1146 DictionaryPrefUpdate update(prefs_, "extensions.settings");
1147 base::DictionaryValue* dict = update.Get();
1148 base::DictionaryValue* prefer = NULL;
1149 dict->GetDictionary(extension->id(), &prefer);
1150
1151 base::ListValue* pattern_list = NULL;
1152
1153 if (!prefer->GetList(kPrefPersistedPermissions, &pattern_list)) {
1154 prefer->Set(kPrefPersistedPermissions, new base::ListValue());
1155 prefer->GetList(kPrefPersistedPermissions, &pattern_list);
1156 }
gpdavis 2014/07/15 21:56:38 If persisted permissions do not exist, we initiali
Devlin 2014/07/15 22:11:01 Probably an URLPattern. Url is too specific; Pref
1157
1158 pattern_list->Append(new base::StringValue(pattern->GetAsString()));
1159 }
1160
1161 void ExtensionPrefs::ClearPersistedPermissions(const Extension* extension) {
gpdavis 2014/07/15 21:56:38 This method will allow us to place a "Clear persis
1162 DictionaryPrefUpdate update(prefs_, "extensions.settings");
1163 base::DictionaryValue* dict = update.Get();
1164 base::DictionaryValue* prefer = NULL;
1165 dict->GetDictionary(extension->id(), &prefer);
1166
1167 prefer->Set(kPrefPersistedPermissions, new base::ListValue());
1168 }
1169
1133 void ExtensionPrefs::SetExtensionRunning(const std::string& extension_id, 1170 void ExtensionPrefs::SetExtensionRunning(const std::string& extension_id,
1134 bool is_running) { 1171 bool is_running) {
1135 base::Value* value = new base::FundamentalValue(is_running); 1172 base::Value* value = new base::FundamentalValue(is_running);
1136 UpdateExtensionPref(extension_id, kPrefRunning, value); 1173 UpdateExtensionPref(extension_id, kPrefRunning, value);
1137 } 1174 }
1138 1175
1139 bool ExtensionPrefs::IsExtensionRunning(const std::string& extension_id) { 1176 bool ExtensionPrefs::IsExtensionRunning(const std::string& extension_id) {
1140 const base::DictionaryValue* extension = GetExtensionPref(extension_id); 1177 const base::DictionaryValue* extension = GetExtensionPref(extension_id);
1141 if (!extension) 1178 if (!extension)
1142 return false; 1179 return false;
(...skipping 1042 matching lines...) Expand 10 before | Expand all | Expand 10 after
2185 extension_pref_value_map_->RegisterExtension( 2222 extension_pref_value_map_->RegisterExtension(
2186 extension_id, install_time, is_enabled, is_incognito_enabled); 2223 extension_id, install_time, is_enabled, is_incognito_enabled);
2187 2224
2188 FOR_EACH_OBSERVER( 2225 FOR_EACH_OBSERVER(
2189 ExtensionPrefsObserver, 2226 ExtensionPrefsObserver,
2190 observer_list_, 2227 observer_list_,
2191 OnExtensionRegistered(extension_id, install_time, is_enabled)); 2228 OnExtensionRegistered(extension_id, install_time, is_enabled));
2192 } 2229 }
2193 2230
2194 } // namespace extensions 2231 } // namespace extensions
OLDNEW
« chrome/browser/extensions/permissions_updater.cc ('K') | « extensions/browser/extension_prefs.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698