| 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/signin/signin_promo.h" | 15 #include "chrome/browser/signin/signin_promo.h" |
| 16 #include "chrome/browser/signin/signin_tracker.h" | 16 #include "chrome/browser/signin/signin_tracker.h" |
| 17 #include "chrome/browser/ui/browser_list_observer.h" | 17 #include "chrome/browser/ui/browser_list_observer.h" |
| 18 #include "chrome/browser/ui/host_desktop.h" | 18 #include "chrome/browser/ui/host_desktop.h" |
| 19 #include "chrome/browser/ui/sync/profile_signin_confirmation_helper.h" | 19 #include "chrome/browser/ui/sync/profile_signin_confirmation_helper.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 |
| 25 namespace content { |
| 26 class WebContents; |
| 27 } // namespace content |
| 28 |
| 24 namespace policy { | 29 namespace policy { |
| 25 class CloudPolicyClient; | 30 class CloudPolicyClient; |
| 26 } | 31 } |
| 27 | 32 |
| 28 // Waits for successful singin notification from the signin manager and then | 33 // Waits for successful singin notification from the signin manager and then |
| 29 // starts the sync machine. Instances of this class delete themselves once | 34 // starts the sync machine. Instances of this class delete themselves once |
| 30 // the job is done. | 35 // the job is done. |
| 31 class OneClickSigninSyncStarter : public SigninTracker::Observer, | 36 class OneClickSigninSyncStarter : public SigninTracker::Observer, |
| 32 public chrome::BrowserListObserver { | 37 public chrome::BrowserListObserver, |
| 38 public content::WebContentsObserver { |
| 33 public: | 39 public: |
| 34 enum StartSyncMode { | 40 enum StartSyncMode { |
| 35 // Starts the process of signing the user in with the SigninManager, and | 41 // Starts the process of signing the user in with the SigninManager, and |
| 36 // once completed automatically starts sync with all data types enabled. | 42 // once completed automatically starts sync with all data types enabled. |
| 37 SYNC_WITH_DEFAULT_SETTINGS, | 43 SYNC_WITH_DEFAULT_SETTINGS, |
| 38 | 44 |
| 39 // Starts the process of signing the user in with the SigninManager, and | 45 // Starts the process of signing the user in with the SigninManager, and |
| 40 // once completed redirects the user to the settings page to allow them | 46 // once completed redirects the user to the settings page to allow them |
| 41 // to configure which data types to sync before sync is enabled. | 47 // to configure which data types to sync before sync is enabled. |
| 42 CONFIGURE_SYNC_FIRST, | 48 CONFIGURE_SYNC_FIRST, |
| (...skipping 25 matching lines...) Expand all Loading... |
| 68 SYNC_SETUP_SUCCESS, | 74 SYNC_SETUP_SUCCESS, |
| 69 SYNC_SETUP_FAILURE | 75 SYNC_SETUP_FAILURE |
| 70 }; | 76 }; |
| 71 | 77 |
| 72 typedef base::Callback<void(SyncSetupResult)> Callback; | 78 typedef base::Callback<void(SyncSetupResult)> Callback; |
| 73 | 79 |
| 74 // |profile| must not be NULL, however |browser| can be. When using the | 80 // |profile| must not be NULL, however |browser| can be. When using the |
| 75 // OneClickSigninSyncStarter from a browser, provide both. | 81 // OneClickSigninSyncStarter from a browser, provide both. |
| 76 // If |display_confirmation| is true, the user will be prompted to confirm the | 82 // If |display_confirmation| is true, the user will be prompted to confirm the |
| 77 // signin before signin completes. | 83 // signin before signin completes. |
| 84 // |web_contents| is used to show the sync setup page, if necessary. If NULL, |
| 85 // the sync setup page will be loaded in either a new tab or a tab that is |
| 86 // already showing it. |
| 78 // |callback| is always executed before OneClickSigninSyncStarter is deleted. | 87 // |callback| is always executed before OneClickSigninSyncStarter is deleted. |
| 79 // It can be empty. | 88 // It can be empty. |
| 80 OneClickSigninSyncStarter(Profile* profile, | 89 OneClickSigninSyncStarter(Profile* profile, |
| 81 Browser* browser, | 90 Browser* browser, |
| 82 const std::string& session_index, | 91 const std::string& session_index, |
| 83 const std::string& email, | 92 const std::string& email, |
| 84 const std::string& password, | 93 const std::string& password, |
| 85 StartSyncMode start_mode, | 94 StartSyncMode start_mode, |
| 86 bool force_same_tab_navigation, | 95 content::WebContents* web_contents, |
| 87 ConfirmationRequired display_confirmation, | 96 ConfirmationRequired display_confirmation, |
| 88 signin::Source source, | 97 signin::Source source, |
| 89 Callback callback); | 98 Callback callback); |
| 90 | 99 |
| 91 // chrome::BrowserListObserver override. | 100 // chrome::BrowserListObserver override. |
| 92 virtual void OnBrowserRemoved(Browser* browser) OVERRIDE; | 101 virtual void OnBrowserRemoved(Browser* browser) OVERRIDE; |
| 93 | 102 |
| 94 private: | 103 private: |
| 95 friend class OneClickSigninSyncStarterTest; | 104 friend class OneClickSigninSyncStarterTest; |
| 96 FRIEND_TEST_ALL_PREFIXES(OneClickSigninSyncStarterTest, | 105 FRIEND_TEST_ALL_PREFIXES(OneClickSigninSyncStarterTest, |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 208 // CloudPolicyClient reference we keep while determining whether to create | 217 // CloudPolicyClient reference we keep while determining whether to create |
| 209 // a new profile for an enterprise user or not. | 218 // a new profile for an enterprise user or not. |
| 210 scoped_ptr<policy::CloudPolicyClient> policy_client_; | 219 scoped_ptr<policy::CloudPolicyClient> policy_client_; |
| 211 #endif | 220 #endif |
| 212 | 221 |
| 213 DISALLOW_COPY_AND_ASSIGN(OneClickSigninSyncStarter); | 222 DISALLOW_COPY_AND_ASSIGN(OneClickSigninSyncStarter); |
| 214 }; | 223 }; |
| 215 | 224 |
| 216 | 225 |
| 217 #endif // CHROME_BROWSER_UI_SYNC_ONE_CLICK_SIGNIN_SYNC_STARTER_H_ | 226 #endif // CHROME_BROWSER_UI_SYNC_ONE_CLICK_SIGNIN_SYNC_STARTER_H_ |
| OLD | NEW |