| 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_WEBUI_SYNC_SETUP_HANDLER_H_ | 5 #ifndef CHROME_BROWSER_UI_WEBUI_SYNC_SETUP_HANDLER_H_ |
| 6 #define CHROME_BROWSER_UI_WEBUI_SYNC_SETUP_HANDLER_H_ | 6 #define CHROME_BROWSER_UI_WEBUI_SYNC_SETUP_HANDLER_H_ |
| 7 | 7 |
| 8 #include "base/gtest_prod_util.h" | 8 #include "base/gtest_prod_util.h" |
| 9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "base/timer.h" | 10 #include "base/timer.h" |
| 11 #include "chrome/browser/signin/signin_tracker.h" | 11 #include "chrome/browser/signin/signin_tracker.h" |
| 12 #include "chrome/browser/ui/webui/options/options_ui.h" | 12 #include "chrome/browser/ui/webui/options/options_ui.h" |
| 13 #include "chrome/browser/ui/webui/signin/login_ui_service.h" | 13 #include "chrome/browser/ui/webui/signin/login_ui_service.h" |
| 14 #include "content/public/browser/web_contents_observer.h" |
| 14 | 15 |
| 15 class LoginUIService; | 16 class LoginUIService; |
| 16 class ProfileManager; | 17 class ProfileManager; |
| 17 class ProfileSyncService; | 18 class ProfileSyncService; |
| 18 class SigninManager; | 19 class SigninManager; |
| 19 | 20 |
| 21 namespace content { |
| 22 class WebContents; |
| 23 } |
| 24 |
| 20 class SyncSetupHandler : public options::OptionsPageUIHandler, | 25 class SyncSetupHandler : public options::OptionsPageUIHandler, |
| 21 public SigninTracker::Observer, | 26 public SigninTracker::Observer, |
| 22 public LoginUIService::LoginUI { | 27 public LoginUIService::LoginUI, |
| 28 public content::WebContentsObserver { |
| 23 public: | 29 public: |
| 24 // Constructs a new SyncSetupHandler. |profile_manager| may be NULL. | 30 // Constructs a new SyncSetupHandler. |profile_manager| may be NULL. |
| 25 explicit SyncSetupHandler(ProfileManager* profile_manager); | 31 explicit SyncSetupHandler(ProfileManager* profile_manager); |
| 26 virtual ~SyncSetupHandler(); | 32 virtual ~SyncSetupHandler(); |
| 27 | 33 |
| 28 // OptionsPageUIHandler implementation. | 34 // OptionsPageUIHandler implementation. |
| 29 virtual void GetLocalizedValues(base::DictionaryValue* localized_strings) | 35 virtual void GetLocalizedValues(base::DictionaryValue* localized_strings) |
| 30 OVERRIDE; | 36 OVERRIDE; |
| 31 virtual void RegisterMessages() OVERRIDE; | 37 virtual void RegisterMessages() OVERRIDE; |
| 32 | 38 |
| 33 // SigninTracker::Observer implementation. | 39 // SigninTracker::Observer implementation. |
| 34 virtual void GaiaCredentialsValid() OVERRIDE; | 40 virtual void GaiaCredentialsValid() OVERRIDE; |
| 35 virtual void SigninFailed(const GoogleServiceAuthError& error) OVERRIDE; | 41 virtual void SigninFailed(const GoogleServiceAuthError& error) OVERRIDE; |
| 36 virtual void SigninSuccess() OVERRIDE; | 42 virtual void SigninSuccess() OVERRIDE; |
| 37 | 43 |
| 38 // LoginUIService::LoginUI implementation. | 44 // LoginUIService::LoginUI implementation. |
| 39 virtual void FocusUI() OVERRIDE; | 45 virtual void FocusUI() OVERRIDE; |
| 40 virtual void CloseUI() OVERRIDE; | 46 virtual void CloseUI() OVERRIDE; |
| 41 | 47 |
| 48 // content::WebContentsObserver implementation. |
| 49 virtual void WebContentsDestroyed( |
| 50 content::WebContents* web_contents) OVERRIDE; |
| 51 |
| 42 static void GetStaticLocalizedValues( | 52 static void GetStaticLocalizedValues( |
| 43 base::DictionaryValue* localized_strings, | 53 base::DictionaryValue* localized_strings, |
| 44 content::WebUI* web_ui); | 54 content::WebUI* web_ui); |
| 45 | 55 |
| 46 // Initializes the sync setup flow and shows the setup UI. If |force_login| is | 56 // Initializes the sync setup flow and shows the setup UI. If |force_login| is |
| 47 // true, then the user is forced through the login flow even if they are | 57 // true, then the user is forced through the login flow even if they are |
| 48 // already signed in (useful for when it is necessary to force the user to | 58 // already signed in (useful for when it is necessary to force the user to |
| 49 // re-enter credentials so new tokens can be fetched). | 59 // re-enter credentials so new tokens can be fetched). |
| 50 void OpenSyncSetup(bool force_login); | 60 void OpenSyncSetup(bool force_login); |
| 51 | 61 |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 157 const std::string& password, | 167 const std::string& password, |
| 158 const std::string& captcha, | 168 const std::string& captcha, |
| 159 const std::string& access_code); | 169 const std::string& access_code); |
| 160 | 170 |
| 161 // If a wizard already exists, focus it and return true. | 171 // If a wizard already exists, focus it and return true. |
| 162 bool FocusExistingWizardIfPresent(); | 172 bool FocusExistingWizardIfPresent(); |
| 163 | 173 |
| 164 // Invokes the javascript call to close the setup overlay. | 174 // Invokes the javascript call to close the setup overlay. |
| 165 void CloseOverlay(); | 175 void CloseOverlay(); |
| 166 | 176 |
| 177 // When using web-flow, closes the Gaia used to collection user credentials. |
| 178 void CloseGaiaSigninPage(); |
| 179 |
| 167 // Returns true if the given login data is valid, false otherwise. If the | 180 // Returns true if the given login data is valid, false otherwise. If the |
| 168 // login data is not valid then on return |error_message| will be set to a | 181 // login data is not valid then on return |error_message| will be set to a |
| 169 // localized error message. Note, |error_message| must not be NULL. | 182 // localized error message. Note, |error_message| must not be NULL. |
| 170 bool IsLoginAuthDataValid(const std::string& username, | 183 bool IsLoginAuthDataValid(const std::string& username, |
| 171 string16* error_message); | 184 string16* error_message); |
| 172 | 185 |
| 173 // Returns the SigninManager for the parent profile. | 186 // Returns the SigninManager for the parent profile. |
| 174 SigninManager* GetSignin() const; | 187 SigninManager* GetSignin() const; |
| 175 | 188 |
| 176 // The SigninTracker object used to determine when the user has fully signed | 189 // The SigninTracker object used to determine when the user has fully signed |
| (...skipping 17 matching lines...) Expand all Loading... |
| 194 GoogleServiceAuthError last_signin_error_; | 207 GoogleServiceAuthError last_signin_error_; |
| 195 | 208 |
| 196 // When setup starts with login UI, retry login if signing in failed. | 209 // When setup starts with login UI, retry login if signing in failed. |
| 197 // When setup starts without login UI, do not retry login and fail. | 210 // When setup starts without login UI, do not retry login and fail. |
| 198 bool retry_on_signin_failure_; | 211 bool retry_on_signin_failure_; |
| 199 | 212 |
| 200 // The OneShotTimer object used to timeout of starting the sync backend | 213 // The OneShotTimer object used to timeout of starting the sync backend |
| 201 // service. | 214 // service. |
| 202 scoped_ptr<base::OneShotTimer<SyncSetupHandler> > backend_start_timer_; | 215 scoped_ptr<base::OneShotTimer<SyncSetupHandler> > backend_start_timer_; |
| 203 | 216 |
| 217 // When using web-flow, pointer to the tab that holds the Gaia sign in page. |
| 218 content::WebContents* active_gaia_signin_tab_; |
| 219 |
| 220 // When using web-flow, this member holds the SyncSetupHandler instance |
| 221 // that initiated the Gaia sign in. |
| 222 static SyncSetupHandler* active_sync_setup_handler_; |
| 223 |
| 204 DISALLOW_COPY_AND_ASSIGN(SyncSetupHandler); | 224 DISALLOW_COPY_AND_ASSIGN(SyncSetupHandler); |
| 205 }; | 225 }; |
| 206 | 226 |
| 207 #endif // CHROME_BROWSER_UI_WEBUI_SYNC_SETUP_HANDLER_H_ | 227 #endif // CHROME_BROWSER_UI_WEBUI_SYNC_SETUP_HANDLER_H_ |
| OLD | NEW |