| 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_SYNC_HANDLER_H_ | 5 #ifndef CHROME_BROWSER_UI_WEBUI_SETTINGS_SYNC_HANDLER_H_ |
| 6 #define CHROME_BROWSER_UI_WEBUI_SETTINGS_SYNC_HANDLER_H_ | 6 #define CHROME_BROWSER_UI_WEBUI_SETTINGS_SYNC_HANDLER_H_ |
| 7 | 7 |
| 8 #include "base/gtest_prod_util.h" | 8 #include "base/gtest_prod_util.h" |
| 9 #include "base/macros.h" | 9 #include "base/macros.h" |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| 11 #include "base/prefs/pref_change_registrar.h" | 11 #include "base/prefs/pref_change_registrar.h" |
| 12 #include "base/scoped_observer.h" | 12 #include "base/scoped_observer.h" |
| 13 #include "base/strings/utf_string_conversions.h" |
| 13 #include "base/timer/timer.h" | 14 #include "base/timer/timer.h" |
| 14 #include "chrome/browser/sync/sync_startup_tracker.h" | 15 #include "chrome/browser/sync/sync_startup_tracker.h" |
| 15 #include "chrome/browser/ui/webui/signin/login_ui_service.h" | 16 #include "chrome/browser/ui/webui/signin/login_ui_service.h" |
| 16 #include "components/signin/core/browser/signin_manager_base.h" | 17 #include "components/signin/core/browser/signin_manager_base.h" |
| 17 #include "components/sync_driver/sync_service_observer.h" | 18 #include "components/sync_driver/sync_service_observer.h" |
| 18 #include "content/public/browser/web_ui_message_handler.h" | 19 #include "content/public/browser/web_ui_message_handler.h" |
| 19 | 20 |
| 20 class LoginUIService; | 21 class LoginUIService; |
| 21 class ProfileSyncService; | 22 class ProfileSyncService; |
| 22 class SigninManagerBase; | 23 class SigninManagerBase; |
| 23 | 24 |
| 24 namespace content { | 25 namespace content { |
| 25 class WebContents; | 26 class WebContents; |
| 26 class WebUI; | 27 class WebUI; |
| 27 } | 28 } |
| 28 | 29 |
| 30 namespace signin_metrics { |
| 31 enum class AccessPoint; |
| 32 } |
| 33 |
| 29 namespace settings { | 34 namespace settings { |
| 30 | 35 |
| 31 class SyncHandler : public content::WebUIMessageHandler, | 36 class SyncHandler : public content::WebUIMessageHandler, |
| 32 public SigninManagerBase::Observer, | 37 public SigninManagerBase::Observer, |
| 33 public SyncStartupTracker::Observer, | 38 public SyncStartupTracker::Observer, |
| 34 public LoginUIService::LoginUI, | 39 public LoginUIService::LoginUI, |
| 35 public sync_driver::SyncServiceObserver { | 40 public sync_driver::SyncServiceObserver { |
| 36 public: | 41 public: |
| 37 explicit SyncHandler(Profile* profile); | 42 explicit SyncHandler(Profile* profile); |
| 38 ~SyncHandler() override; | 43 ~SyncHandler() override; |
| (...skipping 13 matching lines...) Expand all Loading... |
| 52 void GoogleSigninSucceeded(const std::string& account_id, | 57 void GoogleSigninSucceeded(const std::string& account_id, |
| 53 const std::string& username, | 58 const std::string& username, |
| 54 const std::string& password) override; | 59 const std::string& password) override; |
| 55 void GoogleSignedOut(const std::string& account_id, | 60 void GoogleSignedOut(const std::string& account_id, |
| 56 const std::string& username) override; | 61 const std::string& username) override; |
| 57 | 62 |
| 58 // sync_driver::SyncServiceObserver implementation. | 63 // sync_driver::SyncServiceObserver implementation. |
| 59 void OnStateChanged() override; | 64 void OnStateChanged() override; |
| 60 | 65 |
| 61 // Initializes the sync setup flow and shows the setup UI. | 66 // Initializes the sync setup flow and shows the setup UI. |
| 62 void OpenSyncSetup(); | 67 void OpenSyncSetup(const base::ListValue* args); |
| 63 | 68 |
| 64 // Shows advanced configuration dialog without going through sign in dialog. | 69 // Shows advanced configuration dialog without going through sign in dialog. |
| 65 // Kicks the sync backend if necessary with showing spinner dialog until it | 70 // Kicks the sync backend if necessary with showing spinner dialog until it |
| 66 // gets ready. | 71 // gets ready. |
| 67 void OpenConfigureSync(); | 72 void OpenConfigureSync(); |
| 68 | 73 |
| 69 // Terminates the sync setup flow. | 74 // Terminates the sync setup flow. |
| 70 void CloseSyncSetup(); | 75 void CloseSyncSetup(); |
| 71 | 76 |
| 72 // Returns a newly created dictionary with a number of properties that | 77 // Returns a newly created dictionary with a number of properties that |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 120 void HandleShowSetupUI(const base::ListValue* args); | 125 void HandleShowSetupUI(const base::ListValue* args); |
| 121 void HandleDoSignOutOnAuthError(const base::ListValue* args); | 126 void HandleDoSignOutOnAuthError(const base::ListValue* args); |
| 122 void HandleStartSignin(const base::ListValue* args); | 127 void HandleStartSignin(const base::ListValue* args); |
| 123 void HandleStopSyncing(const base::ListValue* args); | 128 void HandleStopSyncing(const base::ListValue* args); |
| 124 void HandleCloseTimeout(const base::ListValue* args); | 129 void HandleCloseTimeout(const base::ListValue* args); |
| 125 void HandleGetSyncStatus(const base::ListValue* args); | 130 void HandleGetSyncStatus(const base::ListValue* args); |
| 126 void HandleManageOtherPeople(const base::ListValue* args); | 131 void HandleManageOtherPeople(const base::ListValue* args); |
| 127 | 132 |
| 128 #if !defined(OS_CHROMEOS) | 133 #if !defined(OS_CHROMEOS) |
| 129 // Displays the GAIA login form. | 134 // Displays the GAIA login form. |
| 130 void DisplayGaiaLogin(); | 135 void DisplayGaiaLogin(signin_metrics::AccessPoint access_point); |
| 131 | 136 |
| 132 // When web-flow is enabled, displays the Gaia login form in a new tab. | 137 // When web-flow is enabled, displays the Gaia login form in a new tab. |
| 133 // This function is virtual so that tests can override. | 138 // This function is virtual so that tests can override. |
| 134 virtual void DisplayGaiaLoginInNewTabOrWindow(); | 139 virtual void DisplayGaiaLoginInNewTabOrWindow( |
| 140 signin_metrics::AccessPoint access_point); |
| 135 #endif | 141 #endif |
| 136 | 142 |
| 137 // A utility function to call before actually showing setup dialog. Makes sure | 143 // A utility function to call before actually showing setup dialog. Makes sure |
| 138 // that a new dialog can be shown and sets flag that setup is in progress. | 144 // that a new dialog can be shown and sets flag that setup is in progress. |
| 139 bool PrepareSyncSetup(); | 145 bool PrepareSyncSetup(); |
| 140 | 146 |
| 141 // Displays spinner-only UI indicating that something is going on in the | 147 // Displays spinner-only UI indicating that something is going on in the |
| 142 // background. | 148 // background. |
| 143 // TODO(kochi): better to show some message that the user can understand what | 149 // TODO(kochi): better to show some message that the user can understand what |
| 144 // is running in the background. | 150 // is running in the background. |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 186 | 192 |
| 187 // Manages observer lifetime. | 193 // Manages observer lifetime. |
| 188 ScopedObserver<ProfileSyncService, SyncHandler> sync_service_observer_; | 194 ScopedObserver<ProfileSyncService, SyncHandler> sync_service_observer_; |
| 189 | 195 |
| 190 DISALLOW_COPY_AND_ASSIGN(SyncHandler); | 196 DISALLOW_COPY_AND_ASSIGN(SyncHandler); |
| 191 }; | 197 }; |
| 192 | 198 |
| 193 } // namespace settings | 199 } // namespace settings |
| 194 | 200 |
| 195 #endif // CHROME_BROWSER_UI_WEBUI_SETTINGS_SYNC_HANDLER_H_ | 201 #endif // CHROME_BROWSER_UI_WEBUI_SETTINGS_SYNC_HANDLER_H_ |
| OLD | NEW |