Chromium Code Reviews| 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 <memory> | 8 #include <memory> |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 34 } // namespace syncer | 34 } // namespace syncer |
| 35 | 35 |
| 36 // Waits for successful sign-in notification from the signin manager and then | 36 // Waits for successful sign-in notification from the signin manager and then |
| 37 // starts the sync machine. Instances of this class delete themselves once | 37 // starts the sync machine. Instances of this class delete themselves once |
| 38 // the job is done. | 38 // the job is done. |
| 39 class OneClickSigninSyncStarter : public SigninTracker::Observer, | 39 class OneClickSigninSyncStarter : public SigninTracker::Observer, |
| 40 public chrome::BrowserListObserver, | 40 public chrome::BrowserListObserver, |
| 41 public content::WebContentsObserver, | 41 public content::WebContentsObserver, |
| 42 public LoginUIService::Observer { | 42 public LoginUIService::Observer { |
| 43 public: | 43 public: |
| 44 enum ProfileMode { | |
| 45 // Attempts to signs the user in |profile_|. Note that if the account to be | |
|
anthonyvd
2016/12/21 19:09:28
nit: sign with no 's'
msarda
2016/12/22 11:58:05
Done.
| |
| 46 // signed in is a managed account, then a profile confirmation dialog is | |
| 47 // shown and the user has the possibility to create a new profile before | |
| 48 // signing in. | |
| 49 CURRENT_PROFILE, | |
| 50 | |
| 51 // Creates a new profile and signs the user in this new profile. | |
| 52 NEW_PROFILE | |
| 53 }; | |
| 54 | |
| 44 enum StartSyncMode { | 55 enum StartSyncMode { |
| 45 // Starts the process of signing the user in with the SigninManager, and | 56 // Starts the process of signing the user in with the SigninManager, and |
| 46 // once completed automatically starts sync with all data types enabled. | 57 // once completed automatically starts sync with all data types enabled. |
| 47 SYNC_WITH_DEFAULT_SETTINGS, | 58 SYNC_WITH_DEFAULT_SETTINGS, |
| 48 | 59 |
| 49 // Starts the process of signing the user in with the SigninManager, and | 60 // Starts the process of signing the user in with the SigninManager, and |
| 50 // once completed shows an inline confirmation UI for sync settings. If the | 61 // once completed shows an inline confirmation UI for sync settings. If the |
| 51 // user dismisses the confirmation UI, sync will start immediately. If the | 62 // user dismisses the confirmation UI, sync will start immediately. If the |
| 52 // user clicks the settings link, Chrome will reidrect to the sync settings | 63 // user clicks the settings link, Chrome will reidrect to the sync settings |
| 53 // page. | 64 // page. |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 98 // |web_contents| will be navigated to the |continue_url| once both signin and | 109 // |web_contents| will be navigated to the |continue_url| once both signin and |
| 99 // Sync setup are complete. | 110 // Sync setup are complete. |
| 100 // |callback| is always executed before OneClickSigninSyncStarter is deleted. | 111 // |callback| is always executed before OneClickSigninSyncStarter is deleted. |
| 101 // It can be empty. | 112 // It can be empty. |
| 102 OneClickSigninSyncStarter(Profile* profile, | 113 OneClickSigninSyncStarter(Profile* profile, |
| 103 Browser* browser, | 114 Browser* browser, |
| 104 const std::string& gaia_id, | 115 const std::string& gaia_id, |
| 105 const std::string& email, | 116 const std::string& email, |
| 106 const std::string& password, | 117 const std::string& password, |
| 107 const std::string& refresh_token, | 118 const std::string& refresh_token, |
| 119 ProfileMode profile_mode, | |
| 108 StartSyncMode start_mode, | 120 StartSyncMode start_mode, |
| 109 content::WebContents* web_contents, | 121 content::WebContents* web_contents, |
| 110 ConfirmationRequired display_confirmation, | 122 ConfirmationRequired display_confirmation, |
| 111 const GURL& current_url, | 123 const GURL& current_url, |
| 112 const GURL& continue_url, | 124 const GURL& continue_url, |
| 113 Callback callback); | 125 Callback callback); |
| 114 | 126 |
| 115 // chrome::BrowserListObserver override. | 127 // chrome::BrowserListObserver override. |
| 116 void OnBrowserRemoved(Browser* browser) override; | 128 void OnBrowserRemoved(Browser* browser) override; |
| 117 | 129 |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 177 // Callback invoked once a profile is created, so we can complete the | 189 // Callback invoked once a profile is created, so we can complete the |
| 178 // credentials transfer, load policy, and open the first window. | 190 // credentials transfer, load policy, and open the first window. |
| 179 void CompleteInitForNewProfile(Profile* profile, | 191 void CompleteInitForNewProfile(Profile* profile, |
| 180 Profile::CreateStatus status); | 192 Profile::CreateStatus status); |
| 181 | 193 |
| 182 // Cancels the in-progress signin for this profile. | 194 // Cancels the in-progress signin for this profile. |
| 183 void CancelSigninAndDelete(); | 195 void CancelSigninAndDelete(); |
| 184 | 196 |
| 185 // Callback invoked to check whether the user needs policy or if a | 197 // Callback invoked to check whether the user needs policy or if a |
| 186 // confirmation is required (in which case we have to prompt the user first). | 198 // confirmation is required (in which case we have to prompt the user first). |
| 187 void ConfirmSignin(const std::string& oauth_token); | 199 void ConfirmSignin(ProfileMode profile_mode, const std::string& oauth_token); |
| 188 | 200 |
| 189 // Displays confirmation UI to the user if confirmation_required_ == | 201 // Displays confirmation UI to the user if confirmation_required_ == |
| 190 // CONFIRM_UNTRUSTED_SIGNIN, otherwise completes the pending signin process. | 202 // CONFIRM_UNTRUSTED_SIGNIN, otherwise completes the pending signin process. |
| 191 void ConfirmAndSignin(); | 203 void ConfirmAndSignin(); |
| 192 | 204 |
| 193 // Callback invoked once the user has responded to the signin confirmation UI. | 205 // Callback invoked once the user has responded to the signin confirmation UI. |
| 194 // If response == UNDO_SYNC, the signin is cancelled, otherwise the pending | 206 // If response == UNDO_SYNC, the signin is cancelled, otherwise the pending |
| 195 // signin is completed. | 207 // signin is completed. |
| 196 void UntrustedSigninConfirmed(StartSyncMode response); | 208 void UntrustedSigninConfirmed(StartSyncMode response); |
| 197 | 209 |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 241 std::string client_id_; | 253 std::string client_id_; |
| 242 | 254 |
| 243 // This only cares about the first AccountAddedToCookie event. Since | 255 // This only cares about the first AccountAddedToCookie event. Since |
| 244 // SigninTracker always expects an observer, this object will just disregard | 256 // SigninTracker always expects an observer, this object will just disregard |
| 245 // following AccountAddedToCookie calls triggered by account reconciliation. | 257 // following AccountAddedToCookie calls triggered by account reconciliation. |
| 246 bool first_account_added_to_cookie_; | 258 bool first_account_added_to_cookie_; |
| 247 | 259 |
| 248 // Prevents Sync from running until configuration is complete. | 260 // Prevents Sync from running until configuration is complete. |
| 249 std::unique_ptr<syncer::SyncSetupInProgressHandle> sync_blocker_; | 261 std::unique_ptr<syncer::SyncSetupInProgressHandle> sync_blocker_; |
| 250 | 262 |
| 251 // Temporary flag to disable new sync confirm page if user choose to create a | |
| 252 // new profile after the corp account signin. | |
| 253 bool skip_sync_confirm_; | |
| 254 | |
| 255 base::WeakPtrFactory<OneClickSigninSyncStarter> weak_pointer_factory_; | 263 base::WeakPtrFactory<OneClickSigninSyncStarter> weak_pointer_factory_; |
| 256 | 264 |
| 257 DISALLOW_COPY_AND_ASSIGN(OneClickSigninSyncStarter); | 265 DISALLOW_COPY_AND_ASSIGN(OneClickSigninSyncStarter); |
| 258 }; | 266 }; |
| 259 | 267 |
| 260 | 268 |
| 261 #endif // CHROME_BROWSER_UI_SYNC_ONE_CLICK_SIGNIN_SYNC_STARTER_H_ | 269 #endif // CHROME_BROWSER_UI_SYNC_ONE_CLICK_SIGNIN_SYNC_STARTER_H_ |
| OLD | NEW |