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

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: Fix the bug of delegated installs for pre-existing extensions 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 SetIsInstalledByCustodian(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)->SetIsInstalledByCustodian(
232 extension_id, installed_by_custodian);
233 ExtensionService* service =
234 ExtensionSystem::Get(context)->extension_service();
235 CHECK(service);
Marc Treib 2016/06/13 09:37:14 ?
mamir 2016/06/13 11:30:16 Done.
236 service->ReloadExtension(extension_id);
237 }
238
223 bool AllowedScriptingOnAllUrls(const std::string& extension_id, 239 bool AllowedScriptingOnAllUrls(const std::string& extension_id,
224 content::BrowserContext* context) { 240 content::BrowserContext* context) {
225 bool allowed = false; 241 bool allowed = false;
226 ExtensionPrefs* prefs = ExtensionPrefs::Get(context); 242 ExtensionPrefs* prefs = ExtensionPrefs::Get(context);
227 if (!prefs->ReadPrefAsBoolean(extension_id, 243 if (!prefs->ReadPrefAsBoolean(extension_id,
228 kExtensionAllowedOnAllUrlsPrefName, 244 kExtensionAllowedOnAllUrlsPrefName,
229 &allowed)) { 245 &allowed)) {
230 // If there is no value present, we make one, defaulting it to the value of 246 // 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 247 // 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. 248 // 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( 405 base::FieldTrialList::FindFullName(
390 kSupervisedUserExtensionPermissionIncreaseFieldTrialName); 406 kSupervisedUserExtensionPermissionIncreaseFieldTrialName);
391 std::string value = variations::GetVariationParamValue( 407 std::string value = variations::GetVariationParamValue(
392 kSupervisedUserExtensionPermissionIncreaseFieldTrialName, 408 kSupervisedUserExtensionPermissionIncreaseFieldTrialName,
393 profile->IsChild() ? "child_account" : "legacy_supervised_user"); 409 profile->IsChild() ? "child_account" : "legacy_supervised_user");
394 return value == "true"; 410 return value == "true";
395 } 411 }
396 412
397 } // namespace util 413 } // namespace util
398 } // namespace extensions 414 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698