| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 #ifndef CHROME_BROWSER_UI_WEBUI_SETTINGS_PEOPLE_HANDLER_H_ | 5 #ifndef CHROME_BROWSER_UI_WEBUI_SETTINGS_PEOPLE_HANDLER_H_ |
| 6 #define CHROME_BROWSER_UI_WEBUI_SETTINGS_PEOPLE_HANDLER_H_ | 6 #define CHROME_BROWSER_UI_WEBUI_SETTINGS_PEOPLE_HANDLER_H_ |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 | 9 |
| 10 #include "base/gtest_prod_util.h" | 10 #include "base/gtest_prod_util.h" |
| 11 #include "base/macros.h" | 11 #include "base/macros.h" |
| 12 #include "base/scoped_observer.h" | 12 #include "base/scoped_observer.h" |
| 13 #include "base/strings/utf_string_conversions.h" | 13 #include "base/strings/utf_string_conversions.h" |
| 14 #include "base/timer/timer.h" | 14 #include "base/timer/timer.h" |
| 15 #include "build/build_config.h" | 15 #include "build/build_config.h" |
| 16 #include "chrome/browser/profiles/profile_attributes_storage.h" | |
| 17 #include "chrome/browser/sync/sync_startup_tracker.h" | 16 #include "chrome/browser/sync/sync_startup_tracker.h" |
| 18 #include "chrome/browser/ui/webui/settings/settings_page_ui_handler.h" | 17 #include "chrome/browser/ui/webui/settings/settings_page_ui_handler.h" |
| 19 #include "chrome/browser/ui/webui/signin/login_ui_service.h" | 18 #include "chrome/browser/ui/webui/signin/login_ui_service.h" |
| 20 #include "components/prefs/pref_change_registrar.h" | 19 #include "components/prefs/pref_change_registrar.h" |
| 21 #include "components/signin/core/browser/signin_manager_base.h" | 20 #include "components/signin/core/browser/signin_manager_base.h" |
| 22 #include "components/sync_driver/sync_service_observer.h" | 21 #include "components/sync_driver/sync_service_observer.h" |
| 23 | 22 |
| 24 #if defined(OS_CHROMEOS) | |
| 25 #include "content/public/browser/notification_observer.h" | |
| 26 #include "content/public/browser/notification_registrar.h" | |
| 27 #endif | |
| 28 | |
| 29 class LoginUIService; | 23 class LoginUIService; |
| 30 class ProfileSyncService; | 24 class ProfileSyncService; |
| 31 class SigninManagerBase; | 25 class SigninManagerBase; |
| 32 | 26 |
| 33 namespace content { | 27 namespace content { |
| 34 class WebContents; | 28 class WebContents; |
| 35 class WebUI; | 29 class WebUI; |
| 36 } | 30 } |
| 37 | 31 |
| 38 namespace signin_metrics { | 32 namespace signin_metrics { |
| 39 enum class AccessPoint; | 33 enum class AccessPoint; |
| 40 } | 34 } |
| 41 | 35 |
| 42 namespace settings { | 36 namespace settings { |
| 43 | 37 |
| 44 class PeopleHandler : public SettingsPageUIHandler, | 38 class PeopleHandler : public SettingsPageUIHandler, |
| 45 public SigninManagerBase::Observer, | 39 public SigninManagerBase::Observer, |
| 46 public SyncStartupTracker::Observer, | 40 public SyncStartupTracker::Observer, |
| 47 public LoginUIService::LoginUI, | 41 public LoginUIService::LoginUI, |
| 48 public sync_driver::SyncServiceObserver, | 42 public sync_driver::SyncServiceObserver { |
| 49 #if defined(OS_CHROMEOS) | |
| 50 public content::NotificationObserver, | |
| 51 #endif | |
| 52 public ProfileAttributesStorage::Observer { | |
| 53 public: | 43 public: |
| 54 explicit PeopleHandler(Profile* profile); | 44 explicit PeopleHandler(Profile* profile); |
| 55 ~PeopleHandler() override; | 45 ~PeopleHandler() override; |
| 56 | 46 |
| 57 // SettingsPageUIHandler implementation. | 47 // SettingsPageUIHandler implementation. |
| 58 void RegisterMessages() override; | 48 void RegisterMessages() override; |
| 59 | 49 |
| 60 // SyncStartupTracker::Observer implementation. | 50 // SyncStartupTracker::Observer implementation. |
| 61 void SyncStartupCompleted() override; | 51 void SyncStartupCompleted() override; |
| 62 void SyncStartupFailed() override; | 52 void SyncStartupFailed() override; |
| 63 | 53 |
| 64 // LoginUIService::LoginUI implementation. | 54 // LoginUIService::LoginUI implementation. |
| 65 void FocusUI() override; | 55 void FocusUI() override; |
| 66 void CloseUI() override; | 56 void CloseUI() override; |
| 67 | 57 |
| 68 // SigninManagerBase::Observer implementation. | 58 // SigninManagerBase::Observer implementation. |
| 69 void GoogleSigninSucceeded(const std::string& account_id, | 59 void GoogleSigninSucceeded(const std::string& account_id, |
| 70 const std::string& username, | 60 const std::string& username, |
| 71 const std::string& password) override; | 61 const std::string& password) override; |
| 72 void GoogleSignedOut(const std::string& account_id, | 62 void GoogleSignedOut(const std::string& account_id, |
| 73 const std::string& username) override; | 63 const std::string& username) override; |
| 74 | 64 |
| 75 // sync_driver::SyncServiceObserver implementation. | 65 // sync_driver::SyncServiceObserver implementation. |
| 76 void OnStateChanged() override; | 66 void OnStateChanged() override; |
| 77 | 67 |
| 78 #if defined(OS_CHROMEOS) | |
| 79 // content::NotificationObserver implementation. | |
| 80 void Observe(int type, | |
| 81 const content::NotificationSource& source, | |
| 82 const content::NotificationDetails& details) override; | |
| 83 #endif | |
| 84 | |
| 85 // ProfileAttributesStorage::Observer implementation. | |
| 86 void OnProfileNameChanged(const base::FilePath& profile_path, | |
| 87 const base::string16& old_profile_name) override; | |
| 88 void OnProfileAvatarChanged(const base::FilePath& profile_path) override; | |
| 89 | |
| 90 // Initializes the sync setup flow and shows the setup UI. | 68 // Initializes the sync setup flow and shows the setup UI. |
| 91 void OpenSyncSetup(bool creating_supervised_user); | 69 void OpenSyncSetup(bool creating_supervised_user); |
| 92 | 70 |
| 93 // Shows advanced configuration dialog without going through sign in dialog. | 71 // Shows advanced configuration dialog without going through sign in dialog. |
| 94 // Kicks the sync backend if necessary with showing spinner dialog until it | 72 // Kicks the sync backend if necessary with showing spinner dialog until it |
| 95 // gets ready. | 73 // gets ready. |
| 96 void OpenConfigureSync(); | 74 void OpenConfigureSync(); |
| 97 | 75 |
| 98 // Terminates the sync setup flow. | 76 // Terminates the sync setup flow. |
| 99 void CloseSyncSetup(); | 77 void CloseSyncSetup(); |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 207 // histograms in the case that the user cancels out. | 185 // histograms in the case that the user cancels out. |
| 208 bool configuring_sync_; | 186 bool configuring_sync_; |
| 209 | 187 |
| 210 // The OneShotTimer object used to timeout of starting the sync backend | 188 // The OneShotTimer object used to timeout of starting the sync backend |
| 211 // service. | 189 // service. |
| 212 std::unique_ptr<base::OneShotTimer> backend_start_timer_; | 190 std::unique_ptr<base::OneShotTimer> backend_start_timer_; |
| 213 | 191 |
| 214 // Used to listen for pref changes to allow or disallow signin. | 192 // Used to listen for pref changes to allow or disallow signin. |
| 215 PrefChangeRegistrar profile_pref_registrar_; | 193 PrefChangeRegistrar profile_pref_registrar_; |
| 216 | 194 |
| 217 #if defined(OS_CHROMEOS) | |
| 218 // Used to listen to ChromeOS user image changes. | |
| 219 content::NotificationRegistrar registrar_; | |
| 220 #endif | |
| 221 | |
| 222 // Manages observer lifetime. | 195 // Manages observer lifetime. |
| 223 ScopedObserver<ProfileSyncService, PeopleHandler> sync_service_observer_; | 196 ScopedObserver<ProfileSyncService, PeopleHandler> sync_service_observer_; |
| 224 | 197 |
| 225 DISALLOW_COPY_AND_ASSIGN(PeopleHandler); | 198 DISALLOW_COPY_AND_ASSIGN(PeopleHandler); |
| 226 }; | 199 }; |
| 227 | 200 |
| 228 } // namespace settings | 201 } // namespace settings |
| 229 | 202 |
| 230 #endif // CHROME_BROWSER_UI_WEBUI_SETTINGS_PEOPLE_HANDLER_H_ | 203 #endif // CHROME_BROWSER_UI_WEBUI_SETTINGS_PEOPLE_HANDLER_H_ |
| OLD | NEW |