OLD | NEW |
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/ui/webui/options/supervised_user_import_handler.h" | 5 #include "chrome/browser/ui/webui/options/supervised_user_import_handler.h" |
6 | 6 |
7 #include <set> | 7 #include <set> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/prefs/pref_service.h" | 10 #include "base/prefs/pref_service.h" |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
49 return cache.ProfileIsLegacySupervisedAtIndex(index); | 49 return cache.ProfileIsLegacySupervisedAtIndex(index); |
50 } | 50 } |
51 | 51 |
52 } // namespace | 52 } // namespace |
53 | 53 |
54 namespace options { | 54 namespace options { |
55 | 55 |
56 SupervisedUserImportHandler::SupervisedUserImportHandler() | 56 SupervisedUserImportHandler::SupervisedUserImportHandler() |
57 : profile_observer_(this), | 57 : profile_observer_(this), |
58 signin_error_observer_(this), | 58 signin_error_observer_(this), |
| 59 supervised_user_sync_service_observer_(this), |
59 removed_profile_is_supervised_(false), | 60 removed_profile_is_supervised_(false), |
60 weak_ptr_factory_(this) { | 61 weak_ptr_factory_(this) { |
61 } | 62 } |
62 | 63 |
63 SupervisedUserImportHandler::~SupervisedUserImportHandler() { | 64 SupervisedUserImportHandler::~SupervisedUserImportHandler() { |
64 Profile* profile = Profile::FromWebUI(web_ui()); | |
65 if (!profile->IsSupervised()) { | |
66 SupervisedUserSyncService* service = | |
67 SupervisedUserSyncServiceFactory::GetForProfile(profile); | |
68 if (service) | |
69 service->RemoveObserver(this); | |
70 subscription_.reset(); | |
71 } | |
72 } | 65 } |
73 | 66 |
74 void SupervisedUserImportHandler::GetLocalizedValues( | 67 void SupervisedUserImportHandler::GetLocalizedValues( |
75 base::DictionaryValue* localized_strings) { | 68 base::DictionaryValue* localized_strings) { |
76 DCHECK(localized_strings); | 69 DCHECK(localized_strings); |
77 | 70 |
78 static OptionsStringResource resources[] = { | 71 static OptionsStringResource resources[] = { |
79 { "supervisedUserImportTitle", | 72 { "supervisedUserImportTitle", |
80 IDS_IMPORT_EXISTING_SUPERVISED_USER_TITLE }, | 73 IDS_IMPORT_EXISTING_SUPERVISED_USER_TITLE }, |
81 { "supervisedUserImportText", IDS_IMPORT_EXISTING_SUPERVISED_USER_TEXT }, | 74 { "supervisedUserImportText", IDS_IMPORT_EXISTING_SUPERVISED_USER_TEXT }, |
(...skipping 16 matching lines...) Expand all Loading... |
98 } | 91 } |
99 | 92 |
100 void SupervisedUserImportHandler::InitializeHandler() { | 93 void SupervisedUserImportHandler::InitializeHandler() { |
101 Profile* profile = Profile::FromWebUI(web_ui()); | 94 Profile* profile = Profile::FromWebUI(web_ui()); |
102 if (!profile->IsSupervised()) { | 95 if (!profile->IsSupervised()) { |
103 profile_observer_.Add( | 96 profile_observer_.Add( |
104 &g_browser_process->profile_manager()->GetProfileInfoCache()); | 97 &g_browser_process->profile_manager()->GetProfileInfoCache()); |
105 SupervisedUserSyncService* sync_service = | 98 SupervisedUserSyncService* sync_service = |
106 SupervisedUserSyncServiceFactory::GetForProfile(profile); | 99 SupervisedUserSyncServiceFactory::GetForProfile(profile); |
107 if (sync_service) { | 100 if (sync_service) { |
108 sync_service->AddObserver(this); | 101 supervised_user_sync_service_observer_.Add(sync_service); |
109 signin_error_observer_.Add( | 102 signin_error_observer_.Add( |
110 SigninErrorControllerFactory::GetForProfile(profile)); | 103 SigninErrorControllerFactory::GetForProfile(profile)); |
111 SupervisedUserSharedSettingsService* settings_service = | 104 SupervisedUserSharedSettingsService* settings_service = |
112 SupervisedUserSharedSettingsServiceFactory::GetForBrowserContext( | 105 SupervisedUserSharedSettingsServiceFactory::GetForBrowserContext( |
113 profile); | 106 profile); |
114 subscription_ = settings_service->Subscribe( | 107 subscription_ = settings_service->Subscribe( |
115 base::Bind(&SupervisedUserImportHandler::OnSharedSettingChanged, | 108 base::Bind(&SupervisedUserImportHandler::OnSharedSettingChanged, |
116 weak_ptr_factory_.GetWeakPtr())); | 109 weak_ptr_factory_.GetWeakPtr())); |
117 } else { | 110 } else { |
118 DCHECK(!SupervisedUserSharedSettingsServiceFactory::GetForBrowserContext( | 111 DCHECK(!SupervisedUserSharedSettingsServiceFactory::GetForBrowserContext( |
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
282 const std::string& key) { | 275 const std::string& key) { |
283 if (key == supervised_users::kChromeAvatarIndex) | 276 if (key == supervised_users::kChromeAvatarIndex) |
284 FetchSupervisedUsers(); | 277 FetchSupervisedUsers(); |
285 } | 278 } |
286 | 279 |
287 void SupervisedUserImportHandler::OnErrorChanged() { | 280 void SupervisedUserImportHandler::OnErrorChanged() { |
288 FetchSupervisedUsers(); | 281 FetchSupervisedUsers(); |
289 } | 282 } |
290 | 283 |
291 } // namespace options | 284 } // namespace options |
OLD | NEW |