| 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_HELPER_H_ | 5 #ifndef CHROME_BROWSER_UI_SYNC_ONE_CLICK_SIGNIN_HELPER_H_ |
| 6 #define CHROME_BROWSER_UI_SYNC_ONE_CLICK_SIGNIN_HELPER_H_ | 6 #define CHROME_BROWSER_UI_SYNC_ONE_CLICK_SIGNIN_HELPER_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/gtest_prod_util.h" | 10 #include "base/gtest_prod_util.h" |
| (...skipping 26 matching lines...) Expand all Loading... |
| 37 class URLRequest; | 37 class URLRequest; |
| 38 } | 38 } |
| 39 | 39 |
| 40 // Per-tab one-click signin helper. When a user signs in to a Google service | 40 // Per-tab one-click signin helper. When a user signs in to a Google service |
| 41 // and the profile is not yet connected to a Google account, will start the | 41 // and the profile is not yet connected to a Google account, will start the |
| 42 // process of helping the user connect his profile with one click. The process | 42 // process of helping the user connect his profile with one click. The process |
| 43 // begins with an infobar and is followed with a confirmation dialog explaining | 43 // begins with an infobar and is followed with a confirmation dialog explaining |
| 44 // more about what this means. | 44 // more about what this means. |
| 45 class OneClickSigninHelper | 45 class OneClickSigninHelper |
| 46 : public content::WebContentsObserver, | 46 : public content::WebContentsObserver, |
| 47 public content::WebContentsUserData<OneClickSigninHelper>, | 47 public content::WebContentsUserData<OneClickSigninHelper> { |
| 48 public ProfileSyncServiceObserver { | |
| 49 public: | 48 public: |
| 50 // Represents user's decision about sign in process. | 49 // Represents user's decision about sign in process. |
| 51 enum AutoAccept { | 50 enum AutoAccept { |
| 52 // User decision not yet known. Assume cancel. | 51 // User decision not yet known. Assume cancel. |
| 53 AUTO_ACCEPT_NONE, | 52 AUTO_ACCEPT_NONE, |
| 54 | 53 |
| 55 // User has explicitly accepted to sign in. A bubble is shown with the | 54 // User has explicitly accepted to sign in. A bubble is shown with the |
| 56 // option to start sync, configure it first, or abort. | 55 // option to start sync, configure it first, or abort. |
| 57 AUTO_ACCEPT_ACCEPTED, | 56 AUTO_ACCEPT_ACCEPTED, |
| 58 | 57 |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 114 | 113 |
| 115 // Web contents in which the sync setup page should be displayed, | 114 // Web contents in which the sync setup page should be displayed, |
| 116 // if necessary. Can be NULL. | 115 // if necessary. Can be NULL. |
| 117 content::WebContents* web_contents; | 116 content::WebContents* web_contents; |
| 118 | 117 |
| 119 OneClickSigninSyncStarter::ConfirmationRequired confirmation_required; | 118 OneClickSigninSyncStarter::ConfirmationRequired confirmation_required; |
| 120 signin::Source source; | 119 signin::Source source; |
| 121 OneClickSigninSyncStarter::Callback callback; | 120 OneClickSigninSyncStarter::Callback callback; |
| 122 }; | 121 }; |
| 123 | 122 |
| 124 // Wrapper to call OneClickSigninSyncStarter after fetching the refresh | 123 // Wrapper to call OneClickSigninSyncStarter after fetching the refresh token |
| 125 // token if needed. Also verifies that the cookie are correct if no password | 124 // if needed. Also verifies that the cookies are correct if no password is |
| 126 // is specified, and checks that the email from the cookies match the expected | 125 // specified, and checks that the email from the cookies match the expected |
| 127 // email address. | 126 // email address. |
| 128 class SyncStarterWrapper : public SigninOAuthHelper::Consumer, | 127 class SyncStarterWrapper : public SigninOAuthHelper::Consumer, |
| 129 public chrome::BrowserListObserver { | 128 public chrome::BrowserListObserver { |
| 130 public: | 129 public: |
| 131 SyncStarterWrapper( | 130 SyncStarterWrapper( |
| 132 const OneClickSigninHelper::StartSyncArgs& args, | 131 const OneClickSigninHelper::StartSyncArgs& args, |
| 133 OneClickSigninSyncStarter::StartSyncMode start_mode); | 132 OneClickSigninSyncStarter::StartSyncMode start_mode); |
| 134 virtual ~SyncStarterWrapper(); | 133 virtual ~SyncStarterWrapper(); |
| 135 | 134 |
| 136 void Start(); | 135 void Start(); |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 246 FRIEND_TEST_ALL_PREFIXES(OneClickSigninHelperIncognitoTest, | 245 FRIEND_TEST_ALL_PREFIXES(OneClickSigninHelperIncognitoTest, |
| 247 ShowInfoBarUIThreadIncognito); | 246 ShowInfoBarUIThreadIncognito); |
| 248 FRIEND_TEST_ALL_PREFIXES(OneClickSigninHelperTest, | 247 FRIEND_TEST_ALL_PREFIXES(OneClickSigninHelperTest, |
| 249 SigninFromWebstoreWithConfigSyncfirst); | 248 SigninFromWebstoreWithConfigSyncfirst); |
| 250 FRIEND_TEST_ALL_PREFIXES(OneClickSigninHelperTest, | 249 FRIEND_TEST_ALL_PREFIXES(OneClickSigninHelperTest, |
| 251 ShowSigninBubbleAfterSigninComplete); | 250 ShowSigninBubbleAfterSigninComplete); |
| 252 FRIEND_TEST_ALL_PREFIXES(OneClickSigninHelperTest, SigninCancelled); | 251 FRIEND_TEST_ALL_PREFIXES(OneClickSigninHelperTest, SigninCancelled); |
| 253 FRIEND_TEST_ALL_PREFIXES(OneClickSigninHelperTest, SigninFailed); | 252 FRIEND_TEST_ALL_PREFIXES(OneClickSigninHelperTest, SigninFailed); |
| 254 FRIEND_TEST_ALL_PREFIXES(OneClickSigninHelperTest, | 253 FRIEND_TEST_ALL_PREFIXES(OneClickSigninHelperTest, |
| 255 CleanTransientStateOnNavigate); | 254 CleanTransientStateOnNavigate); |
| 255 // TODO(isherman): Move this test? |
| 256 FRIEND_TEST_ALL_PREFIXES(OneClickSigninHelperTest, | 256 FRIEND_TEST_ALL_PREFIXES(OneClickSigninHelperTest, |
| 257 RemoveObserverFromProfileSyncService); | 257 RemoveObserverFromProfileSyncService); |
| 258 FRIEND_TEST_ALL_PREFIXES(OneClickSigninHelperIOTest, CanOfferOnIOThread); | 258 FRIEND_TEST_ALL_PREFIXES(OneClickSigninHelperIOTest, CanOfferOnIOThread); |
| 259 FRIEND_TEST_ALL_PREFIXES(OneClickSigninHelperIOTest, | 259 FRIEND_TEST_ALL_PREFIXES(OneClickSigninHelperIOTest, |
| 260 CanOfferOnIOThreadIncognito); | 260 CanOfferOnIOThreadIncognito); |
| 261 FRIEND_TEST_ALL_PREFIXES(OneClickSigninHelperIOTest, | 261 FRIEND_TEST_ALL_PREFIXES(OneClickSigninHelperIOTest, |
| 262 CanOfferOnIOThreadNoIOData); | 262 CanOfferOnIOThreadNoIOData); |
| 263 FRIEND_TEST_ALL_PREFIXES(OneClickSigninHelperIOTest, | 263 FRIEND_TEST_ALL_PREFIXES(OneClickSigninHelperIOTest, |
| 264 CanOfferOnIOThreadBadURL); | 264 CanOfferOnIOThreadBadURL); |
| 265 FRIEND_TEST_ALL_PREFIXES(OneClickSigninHelperIOTest, | 265 FRIEND_TEST_ALL_PREFIXES(OneClickSigninHelperIOTest, |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 335 | 335 |
| 336 // content::WebContentsObserver overrides. | 336 // content::WebContentsObserver overrides. |
| 337 virtual void DidStartNavigationToPendingEntry( | 337 virtual void DidStartNavigationToPendingEntry( |
| 338 const GURL& url, | 338 const GURL& url, |
| 339 content::NavigationController::ReloadType reload_type) OVERRIDE; | 339 content::NavigationController::ReloadType reload_type) OVERRIDE; |
| 340 virtual void DidNavigateMainFrame( | 340 virtual void DidNavigateMainFrame( |
| 341 const content::LoadCommittedDetails& details, | 341 const content::LoadCommittedDetails& details, |
| 342 const content::FrameNavigateParams& params) OVERRIDE; | 342 const content::FrameNavigateParams& params) OVERRIDE; |
| 343 virtual void DidStopLoading( | 343 virtual void DidStopLoading( |
| 344 content::RenderViewHost* render_view_host) OVERRIDE; | 344 content::RenderViewHost* render_view_host) OVERRIDE; |
| 345 virtual void WebContentsDestroyed(content::WebContents* contents) OVERRIDE; | |
| 346 | |
| 347 // ProfileSyncServiceObserver. | |
| 348 virtual void OnStateChanged() OVERRIDE; | |
| 349 | 345 |
| 350 OneClickSigninSyncStarter::Callback CreateSyncStarterCallback(); | 346 OneClickSigninSyncStarter::Callback CreateSyncStarterCallback(); |
| 351 | 347 |
| 352 // Callback invoked when OneClickSigninSyncStarter completes sync setup. | 348 // Callback invoked when OneClickSigninSyncStarter completes sync setup. |
| 353 void SyncSetupCompletedCallback( | 349 void SyncSetupCompletedCallback( |
| 354 OneClickSigninSyncStarter::SyncSetupResult result); | 350 OneClickSigninSyncStarter::SyncSetupResult result); |
| 355 | 351 |
| 356 // Tracks if we are in the process of showing the signin or one click | 352 // Tracks if we are in the process of showing the signin or one click |
| 357 // interstitial page. It's set to true the first time we load one of those | 353 // interstitial page. It's set to true the first time we load one of those |
| 358 // pages and set to false when transient state is cleaned. | 354 // pages and set to false when transient state is cleaned. |
| (...skipping 30 matching lines...) Expand all Loading... |
| 389 | 385 |
| 390 // Allows unittest to avoid starting sync for real. | 386 // Allows unittest to avoid starting sync for real. |
| 391 bool do_not_start_sync_for_testing_; | 387 bool do_not_start_sync_for_testing_; |
| 392 | 388 |
| 393 base::WeakPtrFactory<OneClickSigninHelper> weak_pointer_factory_; | 389 base::WeakPtrFactory<OneClickSigninHelper> weak_pointer_factory_; |
| 394 | 390 |
| 395 DISALLOW_COPY_AND_ASSIGN(OneClickSigninHelper); | 391 DISALLOW_COPY_AND_ASSIGN(OneClickSigninHelper); |
| 396 }; | 392 }; |
| 397 | 393 |
| 398 #endif // CHROME_BROWSER_UI_SYNC_ONE_CLICK_SIGNIN_HELPER_H_ | 394 #endif // CHROME_BROWSER_UI_SYNC_ONE_CLICK_SIGNIN_HELPER_H_ |
| OLD | NEW |