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

Side by Side Diff: chrome/browser/supervised_user/supervised_user_service.cc

Issue 404773003: Apps&Extensions for supervised users: Cleanup (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/supervised_user/supervised_user_service.h" 5 #include "chrome/browser/supervised_user/supervised_user_service.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/memory/ref_counted.h" 8 #include "base/memory/ref_counted.h"
9 #include "base/prefs/pref_service.h" 9 #include "base/prefs/pref_service.h"
10 #include "base/strings/string_number_conversions.h" 10 #include "base/strings/string_number_conversions.h"
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after
268 return "Supervised User Service"; 268 return "Supervised User Service";
269 #endif 269 #endif
270 } 270 }
271 271
272 bool SupervisedUserService::UserMayLoad(const extensions::Extension* extension, 272 bool SupervisedUserService::UserMayLoad(const extensions::Extension* extension,
273 base::string16* error) const { 273 base::string16* error) const {
274 base::string16 tmp_error; 274 base::string16 tmp_error;
275 if (ExtensionManagementPolicyImpl(extension, &tmp_error)) 275 if (ExtensionManagementPolicyImpl(extension, &tmp_error))
276 return true; 276 return true;
277 277
278 // If the extension is already loaded, we allow it, otherwise we'd unload
279 // all existing extensions.
280 ExtensionService* extension_service =
281 extensions::ExtensionSystem::Get(profile_)->extension_service();
282
283 // |extension_service| can be NULL in a unit test.
284 if (extension_service &&
285 extension_service->GetInstalledExtension(extension->id()))
286 return true;
287
288 bool was_installed_by_default = extension->was_installed_by_default(); 278 bool was_installed_by_default = extension->was_installed_by_default();
289 bool was_installed_by_custodian = extension->was_installed_by_custodian(); 279 bool was_installed_by_custodian = extension->was_installed_by_custodian();
290 #if defined(OS_CHROMEOS) 280 #if defined(OS_CHROMEOS)
291 // On Chrome OS all external sources are controlled by us so it means that 281 // On Chrome OS all external sources are controlled by us so it means that
292 // they are "default". Method was_installed_by_default returns false because 282 // they are "default". Method was_installed_by_default returns false because
293 // extensions creation flags are ignored in case of default extensions with 283 // extensions creation flags are ignored in case of default extensions with
294 // update URL(the flags aren't passed to OnExternalExtensionUpdateUrlFound). 284 // update URL(the flags aren't passed to OnExternalExtensionUpdateUrlFound).
295 // TODO(dpolukhin): remove this Chrome OS specific code as soon as creation 285 // TODO(dpolukhin): remove this Chrome OS specific code as soon as creation
296 // flags are not ignored. 286 // flags are not ignored.
297 was_installed_by_default = 287 was_installed_by_default =
298 extensions::Manifest::IsExternalLocation(extension->location()); 288 extensions::Manifest::IsExternalLocation(extension->location());
299 #endif 289 #endif
300 if (extension->location() == extensions::Manifest::COMPONENT || 290 if (extensions::Manifest::IsComponentLocation(extension->location()) ||
301 was_installed_by_default || 291 was_installed_by_default ||
302 was_installed_by_custodian) { 292 was_installed_by_custodian) {
303 return true; 293 return true;
304 } 294 }
305 295
306 if (error) 296 if (error)
307 *error = tmp_error; 297 *error = tmp_error;
308 return false; 298 return false;
309 } 299 }
310 300
(...skipping 454 matching lines...) Expand 10 before | Expand all | Expand 10 after
765 755
766 void SupervisedUserService::OnBrowserSetLastActive(Browser* browser) { 756 void SupervisedUserService::OnBrowserSetLastActive(Browser* browser) {
767 bool profile_became_active = profile_->IsSameProfile(browser->profile()); 757 bool profile_became_active = profile_->IsSameProfile(browser->profile());
768 if (!is_profile_active_ && profile_became_active) 758 if (!is_profile_active_ && profile_became_active)
769 content::RecordAction(UserMetricsAction("ManagedUsers_OpenProfile")); 759 content::RecordAction(UserMetricsAction("ManagedUsers_OpenProfile"));
770 else if (is_profile_active_ && !profile_became_active) 760 else if (is_profile_active_ && !profile_became_active)
771 content::RecordAction(UserMetricsAction("ManagedUsers_SwitchProfile")); 761 content::RecordAction(UserMetricsAction("ManagedUsers_SwitchProfile"));
772 762
773 is_profile_active_ = profile_became_active; 763 is_profile_active_ = profile_became_active;
774 } 764 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698