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/macros.h" | 12 #include "base/macros.h" |
13 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
14 #include "base/memory/weak_ptr.h" | 14 #include "base/memory/weak_ptr.h" |
15 #include "chrome/browser/profiles/profile.h" | 15 #include "chrome/browser/profiles/profile.h" |
16 #include "chrome/browser/ui/browser_list_observer.h" | 16 #include "chrome/browser/ui/browser_list_observer.h" |
17 #include "chrome/browser/ui/host_desktop.h" | |
18 #include "chrome/browser/ui/sync/profile_signin_confirmation_helper.h" | 17 #include "chrome/browser/ui/sync/profile_signin_confirmation_helper.h" |
19 #include "chrome/browser/ui/webui/signin/login_ui_service.h" | 18 #include "chrome/browser/ui/webui/signin/login_ui_service.h" |
20 #include "components/signin/core/browser/signin_tracker.h" | 19 #include "components/signin/core/browser/signin_tracker.h" |
21 #include "content/public/browser/web_contents_observer.h" | 20 #include "content/public/browser/web_contents_observer.h" |
22 | 21 |
23 class Browser; | 22 class Browser; |
24 class ProfileSyncService; | 23 class ProfileSyncService; |
25 | 24 |
26 namespace content { | 25 namespace content { |
27 class WebContents; | 26 class WebContents; |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
105 const GURL& current_url, | 104 const GURL& current_url, |
106 const GURL& continue_url, | 105 const GURL& continue_url, |
107 Callback callback); | 106 Callback callback); |
108 | 107 |
109 // chrome::BrowserListObserver override. | 108 // chrome::BrowserListObserver override. |
110 void OnBrowserRemoved(Browser* browser) override; | 109 void OnBrowserRemoved(Browser* browser) override; |
111 | 110 |
112 // If the |browser| argument is non-null, returns the pointer directly. | 111 // If the |browser| argument is non-null, returns the pointer directly. |
113 // Otherwise creates a new browser for the given profile on the given | 112 // Otherwise creates a new browser for the given profile on the given |
114 // desktop, adds an empty tab and makes sure the browser is visible. | 113 // desktop, adds an empty tab and makes sure the browser is visible. |
115 static Browser* EnsureBrowser(Browser* browser, | 114 static Browser* EnsureBrowser(Browser* browser, Profile* profile); |
116 Profile* profile, | |
117 chrome::HostDesktopType desktop_type); | |
118 | 115 |
119 private: | 116 private: |
120 friend class OneClickSigninSyncStarterTest; | 117 friend class OneClickSigninSyncStarterTest; |
121 FRIEND_TEST_ALL_PREFIXES(OneClickSigninSyncStarterTest, CallbackSigninFailed); | 118 FRIEND_TEST_ALL_PREFIXES(OneClickSigninSyncStarterTest, CallbackSigninFailed); |
122 FRIEND_TEST_ALL_PREFIXES(OneClickSigninSyncStarterTest, CallbackNull); | 119 FRIEND_TEST_ALL_PREFIXES(OneClickSigninSyncStarterTest, CallbackNull); |
123 FRIEND_TEST_ALL_PREFIXES(OneClickSigninSyncStarterTest, LoadContinueUrl); | 120 FRIEND_TEST_ALL_PREFIXES(OneClickSigninSyncStarterTest, LoadContinueUrl); |
124 | 121 |
125 ~OneClickSigninSyncStarter() override; | 122 ~OneClickSigninSyncStarter() override; |
126 | 123 |
127 // Initializes the internals of the OneClickSigninSyncStarter object. Can also | 124 // Initializes the internals of the OneClickSigninSyncStarter object. Can also |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
166 // Called to create a new profile, which is then signed in with the | 163 // Called to create a new profile, which is then signed in with the |
167 // in-progress auth credentials currently stored in this object. | 164 // in-progress auth credentials currently stored in this object. |
168 void CreateNewSignedInProfile(); | 165 void CreateNewSignedInProfile(); |
169 | 166 |
170 // Helper function that loads policy with the cached |dm_token_| and | 167 // Helper function that loads policy with the cached |dm_token_| and |
171 // |client_id|, then completes the signin process. | 168 // |client_id|, then completes the signin process. |
172 void LoadPolicyWithCachedCredentials(); | 169 void LoadPolicyWithCachedCredentials(); |
173 | 170 |
174 // Callback invoked once a profile is created, so we can complete the | 171 // Callback invoked once a profile is created, so we can complete the |
175 // credentials transfer, load policy, and open the first window. | 172 // credentials transfer, load policy, and open the first window. |
176 void CompleteInitForNewProfile(chrome::HostDesktopType desktop_type, | 173 void CompleteInitForNewProfile(Profile* profile, |
177 Profile* profile, | |
178 Profile::CreateStatus status); | 174 Profile::CreateStatus status); |
179 | 175 |
180 #endif // defined(ENABLE_CONFIGURATION_POLICY) | 176 #endif // defined(ENABLE_CONFIGURATION_POLICY) |
181 | 177 |
182 // Cancels the in-progress signin for this profile. | 178 // Cancels the in-progress signin for this profile. |
183 void CancelSigninAndDelete(); | 179 void CancelSigninAndDelete(); |
184 | 180 |
185 // Callback invoked to check whether the user needs policy or if a | 181 // 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). | 182 // confirmation is required (in which case we have to prompt the user first). |
187 void ConfirmSignin(const std::string& oauth_token); | 183 void ConfirmSignin(const std::string& oauth_token); |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
221 | 217 |
222 void DisplayModalSyncConfirmationWindow(); | 218 void DisplayModalSyncConfirmationWindow(); |
223 | 219 |
224 // Loads the |continue_url_| in the current tab. | 220 // Loads the |continue_url_| in the current tab. |
225 void LoadContinueUrl(); | 221 void LoadContinueUrl(); |
226 | 222 |
227 Profile* profile_; | 223 Profile* profile_; |
228 Browser* browser_; | 224 Browser* browser_; |
229 scoped_ptr<SigninTracker> signin_tracker_; | 225 scoped_ptr<SigninTracker> signin_tracker_; |
230 StartSyncMode start_mode_; | 226 StartSyncMode start_mode_; |
231 chrome::HostDesktopType desktop_type_; | |
232 ConfirmationRequired confirmation_required_; | 227 ConfirmationRequired confirmation_required_; |
233 GURL current_url_; | 228 GURL current_url_; |
234 GURL continue_url_; | 229 GURL continue_url_; |
235 | 230 |
236 // Callback executed when sync setup succeeds or fails. | 231 // Callback executed when sync setup succeeds or fails. |
237 Callback sync_setup_completed_callback_; | 232 Callback sync_setup_completed_callback_; |
238 | 233 |
239 #if defined(ENABLE_CONFIGURATION_POLICY) | 234 #if defined(ENABLE_CONFIGURATION_POLICY) |
240 // Policy credentials we keep while determining whether to create | 235 // Policy credentials we keep while determining whether to create |
241 // a new profile for an enterprise user or not. | 236 // a new profile for an enterprise user or not. |
242 std::string dm_token_; | 237 std::string dm_token_; |
243 std::string client_id_; | 238 std::string client_id_; |
244 #endif | 239 #endif |
245 | 240 |
246 base::WeakPtrFactory<OneClickSigninSyncStarter> weak_pointer_factory_; | 241 base::WeakPtrFactory<OneClickSigninSyncStarter> weak_pointer_factory_; |
247 | 242 |
248 DISALLOW_COPY_AND_ASSIGN(OneClickSigninSyncStarter); | 243 DISALLOW_COPY_AND_ASSIGN(OneClickSigninSyncStarter); |
249 }; | 244 }; |
250 | 245 |
251 | 246 |
252 #endif // CHROME_BROWSER_UI_SYNC_ONE_CLICK_SIGNIN_SYNC_STARTER_H_ | 247 #endif // CHROME_BROWSER_UI_SYNC_ONE_CLICK_SIGNIN_SYNC_STARTER_H_ |
OLD | NEW |