OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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/managed_mode/managed_user_service.h" | 5 #include "chrome/browser/managed_mode/managed_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 14 matching lines...) Expand all Loading... |
25 #include "chrome/browser/managed_mode/permission_request_creator_sync.h" | 25 #include "chrome/browser/managed_mode/permission_request_creator_sync.h" |
26 #include "chrome/browser/managed_mode/supervised_user_pref_mapping_service.h" | 26 #include "chrome/browser/managed_mode/supervised_user_pref_mapping_service.h" |
27 #include "chrome/browser/managed_mode/supervised_user_pref_mapping_service_facto
ry.h" | 27 #include "chrome/browser/managed_mode/supervised_user_pref_mapping_service_facto
ry.h" |
28 #include "chrome/browser/profiles/profile.h" | 28 #include "chrome/browser/profiles/profile.h" |
29 #include "chrome/browser/profiles/profile_info_cache.h" | 29 #include "chrome/browser/profiles/profile_info_cache.h" |
30 #include "chrome/browser/profiles/profile_manager.h" | 30 #include "chrome/browser/profiles/profile_manager.h" |
31 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" | 31 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" |
32 #include "chrome/browser/signin/signin_manager_factory.h" | 32 #include "chrome/browser/signin/signin_manager_factory.h" |
33 #include "chrome/browser/sync/profile_sync_service.h" | 33 #include "chrome/browser/sync/profile_sync_service.h" |
34 #include "chrome/browser/sync/profile_sync_service_factory.h" | 34 #include "chrome/browser/sync/profile_sync_service_factory.h" |
| 35 #include "chrome/browser/themes/theme_service.h" |
| 36 #include "chrome/browser/themes/theme_service_factory.h" |
35 #include "chrome/browser/ui/browser.h" | 37 #include "chrome/browser/ui/browser.h" |
36 #include "chrome/browser/ui/browser_list.h" | 38 #include "chrome/browser/ui/browser_list.h" |
37 #include "chrome/common/chrome_switches.h" | 39 #include "chrome/common/chrome_switches.h" |
38 #include "chrome/common/extensions/api/managed_mode_private/managed_mode_handler
.h" | 40 #include "chrome/common/extensions/api/managed_mode_private/managed_mode_handler
.h" |
39 #include "chrome/common/pref_names.h" | 41 #include "chrome/common/pref_names.h" |
40 #include "components/pref_registry/pref_registry_syncable.h" | 42 #include "components/pref_registry/pref_registry_syncable.h" |
41 #include "components/signin/core/browser/profile_oauth2_token_service.h" | 43 #include "components/signin/core/browser/profile_oauth2_token_service.h" |
42 #include "components/signin/core/browser/signin_manager.h" | 44 #include "components/signin/core/browser/signin_manager.h" |
43 #include "components/signin/core/browser/signin_manager_base.h" | 45 #include "components/signin/core/browser/signin_manager_base.h" |
44 #include "content/public/browser/browser_thread.h" | 46 #include "content/public/browser/browser_thread.h" |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
118 ui_url_filter_->SetManualURLs(url_map.get()); | 120 ui_url_filter_->SetManualURLs(url_map.get()); |
119 BrowserThread::PostTask( | 121 BrowserThread::PostTask( |
120 BrowserThread::IO, | 122 BrowserThread::IO, |
121 FROM_HERE, | 123 FROM_HERE, |
122 base::Bind(&ManagedModeURLFilter::SetManualURLs, | 124 base::Bind(&ManagedModeURLFilter::SetManualURLs, |
123 io_url_filter_, base::Owned(url_map.release()))); | 125 io_url_filter_, base::Owned(url_map.release()))); |
124 } | 126 } |
125 | 127 |
126 ManagedUserService::ManagedUserService(Profile* profile) | 128 ManagedUserService::ManagedUserService(Profile* profile) |
127 : profile_(profile), | 129 : profile_(profile), |
| 130 active_(false), |
| 131 delegate_(NULL), |
128 extension_registry_observer_(this), | 132 extension_registry_observer_(this), |
129 waiting_for_sync_initialization_(false), | 133 waiting_for_sync_initialization_(false), |
130 is_profile_active_(false), | 134 is_profile_active_(false), |
131 elevated_for_testing_(false), | 135 elevated_for_testing_(false), |
132 did_shutdown_(false), | 136 did_shutdown_(false), |
133 waiting_for_permissions_(false), | 137 waiting_for_permissions_(false), |
134 weak_ptr_factory_(this) { | 138 weak_ptr_factory_(this) { |
135 } | 139 } |
136 | 140 |
137 ManagedUserService::~ManagedUserService() { | 141 ManagedUserService::~ManagedUserService() { |
138 DCHECK(did_shutdown_); | 142 DCHECK(did_shutdown_); |
139 } | 143 } |
140 | 144 |
141 void ManagedUserService::Shutdown() { | 145 void ManagedUserService::Shutdown() { |
142 did_shutdown_ = true; | 146 did_shutdown_ = true; |
143 if (ProfileIsManaged()) { | 147 if (ProfileIsManaged()) { |
144 content::RecordAction(UserMetricsAction("ManagedUsers_QuitBrowser")); | 148 content::RecordAction(UserMetricsAction("ManagedUsers_QuitBrowser")); |
145 #if !defined(OS_ANDROID) | |
146 // TODO(bauerb): Get rid of the platform-specific #ifdef here. | |
147 // http://crbug.com/313377 | |
148 BrowserList::RemoveObserver(this); | |
149 #endif | |
150 } | 149 } |
151 | 150 SetActive(false); |
152 if (!waiting_for_sync_initialization_) | |
153 return; | |
154 | |
155 ProfileSyncService* sync_service = | |
156 ProfileSyncServiceFactory::GetForProfile(profile_); | |
157 sync_service->RemoveObserver(this); | |
158 } | 151 } |
159 | 152 |
160 bool ManagedUserService::ProfileIsManaged() const { | 153 bool ManagedUserService::ProfileIsManaged() const { |
161 return profile_->IsManaged(); | 154 return profile_->IsManaged(); |
162 } | 155 } |
163 | 156 |
164 // static | 157 // static |
165 void ManagedUserService::RegisterProfilePrefs( | 158 void ManagedUserService::RegisterProfilePrefs( |
166 user_prefs::PrefRegistrySyncable* registry) { | 159 user_prefs::PrefRegistrySyncable* registry) { |
167 registry->RegisterDictionaryPref( | 160 registry->RegisterDictionaryPref( |
(...skipping 26 matching lines...) Expand all Loading... |
194 if (!is_managed) | 187 if (!is_managed) |
195 return; | 188 return; |
196 | 189 |
197 std::string managed_user_id = prefs->GetString(prefs::kManagedUserId); | 190 std::string managed_user_id = prefs->GetString(prefs::kManagedUserId); |
198 if (!managed_user_id.empty()) | 191 if (!managed_user_id.empty()) |
199 return; | 192 return; |
200 | 193 |
201 prefs->SetString(prefs::kManagedUserId, "Dummy ID"); | 194 prefs->SetString(prefs::kManagedUserId, "Dummy ID"); |
202 } | 195 } |
203 | 196 |
| 197 void ManagedUserService::SetDelegate(Delegate* delegate) { |
| 198 if (delegate_ == delegate) |
| 199 return; |
| 200 // If the delegate changed, deactivate first to give the old delegate a chance |
| 201 // to clean up. |
| 202 SetActive(false); |
| 203 delegate_ = delegate; |
| 204 } |
| 205 |
204 scoped_refptr<const ManagedModeURLFilter> | 206 scoped_refptr<const ManagedModeURLFilter> |
205 ManagedUserService::GetURLFilterForIOThread() { | 207 ManagedUserService::GetURLFilterForIOThread() { |
206 return url_filter_context_.io_url_filter(); | 208 return url_filter_context_.io_url_filter(); |
207 } | 209 } |
208 | 210 |
209 ManagedModeURLFilter* ManagedUserService::GetURLFilterForUIThread() { | 211 ManagedModeURLFilter* ManagedUserService::GetURLFilterForUIThread() { |
210 return url_filter_context_.ui_url_filter(); | 212 return url_filter_context_.ui_url_filter(); |
211 } | 213 } |
212 | 214 |
213 // Items not on any list must return -1 (CATEGORY_NOT_ON_LIST in history.js). | 215 // Items not on any list must return -1 (CATEGORY_NOT_ON_LIST in history.js). |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
312 return false; | 314 return false; |
313 } | 315 } |
314 | 316 |
315 bool ManagedUserService::UserMayModifySettings( | 317 bool ManagedUserService::UserMayModifySettings( |
316 const extensions::Extension* extension, | 318 const extensions::Extension* extension, |
317 base::string16* error) const { | 319 base::string16* error) const { |
318 return ExtensionManagementPolicyImpl(extension, error); | 320 return ExtensionManagementPolicyImpl(extension, error); |
319 } | 321 } |
320 | 322 |
321 void ManagedUserService::OnStateChanged() { | 323 void ManagedUserService::OnStateChanged() { |
| 324 DCHECK(profile_->GetProfileName().empty()); |
322 ProfileSyncService* service = | 325 ProfileSyncService* service = |
323 ProfileSyncServiceFactory::GetForProfile(profile_); | 326 ProfileSyncServiceFactory::GetForProfile(profile_); |
324 if (waiting_for_sync_initialization_ && service->sync_initialized()) { | 327 if (waiting_for_sync_initialization_ && service->sync_initialized()) { |
325 waiting_for_sync_initialization_ = false; | 328 waiting_for_sync_initialization_ = false; |
326 service->RemoveObserver(this); | 329 service->RemoveObserver(this); |
327 SetupSync(); | 330 SetupSync(); |
328 return; | 331 return; |
329 } | 332 } |
330 | 333 |
331 DLOG_IF(ERROR, service->GetAuthError().state() == | 334 DLOG_IF(ERROR, service->GetAuthError().state() == |
(...skipping 11 matching lines...) Expand all Loading... |
343 void ManagedUserService::OnExtensionUnloaded( | 346 void ManagedUserService::OnExtensionUnloaded( |
344 content::BrowserContext* browser_context, | 347 content::BrowserContext* browser_context, |
345 const extensions::Extension* extension, | 348 const extensions::Extension* extension, |
346 extensions::UnloadedExtensionInfo::Reason reason) { | 349 extensions::UnloadedExtensionInfo::Reason reason) { |
347 if (!extensions::ManagedModeInfo::GetContentPackSiteList(extension).empty()) { | 350 if (!extensions::ManagedModeInfo::GetContentPackSiteList(extension).empty()) { |
348 UpdateSiteLists(); | 351 UpdateSiteLists(); |
349 } | 352 } |
350 } | 353 } |
351 | 354 |
352 void ManagedUserService::SetupSync() { | 355 void ManagedUserService::SetupSync() { |
| 356 DCHECK(profile_->GetProfileName().empty()); |
353 ProfileSyncService* service = | 357 ProfileSyncService* service = |
354 ProfileSyncServiceFactory::GetForProfile(profile_); | 358 ProfileSyncServiceFactory::GetForProfile(profile_); |
355 DCHECK(service->sync_initialized()); | 359 DCHECK(service->sync_initialized()); |
356 | 360 |
357 bool sync_everything = false; | 361 bool sync_everything = false; |
358 syncer::ModelTypeSet synced_datatypes; | 362 syncer::ModelTypeSet synced_datatypes; |
359 synced_datatypes.Put(syncer::MANAGED_USER_SETTINGS); | 363 synced_datatypes.Put(syncer::MANAGED_USER_SETTINGS); |
360 service->OnUserChoseDatatypes(sync_everything, synced_datatypes); | 364 service->OnUserChoseDatatypes(sync_everything, synced_datatypes); |
361 | 365 |
362 // Notify ProfileSyncService that we are done with configuration. | 366 // Notify ProfileSyncService that we are done with configuration. |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
402 } | 406 } |
403 } | 407 } |
404 | 408 |
405 return site_lists.Pass(); | 409 return site_lists.Pass(); |
406 } | 410 } |
407 | 411 |
408 ManagedUserSettingsService* ManagedUserService::GetSettingsService() { | 412 ManagedUserSettingsService* ManagedUserService::GetSettingsService() { |
409 return ManagedUserSettingsServiceFactory::GetForProfile(profile_); | 413 return ManagedUserSettingsServiceFactory::GetForProfile(profile_); |
410 } | 414 } |
411 | 415 |
| 416 void ManagedUserService::OnManagedUserIdChanged() { |
| 417 std::string managed_user_id = |
| 418 profile_->GetPrefs()->GetString(prefs::kManagedUserId); |
| 419 SetActive(!managed_user_id.empty()); |
| 420 } |
| 421 |
412 void ManagedUserService::OnDefaultFilteringBehaviorChanged() { | 422 void ManagedUserService::OnDefaultFilteringBehaviorChanged() { |
413 DCHECK(ProfileIsManaged()); | 423 DCHECK(ProfileIsManaged()); |
414 | 424 |
415 int behavior_value = profile_->GetPrefs()->GetInteger( | 425 int behavior_value = profile_->GetPrefs()->GetInteger( |
416 prefs::kDefaultManagedModeFilteringBehavior); | 426 prefs::kDefaultManagedModeFilteringBehavior); |
417 ManagedModeURLFilter::FilteringBehavior behavior = | 427 ManagedModeURLFilter::FilteringBehavior behavior = |
418 ManagedModeURLFilter::BehaviorFromInt(behavior_value); | 428 ManagedModeURLFilter::BehaviorFromInt(behavior_value); |
419 url_filter_context_.SetDefaultFilteringBehavior(behavior); | 429 url_filter_context_.SetDefaultFilteringBehavior(behavior); |
420 } | 430 } |
421 | 431 |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
485 const base::DictionaryValue* dict = | 495 const base::DictionaryValue* dict = |
486 profile_->GetPrefs()->GetDictionary(prefs::kManagedModeManualURLs); | 496 profile_->GetPrefs()->GetDictionary(prefs::kManagedModeManualURLs); |
487 for (base::DictionaryValue::Iterator it(*dict); !it.IsAtEnd(); it.Advance()) { | 497 for (base::DictionaryValue::Iterator it(*dict); !it.IsAtEnd(); it.Advance()) { |
488 GURL url(it.key()); | 498 GURL url(it.key()); |
489 if (url.host() == host) | 499 if (url.host() == host) |
490 urls->push_back(url); | 500 urls->push_back(url); |
491 } | 501 } |
492 } | 502 } |
493 | 503 |
494 void ManagedUserService::InitSync(const std::string& refresh_token) { | 504 void ManagedUserService::InitSync(const std::string& refresh_token) { |
| 505 DCHECK(profile_->GetProfileName().empty()); |
495 ProfileSyncService* service = | 506 ProfileSyncService* service = |
496 ProfileSyncServiceFactory::GetForProfile(profile_); | 507 ProfileSyncServiceFactory::GetForProfile(profile_); |
497 // Tell the sync service that setup is in progress so we don't start syncing | 508 // Tell the sync service that setup is in progress so we don't start syncing |
498 // until we've finished configuration. | 509 // until we've finished configuration. |
499 service->SetSetupInProgress(true); | 510 service->SetSetupInProgress(true); |
500 | 511 |
501 ProfileOAuth2TokenService* token_service = | 512 ProfileOAuth2TokenService* token_service = |
502 ProfileOAuth2TokenServiceFactory::GetForProfile(profile_); | 513 ProfileOAuth2TokenServiceFactory::GetForProfile(profile_); |
503 token_service->UpdateCredentials(managed_users::kManagedUserPseudoEmail, | 514 token_service->UpdateCredentials(managed_users::kManagedUserPseudoEmail, |
504 refresh_token); | 515 refresh_token); |
505 | 516 |
506 // Continue in SetupSync() once the Sync backend has been initialized. | 517 // Continue in SetupSync() once the Sync backend has been initialized. |
507 if (service->sync_initialized()) { | 518 if (service->sync_initialized()) { |
508 SetupSync(); | 519 SetupSync(); |
509 } else { | 520 } else { |
510 ProfileSyncServiceFactory::GetForProfile(profile_)->AddObserver(this); | 521 ProfileSyncServiceFactory::GetForProfile(profile_)->AddObserver(this); |
511 waiting_for_sync_initialization_ = true; | 522 waiting_for_sync_initialization_ = true; |
512 } | 523 } |
513 } | 524 } |
514 | 525 |
515 void ManagedUserService::Init() { | 526 void ManagedUserService::Init() { |
516 ManagedUserSettingsService* settings_service = GetSettingsService(); | 527 DCHECK(GetSettingsService()->IsReady()); |
517 DCHECK(settings_service->IsReady()); | 528 |
518 if (!ProfileIsManaged()) { | 529 pref_change_registrar_.Init(profile_->GetPrefs()); |
519 settings_service->Clear(); | 530 pref_change_registrar_.Add( |
| 531 prefs::kManagedUserId, |
| 532 base::Bind(&ManagedUserService::OnManagedUserIdChanged, |
| 533 base::Unretained(this))); |
| 534 |
| 535 SetActive(ProfileIsManaged()); |
| 536 } |
| 537 |
| 538 void ManagedUserService::SetActive(bool active) { |
| 539 if (active_ == active) |
520 return; | 540 return; |
| 541 active_ = active; |
| 542 |
| 543 if (!delegate_ || !delegate_->SetActive(active_)) { |
| 544 if (active_) { |
| 545 SupervisedUserPrefMappingServiceFactory::GetForBrowserContext(profile_) |
| 546 ->Init(); |
| 547 |
| 548 CommandLine* command_line = CommandLine::ForCurrentProcess(); |
| 549 if (command_line->HasSwitch(switches::kManagedUserSyncToken)) { |
| 550 InitSync( |
| 551 command_line->GetSwitchValueASCII(switches::kManagedUserSyncToken)); |
| 552 } |
| 553 |
| 554 ProfileOAuth2TokenService* token_service = |
| 555 ProfileOAuth2TokenServiceFactory::GetForProfile(profile_); |
| 556 token_service->LoadCredentials(managed_users::kManagedUserPseudoEmail); |
| 557 } |
521 } | 558 } |
522 | 559 |
523 settings_service->Activate(); | 560 // Now activate/deactivate anything not handled by the delegate yet. |
524 | 561 |
525 SupervisedUserPrefMappingServiceFactory::GetForBrowserContext(profile_) | 562 // Re-set the default theme to turn the SU theme on/off. |
526 ->Init(); | 563 ThemeService* theme_service = ThemeServiceFactory::GetForProfile(profile_); |
527 | 564 if (theme_service->UsingDefaultTheme() || theme_service->UsingSystemTheme()) { |
528 CommandLine* command_line = CommandLine::ForCurrentProcess(); | 565 ThemeServiceFactory::GetForProfile(profile_)->UseDefaultTheme(); |
529 if (command_line->HasSwitch(switches::kManagedUserSyncToken)) { | |
530 InitSync( | |
531 command_line->GetSwitchValueASCII(switches::kManagedUserSyncToken)); | |
532 } | 566 } |
533 | 567 |
534 ProfileOAuth2TokenService* token_service = | 568 ManagedUserSettingsService* settings_service = GetSettingsService(); |
535 ProfileOAuth2TokenServiceFactory::GetForProfile(profile_); | 569 settings_service->SetActive(active_); |
536 token_service->LoadCredentials(managed_users::kManagedUserPseudoEmail); | |
537 if (CommandLine::ForCurrentProcess()->HasSwitch( | |
538 switches::kPermissionRequestApiUrl)) { | |
539 permissions_creator_ = | |
540 PermissionRequestCreatorApiary::CreateWithProfile(profile_); | |
541 } else { | |
542 PrefService* pref_service = profile_->GetPrefs(); | |
543 permissions_creator_.reset(new PermissionRequestCreatorSync( | |
544 settings_service, | |
545 ManagedUserSharedSettingsServiceFactory::GetForBrowserContext(profile_), | |
546 pref_service->GetString(prefs::kProfileName), | |
547 pref_service->GetString(prefs::kManagedUserId))); | |
548 } | |
549 | 570 |
550 extensions::ExtensionSystem* extension_system = | 571 extensions::ExtensionSystem* extension_system = |
551 extensions::ExtensionSystem::Get(profile_); | 572 extensions::ExtensionSystem::Get(profile_); |
552 extensions::ManagementPolicy* management_policy = | 573 extensions::ManagementPolicy* management_policy = |
553 extension_system->management_policy(); | 574 extension_system->management_policy(); |
554 if (management_policy) | |
555 extension_system->management_policy()->RegisterProvider(this); | |
556 | 575 |
557 extension_registry_observer_.Add( | 576 if (active_) { |
558 extensions::ExtensionRegistry::Get(profile_)); | 577 if (CommandLine::ForCurrentProcess()->HasSwitch( |
| 578 switches::kPermissionRequestApiUrl)) { |
| 579 permissions_creator_ = |
| 580 PermissionRequestCreatorApiary::CreateWithProfile(profile_); |
| 581 } else { |
| 582 PrefService* pref_service = profile_->GetPrefs(); |
| 583 permissions_creator_.reset(new PermissionRequestCreatorSync( |
| 584 settings_service, |
| 585 ManagedUserSharedSettingsServiceFactory::GetForBrowserContext( |
| 586 profile_), |
| 587 pref_service->GetString(prefs::kProfileName), |
| 588 pref_service->GetString(prefs::kManagedUserId))); |
| 589 } |
559 | 590 |
560 pref_change_registrar_.Init(profile_->GetPrefs()); | 591 if (management_policy) |
561 pref_change_registrar_.Add( | 592 management_policy->RegisterProvider(this); |
562 prefs::kDefaultManagedModeFilteringBehavior, | 593 |
563 base::Bind(&ManagedUserService::OnDefaultFilteringBehaviorChanged, | 594 extension_registry_observer_.Add( |
564 base::Unretained(this))); | 595 extensions::ExtensionRegistry::Get(profile_)); |
565 pref_change_registrar_.Add(prefs::kManagedModeManualHosts, | 596 |
566 base::Bind(&ManagedUserService::UpdateManualHosts, | 597 pref_change_registrar_.Add( |
567 base::Unretained(this))); | 598 prefs::kDefaultManagedModeFilteringBehavior, |
568 pref_change_registrar_.Add(prefs::kManagedModeManualURLs, | 599 base::Bind(&ManagedUserService::OnDefaultFilteringBehaviorChanged, |
569 base::Bind(&ManagedUserService::UpdateManualURLs, | 600 base::Unretained(this))); |
570 base::Unretained(this))); | 601 pref_change_registrar_.Add(prefs::kManagedModeManualHosts, |
| 602 base::Bind(&ManagedUserService::UpdateManualHosts, |
| 603 base::Unretained(this))); |
| 604 pref_change_registrar_.Add(prefs::kManagedModeManualURLs, |
| 605 base::Bind(&ManagedUserService::UpdateManualURLs, |
| 606 base::Unretained(this))); |
| 607 |
| 608 // Initialize the filter. |
| 609 OnDefaultFilteringBehaviorChanged(); |
| 610 UpdateSiteLists(); |
| 611 UpdateManualHosts(); |
| 612 UpdateManualURLs(); |
571 | 613 |
572 #if !defined(OS_ANDROID) | 614 #if !defined(OS_ANDROID) |
573 // TODO(bauerb): Get rid of the platform-specific #ifdef here. | 615 // TODO(bauerb): Get rid of the platform-specific #ifdef here. |
574 // http://crbug.com/313377 | 616 // http://crbug.com/313377 |
575 BrowserList::AddObserver(this); | 617 BrowserList::AddObserver(this); |
576 #endif | 618 #endif |
| 619 } else { |
| 620 permissions_creator_.reset(); |
577 | 621 |
578 // Initialize the filter. | 622 if (management_policy) |
579 OnDefaultFilteringBehaviorChanged(); | 623 management_policy->UnregisterProvider(this); |
580 UpdateSiteLists(); | 624 |
581 UpdateManualHosts(); | 625 extension_registry_observer_.RemoveAll(); |
582 UpdateManualURLs(); | 626 |
| 627 pref_change_registrar_.Remove(prefs::kDefaultManagedModeFilteringBehavior); |
| 628 pref_change_registrar_.Remove(prefs::kManagedModeManualHosts); |
| 629 pref_change_registrar_.Remove(prefs::kManagedModeManualURLs); |
| 630 |
| 631 if (waiting_for_sync_initialization_) { |
| 632 ProfileSyncService* sync_service = |
| 633 ProfileSyncServiceFactory::GetForProfile(profile_); |
| 634 sync_service->RemoveObserver(this); |
| 635 } |
| 636 |
| 637 #if !defined(OS_ANDROID) |
| 638 // TODO(bauerb): Get rid of the platform-specific #ifdef here. |
| 639 // http://crbug.com/313377 |
| 640 BrowserList::RemoveObserver(this); |
| 641 #endif |
| 642 } |
583 } | 643 } |
584 | 644 |
585 void ManagedUserService::RegisterAndInitSync( | 645 void ManagedUserService::RegisterAndInitSync( |
586 ManagedUserRegistrationUtility* registration_utility, | 646 ManagedUserRegistrationUtility* registration_utility, |
587 Profile* custodian_profile, | 647 Profile* custodian_profile, |
588 const std::string& managed_user_id, | 648 const std::string& managed_user_id, |
589 const AuthErrorCallback& callback) { | 649 const AuthErrorCallback& callback) { |
590 DCHECK(ProfileIsManaged()); | 650 DCHECK(ProfileIsManaged()); |
| 651 DCHECK(profile_->GetProfileName().empty()); |
591 DCHECK(!custodian_profile->IsManaged()); | 652 DCHECK(!custodian_profile->IsManaged()); |
592 | 653 |
593 base::string16 name = base::UTF8ToUTF16( | 654 base::string16 name = base::UTF8ToUTF16( |
594 profile_->GetPrefs()->GetString(prefs::kProfileName)); | 655 profile_->GetPrefs()->GetString(prefs::kProfileName)); |
595 int avatar_index = profile_->GetPrefs()->GetInteger( | 656 int avatar_index = profile_->GetPrefs()->GetInteger( |
596 prefs::kProfileAvatarIndex); | 657 prefs::kProfileAvatarIndex); |
597 ManagedUserRegistrationInfo info(name, avatar_index); | 658 ManagedUserRegistrationInfo info(name, avatar_index); |
598 registration_utility->Register( | 659 registration_utility->Register( |
599 managed_user_id, | 660 managed_user_id, |
600 info, | 661 info, |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
671 | 732 |
672 void ManagedUserService::OnBrowserSetLastActive(Browser* browser) { | 733 void ManagedUserService::OnBrowserSetLastActive(Browser* browser) { |
673 bool profile_became_active = profile_->IsSameProfile(browser->profile()); | 734 bool profile_became_active = profile_->IsSameProfile(browser->profile()); |
674 if (!is_profile_active_ && profile_became_active) | 735 if (!is_profile_active_ && profile_became_active) |
675 content::RecordAction(UserMetricsAction("ManagedUsers_OpenProfile")); | 736 content::RecordAction(UserMetricsAction("ManagedUsers_OpenProfile")); |
676 else if (is_profile_active_ && !profile_became_active) | 737 else if (is_profile_active_ && !profile_became_active) |
677 content::RecordAction(UserMetricsAction("ManagedUsers_SwitchProfile")); | 738 content::RecordAction(UserMetricsAction("ManagedUsers_SwitchProfile")); |
678 | 739 |
679 is_profile_active_ = profile_became_active; | 740 is_profile_active_ = profile_became_active; |
680 } | 741 } |
OLD | NEW |