Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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 && | |
|
Devlin
2016/06/13 14:36:58
mention how extension can be null.
mamir
2016/06/13 15:25:31
Done.
| |
| 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 // Since the was_installed_by_custodian is stored as a creation flag in the | |
| 236 // Extension immultable object, a reload is required. | |
|
Marc Treib
2016/06/13 14:36:50
immutable
mamir
2016/06/13 15:25:31
Done.
| |
| 237 service->ReloadExtension(extension_id); | |
| 238 } | |
| 239 | |
| 223 bool AllowedScriptingOnAllUrls(const std::string& extension_id, | 240 bool AllowedScriptingOnAllUrls(const std::string& extension_id, |
| 224 content::BrowserContext* context) { | 241 content::BrowserContext* context) { |
| 225 bool allowed = false; | 242 bool allowed = false; |
| 226 ExtensionPrefs* prefs = ExtensionPrefs::Get(context); | 243 ExtensionPrefs* prefs = ExtensionPrefs::Get(context); |
| 227 if (!prefs->ReadPrefAsBoolean(extension_id, | 244 if (!prefs->ReadPrefAsBoolean(extension_id, |
| 228 kExtensionAllowedOnAllUrlsPrefName, | 245 kExtensionAllowedOnAllUrlsPrefName, |
| 229 &allowed)) { | 246 &allowed)) { |
| 230 // If there is no value present, we make one, defaulting it to the value of | 247 // 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 | 248 // 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. | 249 // does not have permission to script on all urls by default. |
| (...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 389 base::FieldTrialList::FindFullName( | 406 base::FieldTrialList::FindFullName( |
| 390 kSupervisedUserExtensionPermissionIncreaseFieldTrialName); | 407 kSupervisedUserExtensionPermissionIncreaseFieldTrialName); |
| 391 std::string value = variations::GetVariationParamValue( | 408 std::string value = variations::GetVariationParamValue( |
| 392 kSupervisedUserExtensionPermissionIncreaseFieldTrialName, | 409 kSupervisedUserExtensionPermissionIncreaseFieldTrialName, |
| 393 profile->IsChild() ? "child_account" : "legacy_supervised_user"); | 410 profile->IsChild() ? "child_account" : "legacy_supervised_user"); |
| 394 return value == "true"; | 411 return value == "true"; |
| 395 } | 412 } |
| 396 | 413 |
| 397 } // namespace util | 414 } // namespace util |
| 398 } // namespace extensions | 415 } // namespace extensions |
| OLD | NEW |