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

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: Discriminate between explicit and scriptable hosts, other minor changes Created 6 years, 4 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 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 // A preference specifying if the user dragged the app on the NTP. 135 // A preference specifying if the user dragged the app on the NTP.
136 const char kPrefUserDraggedApp[] = "user_dragged_app_ntp"; 136 const char kPrefUserDraggedApp[] = "user_dragged_app_ntp";
137 137
138 // Preferences that hold which permissions the user has granted the extension. 138 // Preferences that hold which permissions the user has granted the extension.
139 // We explicitly keep track of these so that extensions can contain unknown 139 // We explicitly keep track of these so that extensions can contain unknown
140 // permissions, for backwards compatibility reasons, and we can still prompt 140 // permissions, for backwards compatibility reasons, and we can still prompt
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 const char kPrefPersistedPermissions[] = "persisted_permissions";
145 146
146 // The preference names for PermissionSet values. 147 // The preference names for PermissionSet values.
147 const char kPrefAPIs[] = "api"; 148 const char kPrefAPIs[] = "api";
148 const char kPrefManifestPermissions[] = "manifest_permissions"; 149 const char kPrefManifestPermissions[] = "manifest_permissions";
149 const char kPrefExplicitHosts[] = "explicit_host"; 150 const char kPrefExplicitHosts[] = "explicit_host";
150 const char kPrefScriptableHosts[] = "scriptable_host"; 151 const char kPrefScriptableHosts[] = "scriptable_host";
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";
(...skipping 971 matching lines...) Expand 10 before | Expand all | Expand 10 after
1126 return ReadPrefAsPermissionSet(extension_id, kPrefActivePermissions); 1127 return ReadPrefAsPermissionSet(extension_id, kPrefActivePermissions);
1127 } 1128 }
1128 1129
1129 void ExtensionPrefs::SetActivePermissions( 1130 void ExtensionPrefs::SetActivePermissions(
1130 const std::string& extension_id, 1131 const std::string& extension_id,
1131 const PermissionSet* permissions) { 1132 const PermissionSet* permissions) {
1132 SetExtensionPrefPermissionSet( 1133 SetExtensionPrefPermissionSet(
1133 extension_id, kPrefActivePermissions, permissions); 1134 extension_id, kPrefActivePermissions, permissions);
1134 } 1135 }
1135 1136
1137 PermissionSet* ExtensionPrefs::GetPersistedPermissions(
1138 const std::string& extension_id) {
1139 CHECK(Extension::IdIsValid(extension_id));
1140 return ReadPrefAsPermissionSet(extension_id, kPrefPersistedPermissions);
1141 }
1142
1143 void ExtensionPrefs::AddPersistedPermission(const std::string& extension_id,
1144 const PermissionSet* permissions) {
1145 scoped_refptr<PermissionSet> old_permissions(
1146 GetPersistedPermissions(extension_id));
1147 SetExtensionPrefPermissionSet(
1148 extension_id,
1149 kPrefPersistedPermissions,
1150 PermissionSet::CreateUnion(old_permissions.get(), permissions));
1151 }
1152
1153 void ExtensionPrefs::ClearPersistedPermissions(
1154 const std::string& extension_id) {
1155 SetExtensionPrefPermissionSet(
1156 extension_id, kPrefPersistedPermissions, new PermissionSet());
1157 }
1158
1136 void ExtensionPrefs::SetExtensionRunning(const std::string& extension_id, 1159 void ExtensionPrefs::SetExtensionRunning(const std::string& extension_id,
1137 bool is_running) { 1160 bool is_running) {
1138 base::Value* value = new base::FundamentalValue(is_running); 1161 base::Value* value = new base::FundamentalValue(is_running);
1139 UpdateExtensionPref(extension_id, kPrefRunning, value); 1162 UpdateExtensionPref(extension_id, kPrefRunning, value);
1140 } 1163 }
1141 1164
1142 bool ExtensionPrefs::IsExtensionRunning(const std::string& extension_id) { 1165 bool ExtensionPrefs::IsExtensionRunning(const std::string& extension_id) {
1143 const base::DictionaryValue* extension = GetExtensionPref(extension_id); 1166 const base::DictionaryValue* extension = GetExtensionPref(extension_id);
1144 if (!extension) 1167 if (!extension)
1145 return false; 1168 return false;
(...skipping 1061 matching lines...) Expand 10 before | Expand all | Expand 10 after
2207 extension_pref_value_map_->RegisterExtension( 2230 extension_pref_value_map_->RegisterExtension(
2208 extension_id, install_time, is_enabled, is_incognito_enabled); 2231 extension_id, install_time, is_enabled, is_incognito_enabled);
2209 2232
2210 FOR_EACH_OBSERVER( 2233 FOR_EACH_OBSERVER(
2211 ExtensionPrefsObserver, 2234 ExtensionPrefsObserver,
2212 observer_list_, 2235 observer_list_,
2213 OnExtensionRegistered(extension_id, install_time, is_enabled)); 2236 OnExtensionRegistered(extension_id, install_time, is_enabled));
2214 } 2237 }
2215 2238
2216 } // namespace extensions 2239 } // namespace extensions
OLDNEW
« extensions/browser/extension_prefs.h ('K') | « extensions/browser/extension_prefs.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698