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 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 229 void SetWasInstalledByCustodian(const std::string& extension_id, | 229 void SetWasInstalledByCustodian(const std::string& extension_id, |
| 230 content::BrowserContext* context, | 230 content::BrowserContext* context, |
| 231 bool installed_by_custodian) { | 231 bool installed_by_custodian) { |
| 232 if (installed_by_custodian == WasInstalledByCustodian(extension_id, context)) | 232 if (installed_by_custodian == WasInstalledByCustodian(extension_id, context)) |
| 233 return; | 233 return; |
| 234 | 234 |
| 235 ExtensionPrefs::Get(context)->UpdateExtensionPref( | 235 ExtensionPrefs::Get(context)->UpdateExtensionPref( |
| 236 extension_id, kWasInstalledByCustodianPrefName, | 236 extension_id, kWasInstalledByCustodianPrefName, |
| 237 installed_by_custodian ? new base::FundamentalValue(true) : nullptr); | 237 installed_by_custodian ? new base::FundamentalValue(true) : nullptr); |
| 238 ExtensionRegistry* registry = ExtensionRegistry::Get(context); | 238 ExtensionRegistry* registry = ExtensionRegistry::Get(context); |
| 239 const Extension* extension = registry->GetInstalledExtension(extension_id); | 239 const Extension* extension = registry->GetInstalledExtension(extension_id); |
|
Marc Treib
2016/06/24 12:46:33
nit: Move getting registry and extension down to w
mamir
2016/06/24 14:43:07
Done.
| |
| 240 ExtensionService* service = | 240 ExtensionService* service = |
| 241 ExtensionSystem::Get(context)->extension_service(); | 241 ExtensionSystem::Get(context)->extension_service(); |
| 242 | 242 |
| 243 // If the installed_by_custodian flag is reset, do nothing. | 243 // If the installed_by_custodian flag is reset, do nothing. |
|
Marc Treib
2016/06/24 12:46:33
Inaccurate, you *do* do something.
mamir
2016/06/24 14:43:07
Done.
| |
| 244 if (!installed_by_custodian) { | 244 if (!installed_by_custodian) { |
| 245 // If installed_by_custodian changes to false, the extension may need to | 245 // If installed_by_custodian changes to false, the extension may need to |
| 246 // be unloaded now. | 246 // be unloaded now. |
| 247 service->ReloadExtension(extension_id); | 247 service->ReloadExtension(extension_id); |
| 248 return; | 248 return; |
| 249 } | 249 } |
| 250 | 250 |
| 251 // If it is already enabled, do nothing. | 251 // If it is already enabled, do nothing. |
| 252 if (registry->enabled_extensions().Contains(extension_id)) | 252 if (registry->enabled_extensions().Contains(extension_id)) |
| 253 return; | 253 return; |
| 254 | 254 |
| 255 // If the extension is not loaded, it may need to be reloaded. | 255 // If the extension is not loaded, it may need to be reloaded. |
| 256 // Example is a pre-installed extension that was unloaded when a | 256 // Example is a pre-installed extension that was unloaded when a |
| 257 // supervised user flag has been received. | 257 // supervised user flag has been received. |
| 258 if (!extension) { | 258 if (!extension) { |
| 259 service->ReloadExtension(extension_id); | 259 service->ReloadExtension(extension_id); |
| 260 service->EnableExtension(extension_id); | |
|
mamir
2016/06/23 11:43:20
Marc, Devlin,
I had to add this call because the t
Marc Treib
2016/06/24 12:46:33
Why does MustRemainDisabled keep it disabled? If w
mamir
2016/06/24 14:43:07
hmm, this is for extension installed by custodian,
Marc Treib
2016/06/24 15:00:59
But it should be called again afterwards, no? That
Devlin
2016/06/24 16:09:39
I would have also thought that calling Reload() wo
mamir
2016/06/27 14:26:59
OK, here is how it works.
The way reload works is
| |
| 260 } | 261 } |
| 261 } | 262 } |
| 262 | 263 |
| 263 bool WasInstalledByCustodian(const std::string& extension_id, | 264 bool WasInstalledByCustodian(const std::string& extension_id, |
| 264 content::BrowserContext* context) { | 265 content::BrowserContext* context) { |
| 265 bool installed_by_custodian = false; | 266 bool installed_by_custodian = false; |
| 266 ExtensionPrefs* prefs = ExtensionPrefs::Get(context); | 267 ExtensionPrefs* prefs = ExtensionPrefs::Get(context); |
| 267 prefs->ReadPrefAsBoolean(extension_id, kWasInstalledByCustodianPrefName, | 268 prefs->ReadPrefAsBoolean(extension_id, kWasInstalledByCustodianPrefName, |
| 268 &installed_by_custodian); | 269 &installed_by_custodian); |
| 269 return installed_by_custodian; | 270 return installed_by_custodian; |
| (...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 439 base::FieldTrialList::FindFullName( | 440 base::FieldTrialList::FindFullName( |
| 440 kSupervisedUserExtensionPermissionIncreaseFieldTrialName); | 441 kSupervisedUserExtensionPermissionIncreaseFieldTrialName); |
| 441 std::string value = variations::GetVariationParamValue( | 442 std::string value = variations::GetVariationParamValue( |
| 442 kSupervisedUserExtensionPermissionIncreaseFieldTrialName, | 443 kSupervisedUserExtensionPermissionIncreaseFieldTrialName, |
| 443 profile->IsChild() ? "child_account" : "legacy_supervised_user"); | 444 profile->IsChild() ? "child_account" : "legacy_supervised_user"); |
| 444 return value == "true"; | 445 return value == "true"; |
| 445 } | 446 } |
| 446 | 447 |
| 447 } // namespace util | 448 } // namespace util |
| 448 } // namespace extensions | 449 } // namespace extensions |
| OLD | NEW |