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

Side by Side Diff: chrome/browser/extensions/extension_util.cc

Issue 2054773002: Replace the WAS_INSTALLED_BY_CUSTODIAN creation flag with a pref (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Response to code review by treib@ Created 4 years, 6 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "chrome/browser/extensions/extension_util.h" 5 #include "chrome/browser/extensions/extension_util.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/metrics/field_trial.h" 9 #include "base/metrics/field_trial.h"
10 #include "base/values.h" 10 #include "base/values.h"
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
213 // Reload to update browser state. Only bother if the value changed and the 213 // Reload to update browser state. Only bother if the value changed and the
214 // extension is actually enabled, since there is no UI otherwise. 214 // extension is actually enabled, since there is no UI otherwise.
215 if (allow == AllowFileAccess(extension_id, context)) 215 if (allow == AllowFileAccess(extension_id, context))
216 return; 216 return;
217 217
218 ExtensionPrefs::Get(context)->SetAllowFileAccess(extension_id, allow); 218 ExtensionPrefs::Get(context)->SetAllowFileAccess(extension_id, allow);
219 219
220 ReloadExtensionIfEnabled(extension_id, context); 220 ReloadExtensionIfEnabled(extension_id, context);
221 } 221 }
222 222
223 void SetWasInstalledByCustodian(const std::string& extension_id,
224 content::BrowserContext* context,
225 bool installed_by_custodian) {
226 const Extension* extension =
227 ExtensionRegistry::Get(context)->GetInstalledExtension(extension_id);
228 if (extension &&
229 installed_by_custodian == extension->was_installed_by_custodian())
230 return;
231 ExtensionPrefs::Get(context)->SetWasInstalledByCustodian(
232 extension_id, installed_by_custodian);
233 ExtensionService* service =
234 ExtensionSystem::Get(context)->extension_service();
235 service->ReloadExtension(extension_id);
Marc Treib 2016/06/13 12:17:09 Maybe add a comment on why the reload is necessary
mamir 2016/06/13 14:15:57 Done.
236 }
237
223 bool AllowedScriptingOnAllUrls(const std::string& extension_id, 238 bool AllowedScriptingOnAllUrls(const std::string& extension_id,
224 content::BrowserContext* context) { 239 content::BrowserContext* context) {
225 bool allowed = false; 240 bool allowed = false;
226 ExtensionPrefs* prefs = ExtensionPrefs::Get(context); 241 ExtensionPrefs* prefs = ExtensionPrefs::Get(context);
227 if (!prefs->ReadPrefAsBoolean(extension_id, 242 if (!prefs->ReadPrefAsBoolean(extension_id,
228 kExtensionAllowedOnAllUrlsPrefName, 243 kExtensionAllowedOnAllUrlsPrefName,
229 &allowed)) { 244 &allowed)) {
230 // If there is no value present, we make one, defaulting it to the value of 245 // If there is no value present, we make one, defaulting it to the value of
231 // the 'scripts require action' flag. If the flag is on, then the extension 246 // the 'scripts require action' flag. If the flag is on, then the extension
232 // does not have permission to script on all urls by default. 247 // does not have permission to script on all urls by default.
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
389 base::FieldTrialList::FindFullName( 404 base::FieldTrialList::FindFullName(
390 kSupervisedUserExtensionPermissionIncreaseFieldTrialName); 405 kSupervisedUserExtensionPermissionIncreaseFieldTrialName);
391 std::string value = variations::GetVariationParamValue( 406 std::string value = variations::GetVariationParamValue(
392 kSupervisedUserExtensionPermissionIncreaseFieldTrialName, 407 kSupervisedUserExtensionPermissionIncreaseFieldTrialName,
393 profile->IsChild() ? "child_account" : "legacy_supervised_user"); 408 profile->IsChild() ? "child_account" : "legacy_supervised_user");
394 return value == "true"; 409 return value == "true";
395 } 410 }
396 411
397 } // namespace util 412 } // namespace util
398 } // namespace extensions 413 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698