| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_SYNC_ONE_CLICK_SIGNIN_SYNC_STARTER_H_ | 5 #ifndef CHROME_BROWSER_UI_SYNC_ONE_CLICK_SIGNIN_SYNC_STARTER_H_ |
| 6 #define CHROME_BROWSER_UI_SYNC_ONE_CLICK_SIGNIN_SYNC_STARTER_H_ | 6 #define CHROME_BROWSER_UI_SYNC_ONE_CLICK_SIGNIN_SYNC_STARTER_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/callback_forward.h" | 10 #include "base/callback_forward.h" |
| 11 #include "base/gtest_prod_util.h" | 11 #include "base/gtest_prod_util.h" |
| 12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
| 13 #include "base/memory/weak_ptr.h" | 13 #include "base/memory/weak_ptr.h" |
| 14 #include "chrome/browser/profiles/profile.h" | 14 #include "chrome/browser/profiles/profile.h" |
| 15 #include "chrome/browser/ui/browser_list_observer.h" | 15 #include "chrome/browser/ui/browser_list_observer.h" |
| 16 #include "chrome/browser/ui/host_desktop.h" | 16 #include "chrome/browser/ui/host_desktop.h" |
| 17 #include "chrome/browser/ui/sync/profile_signin_confirmation_helper.h" | 17 #include "chrome/browser/ui/sync/profile_signin_confirmation_helper.h" |
| 18 #include "chrome/browser/ui/webui/signin/login_ui_service.h" |
| 18 #include "components/signin/core/browser/signin_tracker.h" | 19 #include "components/signin/core/browser/signin_tracker.h" |
| 19 #include "content/public/browser/web_contents_observer.h" | 20 #include "content/public/browser/web_contents_observer.h" |
| 20 | 21 |
| 21 class Browser; | 22 class Browser; |
| 22 class ProfileSyncService; | 23 class ProfileSyncService; |
| 23 | 24 |
| 24 namespace content { | 25 namespace content { |
| 25 class WebContents; | 26 class WebContents; |
| 26 } // namespace content | 27 } // namespace content |
| 27 | 28 |
| 28 // Waits for successful sign-in notification from the signin manager and then | 29 // Waits for successful sign-in notification from the signin manager and then |
| 29 // starts the sync machine. Instances of this class delete themselves once | 30 // starts the sync machine. Instances of this class delete themselves once |
| 30 // the job is done. | 31 // the job is done. |
| 31 class OneClickSigninSyncStarter : public SigninTracker::Observer, | 32 class OneClickSigninSyncStarter : public SigninTracker::Observer, |
| 32 public chrome::BrowserListObserver, | 33 public chrome::BrowserListObserver, |
| 33 public content::WebContentsObserver { | 34 public content::WebContentsObserver, |
| 35 public LoginUIService::Observer { |
| 34 public: | 36 public: |
| 35 enum StartSyncMode { | 37 enum StartSyncMode { |
| 36 // Starts the process of signing the user in with the SigninManager, and | 38 // Starts the process of signing the user in with the SigninManager, and |
| 37 // once completed automatically starts sync with all data types enabled. | 39 // once completed automatically starts sync with all data types enabled. |
| 38 SYNC_WITH_DEFAULT_SETTINGS, | 40 SYNC_WITH_DEFAULT_SETTINGS, |
| 39 | 41 |
| 40 // Starts the process of signing the user in with the SigninManager, and | 42 // Starts the process of signing the user in with the SigninManager, and |
| 43 // once completed shows an inline confirmation UI for sync settings. If the |
| 44 // user dismisses the confirmation UI, sync will start immediately. If the |
| 45 // user clicks the settings link, Chrome will reidrect to the sync settings |
| 46 // page. |
| 47 CONFIRM_SYNC_SETTINGS_FIRST, |
| 48 |
| 49 // Starts the process of signing the user in with the SigninManager, and |
| 41 // once completed redirects the user to the settings page to allow them | 50 // once completed redirects the user to the settings page to allow them |
| 42 // to configure which data types to sync before sync is enabled. | 51 // to configure which data types to sync before sync is enabled. |
| 43 CONFIGURE_SYNC_FIRST, | 52 CONFIGURE_SYNC_FIRST, |
| 44 | 53 |
| 45 // Starts the process of re-authenticating the user via SigninManager, | 54 // Starts the process of re-authenticating the user via SigninManager, |
| 46 // and once completed, redirects the user to the settings page, but doesn't | 55 // and once completed, redirects the user to the settings page, but doesn't |
| 47 // display the configure sync UI. | 56 // display the configure sync UI. |
| 48 SHOW_SETTINGS_WITHOUT_CONFIGURE, | 57 SHOW_SETTINGS_WITHOUT_CONFIGURE, |
| 49 | 58 |
| 50 // The process should be aborted because the undo button has been pressed. | 59 // The process should be aborted because the undo button has been pressed. |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 115 // Initializes the internals of the OneClickSigninSyncStarter object. Can also | 124 // Initializes the internals of the OneClickSigninSyncStarter object. Can also |
| 116 // be used to re-initialize the object to refer to a newly created profile. | 125 // be used to re-initialize the object to refer to a newly created profile. |
| 117 void Initialize(Profile* profile, Browser* browser); | 126 void Initialize(Profile* profile, Browser* browser); |
| 118 | 127 |
| 119 // SigninTracker::Observer override. | 128 // SigninTracker::Observer override. |
| 120 virtual void SigninFailed(const GoogleServiceAuthError& error) OVERRIDE; | 129 virtual void SigninFailed(const GoogleServiceAuthError& error) OVERRIDE; |
| 121 virtual void SigninSuccess() OVERRIDE; | 130 virtual void SigninSuccess() OVERRIDE; |
| 122 virtual void MergeSessionComplete( | 131 virtual void MergeSessionComplete( |
| 123 const GoogleServiceAuthError& error) OVERRIDE; | 132 const GoogleServiceAuthError& error) OVERRIDE; |
| 124 | 133 |
| 134 // LoginUIService::Observer override. |
| 135 virtual void OnSyncConfirmationUIClosed(bool configure_sync_first) OVERRIDE; |
| 136 |
| 125 #if defined(ENABLE_CONFIGURATION_POLICY) | 137 #if defined(ENABLE_CONFIGURATION_POLICY) |
| 126 // User input handler for the signin confirmation dialog. | 138 // User input handler for the signin confirmation dialog. |
| 127 class SigninDialogDelegate | 139 class SigninDialogDelegate |
| 128 : public ui::ProfileSigninConfirmationDelegate { | 140 : public ui::ProfileSigninConfirmationDelegate { |
| 129 public: | 141 public: |
| 130 SigninDialogDelegate( | 142 SigninDialogDelegate( |
| 131 base::WeakPtr<OneClickSigninSyncStarter> sync_starter); | 143 base::WeakPtr<OneClickSigninSyncStarter> sync_starter); |
| 132 virtual ~SigninDialogDelegate(); | 144 virtual ~SigninDialogDelegate(); |
| 133 virtual void OnCancelSignin() OVERRIDE; | 145 virtual void OnCancelSignin() OVERRIDE; |
| 134 virtual void OnContinueSignin() OVERRIDE; | 146 virtual void OnContinueSignin() OVERRIDE; |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 225 std::string client_id_; | 237 std::string client_id_; |
| 226 #endif | 238 #endif |
| 227 | 239 |
| 228 base::WeakPtrFactory<OneClickSigninSyncStarter> weak_pointer_factory_; | 240 base::WeakPtrFactory<OneClickSigninSyncStarter> weak_pointer_factory_; |
| 229 | 241 |
| 230 DISALLOW_COPY_AND_ASSIGN(OneClickSigninSyncStarter); | 242 DISALLOW_COPY_AND_ASSIGN(OneClickSigninSyncStarter); |
| 231 }; | 243 }; |
| 232 | 244 |
| 233 | 245 |
| 234 #endif // CHROME_BROWSER_UI_SYNC_ONE_CLICK_SIGNIN_SYNC_STARTER_H_ | 246 #endif // CHROME_BROWSER_UI_SYNC_ONE_CLICK_SIGNIN_SYNC_STARTER_H_ |
| OLD | NEW |