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

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

Issue 2004043002: Supervised Users Initiated Installs v2 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@kid_initiated_install
Patch Set: Fixing the build again! Created 4 years, 5 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 217 matching lines...) Expand 10 before | Expand all | Expand 10 after
228 228
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);
239 const Extension* extension = registry->GetInstalledExtension(extension_id);
240 ExtensionService* service = 238 ExtensionService* service =
241 ExtensionSystem::Get(context)->extension_service(); 239 ExtensionSystem::Get(context)->extension_service();
242 240
243 // If the installed_by_custodian flag is reset, do nothing.
244 if (!installed_by_custodian) { 241 if (!installed_by_custodian) {
245 // If installed_by_custodian changes to false, the extension may need to 242 // If installed_by_custodian changes to false, the extension may need to
246 // be unloaded now. 243 // be unloaded now.
247 service->ReloadExtension(extension_id); 244 service->ReloadExtension(extension_id);
248 return; 245 return;
249 } 246 }
250 247
248 ExtensionRegistry* registry = ExtensionRegistry::Get(context);
251 // If it is already enabled, do nothing. 249 // If it is already enabled, do nothing.
252 if (registry->enabled_extensions().Contains(extension_id)) 250 if (registry->enabled_extensions().Contains(extension_id))
253 return; 251 return;
254 252
255 // If the extension is not loaded, it may need to be reloaded. 253 // If the extension is not loaded, it may need to be reloaded.
256 // Example is a pre-installed extension that was unloaded when a 254 // Example is a pre-installed extension that was unloaded when a
257 // supervised user flag has been received. 255 // supervised user flag has been received.
258 if (!extension) { 256 if (!registry->GetInstalledExtension(extension_id)) {
259 service->ReloadExtension(extension_id); 257 service->ReloadExtension(extension_id);
260 } 258 }
261 } 259 }
262 260
263 bool WasInstalledByCustodian(const std::string& extension_id, 261 bool WasInstalledByCustodian(const std::string& extension_id,
264 content::BrowserContext* context) { 262 content::BrowserContext* context) {
265 bool installed_by_custodian = false; 263 bool installed_by_custodian = false;
266 ExtensionPrefs* prefs = ExtensionPrefs::Get(context); 264 ExtensionPrefs* prefs = ExtensionPrefs::Get(context);
267 prefs->ReadPrefAsBoolean(extension_id, kWasInstalledByCustodianPrefName, 265 prefs->ReadPrefAsBoolean(extension_id, kWasInstalledByCustodianPrefName,
268 &installed_by_custodian); 266 &installed_by_custodian);
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
439 base::FieldTrialList::FindFullName( 437 base::FieldTrialList::FindFullName(
440 kSupervisedUserExtensionPermissionIncreaseFieldTrialName); 438 kSupervisedUserExtensionPermissionIncreaseFieldTrialName);
441 std::string value = variations::GetVariationParamValue( 439 std::string value = variations::GetVariationParamValue(
442 kSupervisedUserExtensionPermissionIncreaseFieldTrialName, 440 kSupervisedUserExtensionPermissionIncreaseFieldTrialName,
443 profile->IsChild() ? "child_account" : "legacy_supervised_user"); 441 profile->IsChild() ? "child_account" : "legacy_supervised_user");
444 return value == "true"; 442 return value == "true";
445 } 443 }
446 444
447 } // namespace util 445 } // namespace util
448 } // namespace extensions 446 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698