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

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

Issue 384893002: Add #ifdefs for the extensions parts of SupervisedUserService. (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 | « chrome/browser/supervised_user/supervised_user_service.h ('k') | 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"
11 #include "base/strings/utf_string_conversions.h" 11 #include "base/strings/utf_string_conversions.h"
12 #include "chrome/browser/browser_process.h" 12 #include "chrome/browser/browser_process.h"
13 #include "chrome/browser/extensions/extension_service.h"
14 #include "chrome/browser/profiles/profile.h" 13 #include "chrome/browser/profiles/profile.h"
15 #include "chrome/browser/profiles/profile_info_cache.h" 14 #include "chrome/browser/profiles/profile_info_cache.h"
16 #include "chrome/browser/profiles/profile_manager.h" 15 #include "chrome/browser/profiles/profile_manager.h"
17 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" 16 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h"
18 #include "chrome/browser/signin/signin_manager_factory.h" 17 #include "chrome/browser/signin/signin_manager_factory.h"
19 #include "chrome/browser/supervised_user/custodian_profile_downloader_service.h" 18 #include "chrome/browser/supervised_user/custodian_profile_downloader_service.h"
20 #include "chrome/browser/supervised_user/custodian_profile_downloader_service_fa ctory.h" 19 #include "chrome/browser/supervised_user/custodian_profile_downloader_service_fa ctory.h"
21 #include "chrome/browser/supervised_user/permission_request_creator_apiary.h" 20 #include "chrome/browser/supervised_user/permission_request_creator_apiary.h"
22 #include "chrome/browser/supervised_user/permission_request_creator_sync.h" 21 #include "chrome/browser/supervised_user/permission_request_creator_sync.h"
23 #include "chrome/browser/supervised_user/supervised_user_constants.h" 22 #include "chrome/browser/supervised_user/supervised_user_constants.h"
24 #include "chrome/browser/supervised_user/supervised_user_pref_mapping_service.h" 23 #include "chrome/browser/supervised_user/supervised_user_pref_mapping_service.h"
25 #include "chrome/browser/supervised_user/supervised_user_pref_mapping_service_fa ctory.h" 24 #include "chrome/browser/supervised_user/supervised_user_pref_mapping_service_fa ctory.h"
26 #include "chrome/browser/supervised_user/supervised_user_registration_utility.h" 25 #include "chrome/browser/supervised_user/supervised_user_registration_utility.h"
27 #include "chrome/browser/supervised_user/supervised_user_settings_service.h" 26 #include "chrome/browser/supervised_user/supervised_user_settings_service.h"
28 #include "chrome/browser/supervised_user/supervised_user_settings_service_factor y.h" 27 #include "chrome/browser/supervised_user/supervised_user_settings_service_factor y.h"
29 #include "chrome/browser/supervised_user/supervised_user_shared_settings_service _factory.h" 28 #include "chrome/browser/supervised_user/supervised_user_shared_settings_service _factory.h"
30 #include "chrome/browser/supervised_user/supervised_user_site_list.h" 29 #include "chrome/browser/supervised_user/supervised_user_site_list.h"
31 #include "chrome/browser/supervised_user/supervised_user_sync_service.h" 30 #include "chrome/browser/supervised_user/supervised_user_sync_service.h"
32 #include "chrome/browser/supervised_user/supervised_user_sync_service_factory.h" 31 #include "chrome/browser/supervised_user/supervised_user_sync_service_factory.h"
33 #include "chrome/browser/sync/profile_sync_service.h" 32 #include "chrome/browser/sync/profile_sync_service.h"
34 #include "chrome/browser/sync/profile_sync_service_factory.h" 33 #include "chrome/browser/sync/profile_sync_service_factory.h"
35 #include "chrome/browser/ui/browser.h" 34 #include "chrome/browser/ui/browser.h"
36 #include "chrome/browser/ui/browser_list.h" 35 #include "chrome/browser/ui/browser_list.h"
37 #include "chrome/common/chrome_switches.h" 36 #include "chrome/common/chrome_switches.h"
38 #include "chrome/common/extensions/api/supervised_user_private/supervised_user_h andler.h"
39 #include "chrome/common/pref_names.h" 37 #include "chrome/common/pref_names.h"
40 #include "components/pref_registry/pref_registry_syncable.h" 38 #include "components/pref_registry/pref_registry_syncable.h"
41 #include "components/signin/core/browser/profile_oauth2_token_service.h" 39 #include "components/signin/core/browser/profile_oauth2_token_service.h"
42 #include "components/signin/core/browser/signin_manager.h" 40 #include "components/signin/core/browser/signin_manager.h"
43 #include "components/signin/core/browser/signin_manager_base.h" 41 #include "components/signin/core/browser/signin_manager_base.h"
44 #include "content/public/browser/browser_thread.h" 42 #include "content/public/browser/browser_thread.h"
45 #include "content/public/browser/user_metrics.h" 43 #include "content/public/browser/user_metrics.h"
46 #include "extensions/browser/extension_registry.h"
47 #include "extensions/browser/extension_system.h"
48 #include "extensions/common/extension_set.h"
49 #include "google_apis/gaia/google_service_auth_error.h" 44 #include "google_apis/gaia/google_service_auth_error.h"
50 #include "grit/generated_resources.h" 45 #include "grit/generated_resources.h"
51 #include "net/base/escape.h" 46 #include "net/base/escape.h"
52 #include "ui/base/l10n/l10n_util.h" 47 #include "ui/base/l10n/l10n_util.h"
53 48
54 #if defined(OS_CHROMEOS) 49 #if defined(OS_CHROMEOS)
Bernhard Bauer 2014/07/11 10:50:02 Could you move this down below ENABLE_THEMES?
Lei Zhang 2014/07/11 19:33:06 Many files generally do OS_ #ifdefs ahead of featu
55 #include "chrome/browser/chromeos/login/users/supervised_user_manager.h" 50 #include "chrome/browser/chromeos/login/users/supervised_user_manager.h"
56 #include "chrome/browser/chromeos/login/users/user_manager.h" 51 #include "chrome/browser/chromeos/login/users/user_manager.h"
57 #endif 52 #endif
58 53
54 #if defined(ENABLE_EXTENSIONS)
55 #include "chrome/browser/extensions/extension_service.h"
56 #include "chrome/common/extensions/api/supervised_user_private/supervised_user_h andler.h"
57 #include "extensions/browser/extension_registry.h"
58 #include "extensions/browser/extension_system.h"
59 #include "extensions/common/extension_set.h"
60 #endif
61
59 #if defined(ENABLE_THEMES) 62 #if defined(ENABLE_THEMES)
60 #include "chrome/browser/themes/theme_service.h" 63 #include "chrome/browser/themes/theme_service.h"
61 #include "chrome/browser/themes/theme_service_factory.h" 64 #include "chrome/browser/themes/theme_service_factory.h"
62 #endif 65 #endif
63 66
64 using base::DictionaryValue; 67 using base::DictionaryValue;
65 using base::UserMetricsAction; 68 using base::UserMetricsAction;
66 using content::BrowserThread; 69 using content::BrowserThread;
67 70
68 SupervisedUserService::URLFilterContext::URLFilterContext() 71 SupervisedUserService::URLFilterContext::URLFilterContext()
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 BrowserThread::IO, 128 BrowserThread::IO,
126 FROM_HERE, 129 FROM_HERE,
127 base::Bind(&SupervisedUserURLFilter::SetManualURLs, 130 base::Bind(&SupervisedUserURLFilter::SetManualURLs,
128 io_url_filter_, base::Owned(url_map.release()))); 131 io_url_filter_, base::Owned(url_map.release())));
129 } 132 }
130 133
131 SupervisedUserService::SupervisedUserService(Profile* profile) 134 SupervisedUserService::SupervisedUserService(Profile* profile)
132 : profile_(profile), 135 : profile_(profile),
133 active_(false), 136 active_(false),
134 delegate_(NULL), 137 delegate_(NULL),
138 #if defined(ENABLE_EXTENSIONS)
135 extension_registry_observer_(this), 139 extension_registry_observer_(this),
140 #endif
136 waiting_for_sync_initialization_(false), 141 waiting_for_sync_initialization_(false),
137 is_profile_active_(false), 142 is_profile_active_(false),
138 elevated_for_testing_(false), 143 elevated_for_testing_(false),
139 did_shutdown_(false), 144 did_shutdown_(false),
140 waiting_for_permissions_(false), 145 waiting_for_permissions_(false),
141 weak_ptr_factory_(this) { 146 weak_ptr_factory_(this) {
142 } 147 }
143 148
144 SupervisedUserService::~SupervisedUserService() { 149 SupervisedUserService::~SupervisedUserService() {
145 DCHECK(did_shutdown_); 150 DCHECK(did_shutdown_);
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
246 251
247 void SupervisedUserService::DidBlockNavigation( 252 void SupervisedUserService::DidBlockNavigation(
248 content::WebContents* web_contents) { 253 content::WebContents* web_contents) {
249 for (std::vector<NavigationBlockedCallback>::iterator it = 254 for (std::vector<NavigationBlockedCallback>::iterator it =
250 navigation_blocked_callbacks_.begin(); 255 navigation_blocked_callbacks_.begin();
251 it != navigation_blocked_callbacks_.end(); ++it) { 256 it != navigation_blocked_callbacks_.end(); ++it) {
252 it->Run(web_contents); 257 it->Run(web_contents);
253 } 258 }
254 } 259 }
255 260
261 #if defined(ENABLE_EXTENSIONS)
256 std::string SupervisedUserService::GetDebugPolicyProviderName() const { 262 std::string SupervisedUserService::GetDebugPolicyProviderName() const {
257 // Save the string space in official builds. 263 // Save the string space in official builds.
258 #ifdef NDEBUG 264 #ifdef NDEBUG
259 NOTREACHED(); 265 NOTREACHED();
260 return std::string(); 266 return std::string();
261 #else 267 #else
262 return "Supervised User Service"; 268 return "Supervised User Service";
263 #endif 269 #endif
264 } 270 }
265 271
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
299 *error = tmp_error; 305 *error = tmp_error;
300 return false; 306 return false;
301 } 307 }
302 308
303 bool SupervisedUserService::UserMayModifySettings( 309 bool SupervisedUserService::UserMayModifySettings(
304 const extensions::Extension* extension, 310 const extensions::Extension* extension,
305 base::string16* error) const { 311 base::string16* error) const {
306 return ExtensionManagementPolicyImpl(extension, error); 312 return ExtensionManagementPolicyImpl(extension, error);
307 } 313 }
308 314
309 void SupervisedUserService::OnStateChanged() {
310 ProfileSyncService* service =
311 ProfileSyncServiceFactory::GetForProfile(profile_);
312 if (waiting_for_sync_initialization_ && service->sync_initialized()) {
313 waiting_for_sync_initialization_ = false;
314 service->RemoveObserver(this);
315 FinishSetupSync();
316 return;
317 }
318
319 DLOG_IF(ERROR, service->GetAuthError().state() ==
320 GoogleServiceAuthError::INVALID_GAIA_CREDENTIALS)
321 << "Credentials rejected";
322 }
323
324 void SupervisedUserService::OnExtensionLoaded( 315 void SupervisedUserService::OnExtensionLoaded(
325 content::BrowserContext* browser_context, 316 content::BrowserContext* browser_context,
326 const extensions::Extension* extension) { 317 const extensions::Extension* extension) {
327 if (!extensions::SupervisedUserInfo::GetContentPackSiteList(extension) 318 if (!extensions::SupervisedUserInfo::GetContentPackSiteList(extension)
328 .empty()) { 319 .empty()) {
329 UpdateSiteLists(); 320 UpdateSiteLists();
330 } 321 }
331 } 322 }
332 void SupervisedUserService::OnExtensionUnloaded( 323 void SupervisedUserService::OnExtensionUnloaded(
333 content::BrowserContext* browser_context, 324 content::BrowserContext* browser_context,
334 const extensions::Extension* extension, 325 const extensions::Extension* extension,
335 extensions::UnloadedExtensionInfo::Reason reason) { 326 extensions::UnloadedExtensionInfo::Reason reason) {
336 if (!extensions::SupervisedUserInfo::GetContentPackSiteList(extension) 327 if (!extensions::SupervisedUserInfo::GetContentPackSiteList(extension)
337 .empty()) { 328 .empty()) {
338 UpdateSiteLists(); 329 UpdateSiteLists();
339 } 330 }
340 } 331 }
332 #endif // defined(ENABLE_EXTENSIONS)
333
334 void SupervisedUserService::OnStateChanged() {
335 ProfileSyncService* service =
336 ProfileSyncServiceFactory::GetForProfile(profile_);
337 if (waiting_for_sync_initialization_ && service->sync_initialized()) {
338 waiting_for_sync_initialization_ = false;
339 service->RemoveObserver(this);
340 FinishSetupSync();
341 return;
342 }
343
344 DLOG_IF(ERROR, service->GetAuthError().state() ==
345 GoogleServiceAuthError::INVALID_GAIA_CREDENTIALS)
346 << "Credentials rejected";
347 }
341 348
342 void SupervisedUserService::SetupSync() { 349 void SupervisedUserService::SetupSync() {
343 StartSetupSync(); 350 StartSetupSync();
344 FinishSetupSyncWhenReady(); 351 FinishSetupSyncWhenReady();
345 } 352 }
346 353
347 void SupervisedUserService::StartSetupSync() { 354 void SupervisedUserService::StartSetupSync() {
348 // Tell the sync service that setup is in progress so we don't start syncing 355 // Tell the sync service that setup is in progress so we don't start syncing
349 // until we've finished configuration. 356 // until we've finished configuration.
350 ProfileSyncServiceFactory::GetForProfile(profile_)->SetSetupInProgress(true); 357 ProfileSyncServiceFactory::GetForProfile(profile_)->SetSetupInProgress(true);
(...skipping 23 matching lines...) Expand all
374 bool sync_everything = false; 381 bool sync_everything = false;
375 syncer::ModelTypeSet synced_datatypes; 382 syncer::ModelTypeSet synced_datatypes;
376 synced_datatypes.Put(syncer::SESSIONS); 383 synced_datatypes.Put(syncer::SESSIONS);
377 service->OnUserChoseDatatypes(sync_everything, synced_datatypes); 384 service->OnUserChoseDatatypes(sync_everything, synced_datatypes);
378 385
379 // Notify ProfileSyncService that we are done with configuration. 386 // Notify ProfileSyncService that we are done with configuration.
380 service->SetSetupInProgress(false); 387 service->SetSetupInProgress(false);
381 service->SetSyncSetupCompleted(); 388 service->SetSyncSetupCompleted();
382 } 389 }
383 390
391 #if defined(ENABLE_EXTENSIONS)
384 bool SupervisedUserService::ExtensionManagementPolicyImpl( 392 bool SupervisedUserService::ExtensionManagementPolicyImpl(
385 const extensions::Extension* extension, 393 const extensions::Extension* extension,
386 base::string16* error) const { 394 base::string16* error) const {
387 // |extension| can be NULL in unit_tests. 395 // |extension| can be NULL in unit_tests.
388 if (!ProfileIsSupervised() || (extension && extension->is_theme())) 396 if (!ProfileIsSupervised() || (extension && extension->is_theme()))
389 return true; 397 return true;
390 398
391 if (elevated_for_testing_) 399 if (elevated_for_testing_)
392 return true; 400 return true;
393 401
(...skipping 22 matching lines...) Expand all
416 extensions::SupervisedUserInfo::GetContentPackSiteList(extension); 424 extensions::SupervisedUserInfo::GetContentPackSiteList(extension);
417 if (!site_list.empty()) { 425 if (!site_list.empty()) {
418 site_lists.push_back(new SupervisedUserSiteList(extension->id(), 426 site_lists.push_back(new SupervisedUserSiteList(extension->id(),
419 site_list.GetFilePath())); 427 site_list.GetFilePath()));
420 } 428 }
421 } 429 }
422 430
423 return site_lists.Pass(); 431 return site_lists.Pass();
424 } 432 }
425 433
434 void SupervisedUserService::SetExtensionsActive() {
435 extensions::ExtensionSystem* extension_system =
436 extensions::ExtensionSystem::Get(profile_);
437 extensions::ManagementPolicy* management_policy =
438 extension_system->management_policy();
439
440 if (active_) {
441 if (management_policy)
442 management_policy->RegisterProvider(this);
443
444 extension_registry_observer_.Add(
445 extensions::ExtensionRegistry::Get(profile_));
446 } else {
447 if (management_policy)
448 management_policy->UnregisterProvider(this);
449
450 extension_registry_observer_.RemoveAll();
451 }
452 }
453 #endif // defined(ENABLE_EXTENSIONS)
454
426 SupervisedUserSettingsService* SupervisedUserService::GetSettingsService() { 455 SupervisedUserSettingsService* SupervisedUserService::GetSettingsService() {
427 return SupervisedUserSettingsServiceFactory::GetForProfile(profile_); 456 return SupervisedUserSettingsServiceFactory::GetForProfile(profile_);
428 } 457 }
429 458
430 void SupervisedUserService::OnSupervisedUserIdChanged() { 459 void SupervisedUserService::OnSupervisedUserIdChanged() {
431 std::string supervised_user_id = 460 std::string supervised_user_id =
432 profile_->GetPrefs()->GetString(prefs::kSupervisedUserId); 461 profile_->GetPrefs()->GetString(prefs::kSupervisedUserId);
433 SetActive(!supervised_user_id.empty()); 462 SetActive(!supervised_user_id.empty());
434 } 463 }
435 464
436 void SupervisedUserService::OnDefaultFilteringBehaviorChanged() { 465 void SupervisedUserService::OnDefaultFilteringBehaviorChanged() {
437 DCHECK(ProfileIsSupervised()); 466 DCHECK(ProfileIsSupervised());
438 467
439 int behavior_value = profile_->GetPrefs()->GetInteger( 468 int behavior_value = profile_->GetPrefs()->GetInteger(
440 prefs::kDefaultSupervisedUserFilteringBehavior); 469 prefs::kDefaultSupervisedUserFilteringBehavior);
441 SupervisedUserURLFilter::FilteringBehavior behavior = 470 SupervisedUserURLFilter::FilteringBehavior behavior =
442 SupervisedUserURLFilter::BehaviorFromInt(behavior_value); 471 SupervisedUserURLFilter::BehaviorFromInt(behavior_value);
443 url_filter_context_.SetDefaultFilteringBehavior(behavior); 472 url_filter_context_.SetDefaultFilteringBehavior(behavior);
444 } 473 }
445 474
446 void SupervisedUserService::UpdateSiteLists() { 475 void SupervisedUserService::UpdateSiteLists() {
476 #if defined(ENABLE_EXTENSIONS)
447 url_filter_context_.LoadWhitelists(GetActiveSiteLists()); 477 url_filter_context_.LoadWhitelists(GetActiveSiteLists());
478 #endif
448 } 479 }
449 480
450 bool SupervisedUserService::AccessRequestsEnabled() { 481 bool SupervisedUserService::AccessRequestsEnabled() {
451 if (waiting_for_permissions_) 482 if (waiting_for_permissions_)
452 return false; 483 return false;
453 484
454 ProfileSyncService* service = 485 ProfileSyncService* service =
455 ProfileSyncServiceFactory::GetForProfile(profile_); 486 ProfileSyncServiceFactory::GetForProfile(profile_);
456 GoogleServiceAuthError::State state = service->GetAuthError().state(); 487 GoogleServiceAuthError::State state = service->GetAuthError().state();
457 // We allow requesting access if Sync is working or has a transient error. 488 // We allow requesting access if Sync is working or has a transient error.
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
573 // Re-set the default theme to turn the SU theme on/off. 604 // Re-set the default theme to turn the SU theme on/off.
574 ThemeService* theme_service = ThemeServiceFactory::GetForProfile(profile_); 605 ThemeService* theme_service = ThemeServiceFactory::GetForProfile(profile_);
575 if (theme_service->UsingDefaultTheme() || theme_service->UsingSystemTheme()) { 606 if (theme_service->UsingDefaultTheme() || theme_service->UsingSystemTheme()) {
576 ThemeServiceFactory::GetForProfile(profile_)->UseDefaultTheme(); 607 ThemeServiceFactory::GetForProfile(profile_)->UseDefaultTheme();
577 } 608 }
578 #endif 609 #endif
579 610
580 SupervisedUserSettingsService* settings_service = GetSettingsService(); 611 SupervisedUserSettingsService* settings_service = GetSettingsService();
581 settings_service->SetActive(active_); 612 settings_service->SetActive(active_);
582 613
583 extensions::ExtensionSystem* extension_system = 614 #if defined(ENABLE_EXTENSIONS)
584 extensions::ExtensionSystem::Get(profile_); 615 SetExtensionsActive();
585 extensions::ManagementPolicy* management_policy = 616 #endif
586 extension_system->management_policy();
587 617
588 if (active_) { 618 if (active_) {
589 if (CommandLine::ForCurrentProcess()->HasSwitch( 619 if (CommandLine::ForCurrentProcess()->HasSwitch(
590 switches::kPermissionRequestApiUrl)) { 620 switches::kPermissionRequestApiUrl)) {
591 permissions_creator_ = 621 permissions_creator_ =
592 PermissionRequestCreatorApiary::CreateWithProfile(profile_); 622 PermissionRequestCreatorApiary::CreateWithProfile(profile_);
593 } else { 623 } else {
594 PrefService* pref_service = profile_->GetPrefs(); 624 PrefService* pref_service = profile_->GetPrefs();
595 permissions_creator_.reset(new PermissionRequestCreatorSync( 625 permissions_creator_.reset(new PermissionRequestCreatorSync(
596 settings_service, 626 settings_service,
597 SupervisedUserSharedSettingsServiceFactory::GetForBrowserContext( 627 SupervisedUserSharedSettingsServiceFactory::GetForBrowserContext(
598 profile_), 628 profile_),
599 pref_service->GetString(prefs::kProfileName), 629 pref_service->GetString(prefs::kProfileName),
600 pref_service->GetString(prefs::kSupervisedUserId))); 630 pref_service->GetString(prefs::kSupervisedUserId)));
601 } 631 }
602 632
603 if (management_policy)
604 management_policy->RegisterProvider(this);
605
606 extension_registry_observer_.Add(
607 extensions::ExtensionRegistry::Get(profile_));
608
609 pref_change_registrar_.Add( 633 pref_change_registrar_.Add(
610 prefs::kDefaultSupervisedUserFilteringBehavior, 634 prefs::kDefaultSupervisedUserFilteringBehavior,
611 base::Bind(&SupervisedUserService::OnDefaultFilteringBehaviorChanged, 635 base::Bind(&SupervisedUserService::OnDefaultFilteringBehaviorChanged,
612 base::Unretained(this))); 636 base::Unretained(this)));
613 pref_change_registrar_.Add(prefs::kSupervisedUserManualHosts, 637 pref_change_registrar_.Add(prefs::kSupervisedUserManualHosts,
614 base::Bind(&SupervisedUserService::UpdateManualHosts, 638 base::Bind(&SupervisedUserService::UpdateManualHosts,
615 base::Unretained(this))); 639 base::Unretained(this)));
616 pref_change_registrar_.Add(prefs::kSupervisedUserManualURLs, 640 pref_change_registrar_.Add(prefs::kSupervisedUserManualURLs,
617 base::Bind(&SupervisedUserService::UpdateManualURLs, 641 base::Bind(&SupervisedUserService::UpdateManualURLs,
618 base::Unretained(this))); 642 base::Unretained(this)));
619 643
620 // Initialize the filter. 644 // Initialize the filter.
621 OnDefaultFilteringBehaviorChanged(); 645 OnDefaultFilteringBehaviorChanged();
622 UpdateSiteLists(); 646 UpdateSiteLists();
623 UpdateManualHosts(); 647 UpdateManualHosts();
624 UpdateManualURLs(); 648 UpdateManualURLs();
625 649
626 #if !defined(OS_ANDROID) 650 #if !defined(OS_ANDROID)
627 // TODO(bauerb): Get rid of the platform-specific #ifdef here. 651 // TODO(bauerb): Get rid of the platform-specific #ifdef here.
628 // http://crbug.com/313377 652 // http://crbug.com/313377
629 BrowserList::AddObserver(this); 653 BrowserList::AddObserver(this);
630 #endif 654 #endif
631 } else { 655 } else {
632 permissions_creator_.reset(); 656 permissions_creator_.reset();
633 657
634 if (management_policy)
635 management_policy->UnregisterProvider(this);
636
637 extension_registry_observer_.RemoveAll();
638
639 pref_change_registrar_.Remove( 658 pref_change_registrar_.Remove(
640 prefs::kDefaultSupervisedUserFilteringBehavior); 659 prefs::kDefaultSupervisedUserFilteringBehavior);
641 pref_change_registrar_.Remove(prefs::kSupervisedUserManualHosts); 660 pref_change_registrar_.Remove(prefs::kSupervisedUserManualHosts);
642 pref_change_registrar_.Remove(prefs::kSupervisedUserManualURLs); 661 pref_change_registrar_.Remove(prefs::kSupervisedUserManualURLs);
643 662
644 if (waiting_for_sync_initialization_) { 663 if (waiting_for_sync_initialization_) {
645 ProfileSyncService* sync_service = 664 ProfileSyncService* sync_service =
646 ProfileSyncServiceFactory::GetForProfile(profile_); 665 ProfileSyncServiceFactory::GetForProfile(profile_);
647 sync_service->RemoveObserver(this); 666 sync_service->RemoveObserver(this);
648 } 667 }
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
744 763
745 void SupervisedUserService::OnBrowserSetLastActive(Browser* browser) { 764 void SupervisedUserService::OnBrowserSetLastActive(Browser* browser) {
746 bool profile_became_active = profile_->IsSameProfile(browser->profile()); 765 bool profile_became_active = profile_->IsSameProfile(browser->profile());
747 if (!is_profile_active_ && profile_became_active) 766 if (!is_profile_active_ && profile_became_active)
748 content::RecordAction(UserMetricsAction("ManagedUsers_OpenProfile")); 767 content::RecordAction(UserMetricsAction("ManagedUsers_OpenProfile"));
749 else if (is_profile_active_ && !profile_became_active) 768 else if (is_profile_active_ && !profile_became_active)
750 content::RecordAction(UserMetricsAction("ManagedUsers_SwitchProfile")); 769 content::RecordAction(UserMetricsAction("ManagedUsers_SwitchProfile"));
751 770
752 is_profile_active_ = profile_became_active; 771 is_profile_active_ = profile_became_active;
753 } 772 }
OLDNEW
« no previous file with comments | « chrome/browser/supervised_user/supervised_user_service.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698