OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 #include "chrome/browser/ui/webui/signin/inline_login_handler_impl.h" | 5 #include "chrome/browser/ui/webui/signin/inline_login_handler_impl.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
11 #include "base/strings/string_util.h" | 11 #include "base/strings/string_util.h" |
12 #include "base/strings/utf_string_conversions.h" | 12 #include "base/strings/utf_string_conversions.h" |
13 #include "base/values.h" | 13 #include "base/values.h" |
14 #include "chrome/browser/profiles/profile.h" | 14 #include "chrome/browser/profiles/profile.h" |
15 #include "chrome/browser/signin/about_signin_internals_factory.h" | 15 #include "chrome/browser/signin/about_signin_internals_factory.h" |
16 #include "chrome/browser/signin/chrome_signin_client_factory.h" | 16 #include "chrome/browser/signin/chrome_signin_client_factory.h" |
17 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" | 17 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" |
18 #include "chrome/browser/signin/signin_manager_factory.h" | 18 #include "chrome/browser/signin/signin_manager_factory.h" |
19 #include "chrome/browser/sync/profile_sync_service.h" | 19 #include "chrome/browser/sync/profile_sync_service.h" |
20 #include "chrome/browser/sync/profile_sync_service_factory.h" | 20 #include "chrome/browser/sync/profile_sync_service_factory.h" |
21 #include "chrome/browser/ui/browser_finder.h" | 21 #include "chrome/browser/ui/browser_finder.h" |
22 #include "chrome/browser/ui/browser_window.h" | 22 #include "chrome/browser/ui/browser_window.h" |
23 #include "chrome/browser/ui/sync/one_click_signin_helper.h" | 23 #include "chrome/browser/ui/sync/one_click_signin_helper.h" |
24 #include "chrome/browser/ui/sync/one_click_signin_histogram.h" | 24 #include "chrome/browser/ui/sync/one_click_signin_histogram.h" |
25 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 25 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 26 #include "chrome/browser/ui/webui/signin/inline_login_ui.h" |
26 #include "chrome/common/url_constants.h" | 27 #include "chrome/common/url_constants.h" |
27 #include "components/signin/core/browser/about_signin_internals.h" | 28 #include "components/signin/core/browser/about_signin_internals.h" |
28 #include "components/signin/core/browser/profile_oauth2_token_service.h" | 29 #include "components/signin/core/browser/profile_oauth2_token_service.h" |
29 #include "components/signin/core/browser/signin_error_controller.h" | 30 #include "components/signin/core/browser/signin_error_controller.h" |
30 #include "components/signin/core/browser/signin_oauth_helper.h" | 31 #include "components/signin/core/browser/signin_oauth_helper.h" |
31 #include "components/signin/core/common/profile_management_switches.h" | 32 #include "components/signin/core/common/profile_management_switches.h" |
32 #include "content/public/browser/storage_partition.h" | 33 #include "content/public/browser/storage_partition.h" |
33 #include "content/public/browser/web_ui.h" | 34 #include "content/public/browser/web_ui.h" |
34 #include "google_apis/gaia/gaia_auth_fetcher.h" | 35 #include "google_apis/gaia/gaia_auth_fetcher.h" |
35 #include "google_apis/gaia/gaia_auth_util.h" | 36 #include "google_apis/gaia/gaia_auth_util.h" |
36 #include "google_apis/gaia/gaia_constants.h" | 37 #include "google_apis/gaia/gaia_constants.h" |
37 #include "google_apis/gaia/gaia_urls.h" | 38 #include "google_apis/gaia/gaia_urls.h" |
38 #include "net/base/url_util.h" | 39 #include "net/base/url_util.h" |
39 | 40 |
40 namespace { | 41 namespace { |
41 | 42 |
42 class InlineSigninHelper : public SigninOAuthHelper::Consumer { | 43 class InlineSigninHelper : public SigninOAuthHelper::Consumer { |
43 public: | 44 public: |
44 InlineSigninHelper( | 45 InlineSigninHelper( |
45 base::WeakPtr<InlineLoginHandlerImpl> handler, | 46 base::WeakPtr<InlineLoginHandlerImpl> handler, |
46 net::URLRequestContextGetter* getter, | 47 net::URLRequestContextGetter* getter, |
47 Profile* profile, | 48 Profile* profile, |
48 const GURL& current_url, | 49 const GURL& current_url, |
49 const std::string& email, | 50 const std::string& email, |
50 const std::string& password, | 51 const std::string& password, |
51 const std::string& session_index, | 52 const std::string& session_index, |
52 const std::string& signin_scoped_device_id, | 53 const std::string& signin_scoped_device_id, |
53 bool choose_what_to_sync); | 54 bool choose_what_to_sync, |
| 55 bool confirm_untrusted_signin); |
54 | 56 |
55 private: | 57 private: |
56 // Overriden from SigninOAuthHelper::Consumer. | 58 // Overriden from SigninOAuthHelper::Consumer. |
57 virtual void OnSigninOAuthInformationAvailable( | 59 virtual void OnSigninOAuthInformationAvailable( |
58 const std::string& email, | 60 const std::string& email, |
59 const std::string& display_email, | 61 const std::string& display_email, |
60 const std::string& refresh_token) OVERRIDE; | 62 const std::string& refresh_token) OVERRIDE; |
61 virtual void OnSigninOAuthInformationFailure( | 63 virtual void OnSigninOAuthInformationFailure( |
62 const GoogleServiceAuthError& error) OVERRIDE; | 64 const GoogleServiceAuthError& error) OVERRIDE; |
63 | 65 |
64 SigninOAuthHelper signin_oauth_helper_; | 66 SigninOAuthHelper signin_oauth_helper_; |
65 base::WeakPtr<InlineLoginHandlerImpl> handler_; | 67 base::WeakPtr<InlineLoginHandlerImpl> handler_; |
66 Profile* profile_; | 68 Profile* profile_; |
67 GURL current_url_; | 69 GURL current_url_; |
68 std::string email_; | 70 std::string email_; |
69 std::string password_; | 71 std::string password_; |
70 std::string session_index_; | 72 std::string session_index_; |
71 bool choose_what_to_sync_; | 73 bool choose_what_to_sync_; |
| 74 bool confirm_untrusted_signin_; |
72 | 75 |
73 DISALLOW_COPY_AND_ASSIGN(InlineSigninHelper); | 76 DISALLOW_COPY_AND_ASSIGN(InlineSigninHelper); |
74 }; | 77 }; |
75 | 78 |
76 InlineSigninHelper::InlineSigninHelper( | 79 InlineSigninHelper::InlineSigninHelper( |
77 base::WeakPtr<InlineLoginHandlerImpl> handler, | 80 base::WeakPtr<InlineLoginHandlerImpl> handler, |
78 net::URLRequestContextGetter* getter, | 81 net::URLRequestContextGetter* getter, |
79 Profile* profile, | 82 Profile* profile, |
80 const GURL& current_url, | 83 const GURL& current_url, |
81 const std::string& email, | 84 const std::string& email, |
82 const std::string& password, | 85 const std::string& password, |
83 const std::string& session_index, | 86 const std::string& session_index, |
84 const std::string& signin_scoped_device_id, | 87 const std::string& signin_scoped_device_id, |
85 bool choose_what_to_sync) | 88 bool choose_what_to_sync, |
| 89 bool confirm_untrusted_signin) |
86 : signin_oauth_helper_(getter, session_index, signin_scoped_device_id, | 90 : signin_oauth_helper_(getter, session_index, signin_scoped_device_id, |
87 this), | 91 this), |
88 handler_(handler), | 92 handler_(handler), |
89 profile_(profile), | 93 profile_(profile), |
90 current_url_(current_url), | 94 current_url_(current_url), |
91 email_(email), | 95 email_(email), |
92 password_(password), | 96 password_(password), |
93 choose_what_to_sync_(choose_what_to_sync) { | 97 session_index_(session_index), |
| 98 choose_what_to_sync_(choose_what_to_sync), |
| 99 confirm_untrusted_signin_(confirm_untrusted_signin) { |
94 DCHECK(profile_); | 100 DCHECK(profile_); |
95 DCHECK(!email_.empty()); | 101 DCHECK(!email_.empty()); |
96 } | 102 } |
97 | 103 |
98 void InlineSigninHelper::OnSigninOAuthInformationAvailable( | 104 void InlineSigninHelper::OnSigninOAuthInformationAvailable( |
99 const std::string& email, | 105 const std::string& email, |
100 const std::string& display_email, | 106 const std::string& display_email, |
101 const std::string& refresh_token) { | 107 const std::string& refresh_token) { |
102 content::WebContents* contents = NULL; | 108 content::WebContents* contents = NULL; |
103 Browser* browser = NULL; | 109 Browser* browser = NULL; |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
145 sync_service->HasSyncSetupCompleted(); | 151 sync_service->HasSyncSetupCompleted(); |
146 start_mode = show_settings_without_configure ? | 152 start_mode = show_settings_without_configure ? |
147 OneClickSigninSyncStarter::SHOW_SETTINGS_WITHOUT_CONFIGURE : | 153 OneClickSigninSyncStarter::SHOW_SETTINGS_WITHOUT_CONFIGURE : |
148 OneClickSigninSyncStarter::CONFIGURE_SYNC_FIRST; | 154 OneClickSigninSyncStarter::CONFIGURE_SYNC_FIRST; |
149 } else { | 155 } else { |
150 start_mode = show_inline_confirmation_for_sync ? | 156 start_mode = show_inline_confirmation_for_sync ? |
151 OneClickSigninSyncStarter::CONFIRM_SYNC_SETTINGS_FIRST : | 157 OneClickSigninSyncStarter::CONFIRM_SYNC_SETTINGS_FIRST : |
152 OneClickSigninSyncStarter::SYNC_WITH_DEFAULT_SETTINGS; | 158 OneClickSigninSyncStarter::SYNC_WITH_DEFAULT_SETTINGS; |
153 } | 159 } |
154 | 160 |
155 OneClickSigninSyncStarter::ConfirmationRequired confirmation_required = | 161 OneClickSigninSyncStarter::ConfirmationRequired confirmation_required; |
156 source == signin::SOURCE_SETTINGS || | 162 if (confirm_untrusted_signin_) { |
157 source == signin::SOURCE_WEBSTORE_INSTALL || | 163 confirmation_required = |
158 choose_what_to_sync_ || | 164 OneClickSigninSyncStarter::CONFIRM_UNTRUSTED_SIGNIN; |
159 show_inline_confirmation_for_sync ? | 165 } else { |
160 OneClickSigninSyncStarter::NO_CONFIRMATION : | 166 confirmation_required = |
161 OneClickSigninSyncStarter::CONFIRM_AFTER_SIGNIN; | 167 source == signin::SOURCE_SETTINGS || |
| 168 source == signin::SOURCE_WEBSTORE_INSTALL || |
| 169 choose_what_to_sync_ || |
| 170 show_inline_confirmation_for_sync ? |
| 171 OneClickSigninSyncStarter::NO_CONFIRMATION : |
| 172 OneClickSigninSyncStarter::CONFIRM_AFTER_SIGNIN; |
| 173 } |
| 174 |
162 bool start_signin = | 175 bool start_signin = |
163 !OneClickSigninHelper::HandleCrossAccountError( | 176 !OneClickSigninHelper::HandleCrossAccountError( |
164 profile_, "", | 177 profile_, "", |
165 email, password_, refresh_token, | 178 email, password_, refresh_token, |
166 OneClickSigninHelper::AUTO_ACCEPT_EXPLICIT, | 179 OneClickSigninHelper::AUTO_ACCEPT_EXPLICIT, |
167 source, start_mode, | 180 source, start_mode, |
168 base::Bind(&InlineLoginHandlerImpl::SyncStarterCallback, | 181 base::Bind(&InlineLoginHandlerImpl::SyncStarterCallback, |
169 handler_)); | 182 handler_)); |
170 if (start_signin) { | 183 if (start_signin) { |
171 // Call OneClickSigninSyncStarter to exchange oauth code for tokens. | 184 // Call OneClickSigninSyncStarter to exchange oauth code for tokens. |
(...skipping 21 matching lines...) Expand all Loading... |
193 AboutSigninInternalsFactory::GetForProfile(profile_); | 206 AboutSigninInternalsFactory::GetForProfile(profile_); |
194 about_signin_internals->OnRefreshTokenReceived("Failure"); | 207 about_signin_internals->OnRefreshTokenReceived("Failure"); |
195 | 208 |
196 base::MessageLoop::current()->DeleteSoon(FROM_HERE, this); | 209 base::MessageLoop::current()->DeleteSoon(FROM_HERE, this); |
197 } | 210 } |
198 | 211 |
199 } // namespace | 212 } // namespace |
200 | 213 |
201 InlineLoginHandlerImpl::InlineLoginHandlerImpl() | 214 InlineLoginHandlerImpl::InlineLoginHandlerImpl() |
202 : weak_factory_(this), | 215 : weak_factory_(this), |
203 choose_what_to_sync_(false) { | 216 confirm_untrusted_signin_(false) { |
204 } | 217 } |
205 | 218 |
206 InlineLoginHandlerImpl::~InlineLoginHandlerImpl() {} | 219 InlineLoginHandlerImpl::~InlineLoginHandlerImpl() {} |
207 | 220 |
208 bool InlineLoginHandlerImpl::HandleContextMenu( | 221 bool InlineLoginHandlerImpl::HandleContextMenu( |
209 const content::ContextMenuParams& params) { | 222 const content::ContextMenuParams& params) { |
210 #ifndef NDEBUG | 223 #ifndef NDEBUG |
211 return false; | 224 return false; |
212 #else | 225 #else |
213 return true; | 226 return true; |
214 #endif | 227 #endif |
215 } | 228 } |
216 | 229 |
| 230 void InlineLoginHandlerImpl::DidCommitProvisionalLoadForFrame( |
| 231 content::RenderFrameHost* render_frame_host, |
| 232 const GURL& url, |
| 233 content::PageTransition transition_type) { |
| 234 if (!web_contents()) |
| 235 return; |
| 236 |
| 237 // Returns early if this is not a gaia iframe navigation. |
| 238 const GURL kGaiaExtOrigin( |
| 239 "chrome-extension://mfffpogegjflfpflabcdkioaeobkgjik/"); |
| 240 content::RenderFrameHost* gaia_iframe = InlineLoginUI::GetAuthIframe( |
| 241 web_contents(), kGaiaExtOrigin, "signin-frame"); |
| 242 if (render_frame_host != gaia_iframe) |
| 243 return; |
| 244 |
| 245 // Loading any untrusted (e.g., HTTP) URLs in the privileged sign-in process |
| 246 // will require confirmation before the sign in takes effect. |
| 247 if (!url.is_empty() && |
| 248 url.spec() != url::kAboutBlankURL && |
| 249 !gaia::IsGaiaSignonRealm(url.GetOrigin()) && |
| 250 !signin::IsContinueUrlForWebBasedSigninFlow(url)) { |
| 251 confirm_untrusted_signin_ = true; |
| 252 } |
| 253 } |
| 254 |
217 void InlineLoginHandlerImpl::SetExtraInitParams(base::DictionaryValue& params) { | 255 void InlineLoginHandlerImpl::SetExtraInitParams(base::DictionaryValue& params) { |
218 params.SetString("service", "chromiumsync"); | 256 params.SetString("service", "chromiumsync"); |
219 | 257 |
220 content::WebContents* contents = web_ui()->GetWebContents(); | 258 content::WebContents* contents = web_ui()->GetWebContents(); |
221 const GURL& current_url = contents->GetURL(); | 259 const GURL& current_url = contents->GetURL(); |
222 std::string is_constrained; | 260 std::string is_constrained; |
223 net::GetValueForKeyInQuery(current_url, "constrained", &is_constrained); | 261 net::GetValueForKeyInQuery(current_url, "constrained", &is_constrained); |
224 if (is_constrained == "1") | 262 if (is_constrained == "1") |
225 contents->SetDelegate(this); | 263 contents->SetDelegate(this); |
226 | 264 |
| 265 content::WebContentsObserver::Observe(contents); |
| 266 |
227 signin::Source source = signin::GetSourceForPromoURL(current_url); | 267 signin::Source source = signin::GetSourceForPromoURL(current_url); |
228 OneClickSigninHelper::LogHistogramValue( | 268 OneClickSigninHelper::LogHistogramValue( |
229 source, one_click_signin::HISTOGRAM_SHOWN); | 269 source, one_click_signin::HISTOGRAM_SHOWN); |
230 } | 270 } |
231 | 271 |
232 void InlineLoginHandlerImpl::CompleteLogin(const base::ListValue* args) { | 272 void InlineLoginHandlerImpl::CompleteLogin(const base::ListValue* args) { |
233 content::WebContents* contents = web_ui()->GetWebContents(); | 273 content::WebContents* contents = web_ui()->GetWebContents(); |
234 const GURL& current_url = contents->GetURL(); | 274 const GURL& current_url = contents->GetURL(); |
235 | 275 |
236 const base::DictionaryValue* dict = NULL; | 276 const base::DictionaryValue* dict = NULL; |
237 args->GetDictionary(0, &dict); | 277 args->GetDictionary(0, &dict); |
238 | 278 |
239 bool skip_for_now = false; | 279 bool skip_for_now = false; |
240 dict->GetBoolean("skipForNow", &skip_for_now); | 280 dict->GetBoolean("skipForNow", &skip_for_now); |
241 if (skip_for_now) { | 281 if (skip_for_now) { |
242 signin::SetUserSkippedPromo(Profile::FromWebUI(web_ui())); | 282 signin::SetUserSkippedPromo(Profile::FromWebUI(web_ui())); |
243 SyncStarterCallback(OneClickSigninSyncStarter::SYNC_SETUP_FAILURE); | 283 SyncStarterCallback(OneClickSigninSyncStarter::SYNC_SETUP_FAILURE); |
244 return; | 284 return; |
245 } | 285 } |
246 | 286 |
247 base::string16 email; | 287 base::string16 email_string16; |
248 dict->GetString("email", &email); | 288 dict->GetString("email", &email_string16); |
249 DCHECK(!email.empty()); | 289 DCHECK(!email_string16.empty()); |
250 email_ = base::UTF16ToASCII(email); | 290 std::string email(base::UTF16ToASCII(email_string16)); |
251 base::string16 password; | 291 |
252 dict->GetString("password", &password); | 292 base::string16 password_string16; |
253 password_ = base::UTF16ToASCII(password); | 293 dict->GetString("password", &password_string16); |
| 294 std::string password(base::UTF16ToASCII(password_string16)); |
254 | 295 |
255 // When doing a SAML sign in, this email check may result in a false | 296 // When doing a SAML sign in, this email check may result in a false |
256 // positive. This happens when the user types one email address in the | 297 // positive. This happens when the user types one email address in the |
257 // gaia sign in page, but signs in to a different account in the SAML sign in | 298 // gaia sign in page, but signs in to a different account in the SAML sign in |
258 // page. | 299 // page. |
259 std::string default_email; | 300 std::string default_email; |
260 std::string validate_email; | 301 std::string validate_email; |
261 if (net::GetValueForKeyInQuery(current_url, "email", &default_email) && | 302 if (net::GetValueForKeyInQuery(current_url, "email", &default_email) && |
262 net::GetValueForKeyInQuery(current_url, "validateEmail", | 303 net::GetValueForKeyInQuery(current_url, "validateEmail", |
263 &validate_email) && | 304 &validate_email) && |
264 validate_email == "1") { | 305 validate_email == "1") { |
265 if (!gaia::AreEmailsSame(email_, default_email)) { | 306 if (!gaia::AreEmailsSame(email, default_email)) { |
266 SyncStarterCallback(OneClickSigninSyncStarter::SYNC_SETUP_FAILURE); | 307 SyncStarterCallback(OneClickSigninSyncStarter::SYNC_SETUP_FAILURE); |
267 return; | 308 return; |
268 } | 309 } |
269 } | 310 } |
270 | 311 |
271 base::string16 session_index; | 312 base::string16 session_index_string16; |
272 dict->GetString("sessionIndex", &session_index); | 313 dict->GetString("sessionIndex", &session_index_string16); |
273 session_index_ = base::UTF16ToASCII(session_index); | 314 std::string session_index = base::UTF16ToASCII(session_index_string16); |
274 DCHECK(!session_index_.empty()); | 315 DCHECK(!session_index.empty()); |
275 dict->GetBoolean("chooseWhatToSync", &choose_what_to_sync_); | 316 |
| 317 bool choose_what_to_sync = false; |
| 318 dict->GetBoolean("chooseWhatToSync", &choose_what_to_sync); |
276 | 319 |
277 signin::Source source = signin::GetSourceForPromoURL(current_url); | 320 signin::Source source = signin::GetSourceForPromoURL(current_url); |
278 OneClickSigninHelper::LogHistogramValue( | 321 OneClickSigninHelper::LogHistogramValue( |
279 source, one_click_signin::HISTOGRAM_ACCEPTED); | 322 source, one_click_signin::HISTOGRAM_ACCEPTED); |
280 bool switch_to_advanced = | 323 bool switch_to_advanced = |
281 choose_what_to_sync_ && (source != signin::SOURCE_SETTINGS); | 324 choose_what_to_sync && (source != signin::SOURCE_SETTINGS); |
282 OneClickSigninHelper::LogHistogramValue( | 325 OneClickSigninHelper::LogHistogramValue( |
283 source, | 326 source, |
284 switch_to_advanced ? one_click_signin::HISTOGRAM_WITH_ADVANCED : | 327 switch_to_advanced ? one_click_signin::HISTOGRAM_WITH_ADVANCED : |
285 one_click_signin::HISTOGRAM_WITH_DEFAULTS); | 328 one_click_signin::HISTOGRAM_WITH_DEFAULTS); |
286 | 329 |
287 OneClickSigninHelper::CanOfferFor can_offer_for = | 330 OneClickSigninHelper::CanOfferFor can_offer_for = |
288 OneClickSigninHelper::CAN_OFFER_FOR_ALL; | 331 OneClickSigninHelper::CAN_OFFER_FOR_ALL; |
289 switch (source) { | 332 switch (source) { |
290 case signin::SOURCE_AVATAR_BUBBLE_ADD_ACCOUNT: | 333 case signin::SOURCE_AVATAR_BUBBLE_ADD_ACCOUNT: |
291 can_offer_for = OneClickSigninHelper::CAN_OFFER_FOR_SECONDARY_ACCOUNT; | 334 can_offer_for = OneClickSigninHelper::CAN_OFFER_FOR_SECONDARY_ACCOUNT; |
292 break; | 335 break; |
293 case signin::SOURCE_REAUTH: { | 336 case signin::SOURCE_REAUTH: { |
294 std::string primary_username = | 337 std::string primary_username = |
295 SigninManagerFactory::GetForProfile( | 338 SigninManagerFactory::GetForProfile( |
296 Profile::FromWebUI(web_ui()))->GetAuthenticatedUsername(); | 339 Profile::FromWebUI(web_ui()))->GetAuthenticatedUsername(); |
297 if (!gaia::AreEmailsSame(default_email, primary_username)) | 340 if (!gaia::AreEmailsSame(default_email, primary_username)) |
298 can_offer_for = OneClickSigninHelper::CAN_OFFER_FOR_SECONDARY_ACCOUNT; | 341 can_offer_for = OneClickSigninHelper::CAN_OFFER_FOR_SECONDARY_ACCOUNT; |
299 break; | 342 break; |
300 } | 343 } |
301 default: | 344 default: |
302 // No need to change |can_offer_for|. | 345 // No need to change |can_offer_for|. |
303 break; | 346 break; |
304 } | 347 } |
305 | 348 |
306 std::string error_msg; | 349 std::string error_msg; |
307 bool can_offer = OneClickSigninHelper::CanOffer( | 350 bool can_offer = OneClickSigninHelper::CanOffer( |
308 contents, can_offer_for, email_, &error_msg); | 351 contents, can_offer_for, email, &error_msg); |
309 if (!can_offer) { | 352 if (!can_offer) { |
310 HandleLoginError(error_msg); | 353 HandleLoginError(error_msg); |
311 return; | 354 return; |
312 } | 355 } |
313 | 356 |
314 AboutSigninInternals* about_signin_internals = | 357 AboutSigninInternals* about_signin_internals = |
315 AboutSigninInternalsFactory::GetForProfile(Profile::FromWebUI(web_ui())); | 358 AboutSigninInternalsFactory::GetForProfile(Profile::FromWebUI(web_ui())); |
316 about_signin_internals->OnAuthenticationResultReceived( | 359 about_signin_internals->OnAuthenticationResultReceived( |
317 "GAIA Auth Successful"); | 360 "GAIA Auth Successful"); |
318 | 361 |
319 content::StoragePartition* partition = | 362 content::StoragePartition* partition = |
320 content::BrowserContext::GetStoragePartitionForSite( | 363 content::BrowserContext::GetStoragePartitionForSite( |
321 contents->GetBrowserContext(), | 364 contents->GetBrowserContext(), |
322 GURL(chrome::kChromeUIChromeSigninURL)); | 365 GURL(chrome::kChromeUIChromeSigninURL)); |
323 | 366 |
324 SigninClient* signin_client = | 367 SigninClient* signin_client = |
325 ChromeSigninClientFactory::GetForProfile(Profile::FromWebUI(web_ui())); | 368 ChromeSigninClientFactory::GetForProfile(Profile::FromWebUI(web_ui())); |
326 std::string signin_scoped_device_id = | 369 std::string signin_scoped_device_id = |
327 signin_client->GetSigninScopedDeviceId(); | 370 signin_client->GetSigninScopedDeviceId(); |
328 // InlineSigninHelper will delete itself. | 371 // InlineSigninHelper will delete itself. |
329 new InlineSigninHelper(GetWeakPtr(), partition->GetURLRequestContext(), | 372 new InlineSigninHelper(GetWeakPtr(), partition->GetURLRequestContext(), |
330 Profile::FromWebUI(web_ui()), current_url, | 373 Profile::FromWebUI(web_ui()), current_url, |
331 email_, password_, session_index_, | 374 email, password, session_index, |
332 signin_scoped_device_id, choose_what_to_sync_); | 375 signin_scoped_device_id, choose_what_to_sync, |
| 376 confirm_untrusted_signin_); |
333 | 377 |
334 email_.clear(); | |
335 password_.clear(); | |
336 session_index_.clear(); | |
337 web_ui()->CallJavascriptFunction("inline.login.closeDialog"); | 378 web_ui()->CallJavascriptFunction("inline.login.closeDialog"); |
338 } | 379 } |
339 | 380 |
340 void InlineLoginHandlerImpl::HandleLoginError(const std::string& error_msg) { | 381 void InlineLoginHandlerImpl::HandleLoginError(const std::string& error_msg) { |
341 SyncStarterCallback(OneClickSigninSyncStarter::SYNC_SETUP_FAILURE); | 382 SyncStarterCallback(OneClickSigninSyncStarter::SYNC_SETUP_FAILURE); |
342 | 383 |
343 Browser* browser = GetDesktopBrowser(); | 384 Browser* browser = GetDesktopBrowser(); |
344 if (browser && !error_msg.empty()) { | 385 if (browser && !error_msg.empty()) { |
345 VLOG(1) << "InlineLoginHandlerImpl::HandleLoginError shows error message: " | 386 VLOG(1) << "InlineLoginHandlerImpl::HandleLoginError shows error message: " |
346 << error_msg; | 387 << error_msg; |
347 OneClickSigninHelper::ShowSigninErrorBubble(browser, error_msg); | 388 OneClickSigninHelper::ShowSigninErrorBubble(browser, error_msg); |
348 } | 389 } |
349 | |
350 email_.clear(); | |
351 password_.clear(); | |
352 session_index_.clear(); | |
353 } | 390 } |
354 | 391 |
355 Browser* InlineLoginHandlerImpl::GetDesktopBrowser() { | 392 Browser* InlineLoginHandlerImpl::GetDesktopBrowser() { |
356 Browser* browser = chrome::FindBrowserWithWebContents( | 393 Browser* browser = chrome::FindBrowserWithWebContents( |
357 web_ui()->GetWebContents()); | 394 web_ui()->GetWebContents()); |
358 if (!browser) { | 395 if (!browser) { |
359 browser = chrome::FindLastActiveWithProfile( | 396 browser = chrome::FindLastActiveWithProfile( |
360 Profile::FromWebUI(web_ui()), chrome::GetActiveDesktop()); | 397 Profile::FromWebUI(web_ui()), chrome::GetActiveDesktop()); |
361 } | 398 } |
362 return browser; | 399 return browser; |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
403 } | 440 } |
404 } | 441 } |
405 | 442 |
406 if (show_account_management) { | 443 if (show_account_management) { |
407 browser->window()->ShowAvatarBubbleFromAvatarButton( | 444 browser->window()->ShowAvatarBubbleFromAvatarButton( |
408 BrowserWindow::AVATAR_BUBBLE_MODE_ACCOUNT_MANAGEMENT, | 445 BrowserWindow::AVATAR_BUBBLE_MODE_ACCOUNT_MANAGEMENT, |
409 signin::ManageAccountsParams()); | 446 signin::ManageAccountsParams()); |
410 } | 447 } |
411 } | 448 } |
412 } | 449 } |
OLD | NEW |