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 "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/prefs/pref_service.h" | 8 #include "base/prefs/pref_service.h" |
9 #include "base/strings/string_number_conversions.h" | 9 #include "base/strings/string_number_conversions.h" |
10 #include "base/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
55 const GURL& current_url = web_ui()->GetWebContents()->GetURL(); | 55 const GURL& current_url = web_ui()->GetWebContents()->GetURL(); |
56 signin::Source source = signin::GetSourceForPromoURL(current_url); | 56 signin::Source source = signin::GetSourceForPromoURL(current_url); |
57 DCHECK(source != signin::SOURCE_UNKNOWN); | 57 DCHECK(source != signin::SOURCE_UNKNOWN); |
58 if (source == signin::SOURCE_AVATAR_BUBBLE_ADD_ACCOUNT || | 58 if (source == signin::SOURCE_AVATAR_BUBBLE_ADD_ACCOUNT || |
59 source == signin::SOURCE_AVATAR_BUBBLE_SIGN_IN) { | 59 source == signin::SOURCE_AVATAR_BUBBLE_SIGN_IN) { |
60 // Drop the leading slash in the path. | 60 // Drop the leading slash in the path. |
61 params.SetString("gaiaPath", | 61 params.SetString("gaiaPath", |
62 GaiaUrls::GetInstance()->embedded_signin_url().path().substr(1)); | 62 GaiaUrls::GetInstance()->embedded_signin_url().path().substr(1)); |
63 } | 63 } |
64 | 64 |
65 // TODO(isherman): Should the continue URL be passed on to GAIA? When I try | |
66 // to pass it on, the tab crashes... I'm not exactly sure why. | |
Ilya Sherman
2014/03/14 05:42:56
^^^
guohui
2014/03/14 22:09:44
nope gaia does not need to know the continue url.
| |
65 params.SetString("service", "chromiumsync"); | 67 params.SetString("service", "chromiumsync"); |
66 params.SetString("continueUrl", | 68 params.SetString("continueUrl", |
67 signin::GetLandingURL("source", static_cast<int>(source)).spec()); | 69 signin::GetLandingURL("source", static_cast<int>(source)).spec()); |
68 | 70 |
69 std::string default_email; | 71 std::string default_email; |
70 if (source != signin::SOURCE_AVATAR_BUBBLE_ADD_ACCOUNT) { | 72 if (source != signin::SOURCE_AVATAR_BUBBLE_ADD_ACCOUNT) { |
71 default_email = Profile::FromWebUI(web_ui())->GetPrefs()-> | 73 default_email = Profile::FromWebUI(web_ui())->GetPrefs()-> |
72 GetString(prefs::kGoogleServicesLastUsername); | 74 GetString(prefs::kGoogleServicesLastUsername); |
73 } else { | 75 } else { |
74 if (!net::GetValueForKeyInQuery(current_url, "email", &default_email)) | 76 if (!net::GetValueForKeyInQuery(current_url, "email", &default_email)) |
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
312 // Do nothing if a navigation is pending, since this call can be triggered | 314 // Do nothing if a navigation is pending, since this call can be triggered |
313 // from DidStartLoading. This avoids deleting the pending entry while we are | 315 // from DidStartLoading. This avoids deleting the pending entry while we are |
314 // still navigating to it. See crbug/346632. | 316 // still navigating to it. See crbug/346632. |
315 return; | 317 return; |
316 } | 318 } |
317 | 319 |
318 const GURL& current_url = contents->GetLastCommittedURL(); | 320 const GURL& current_url = contents->GetLastCommittedURL(); |
319 signin::Source source = signin::GetSourceForPromoURL(current_url); | 321 signin::Source source = signin::GetSourceForPromoURL(current_url); |
320 DCHECK(source != signin::SOURCE_UNKNOWN); | 322 DCHECK(source != signin::SOURCE_UNKNOWN); |
321 bool auto_close = signin::IsAutoCloseEnabledInURL(current_url); | 323 bool auto_close = signin::IsAutoCloseEnabledInURL(current_url); |
324 std::string continue_url; | |
325 net::GetValueForKeyInQuery(current_url, "continueUrl", &continue_url); | |
322 | 326 |
323 if (result == OneClickSigninSyncStarter::SYNC_SETUP_FAILURE) { | 327 if (result == OneClickSigninSyncStarter::SYNC_SETUP_FAILURE) { |
324 OneClickSigninHelper::RedirectToNtpOrAppsPage(contents, source); | 328 OneClickSigninHelper::RedirectToNtpOrAppsPage(contents, source); |
325 } else if (auto_close) { | 329 } else if (auto_close) { |
326 base::MessageLoop::current()->PostTask( | 330 base::MessageLoop::current()->PostTask( |
327 FROM_HERE, | 331 FROM_HERE, |
328 base::Bind(&InlineLoginHandlerImpl::CloseTab, | 332 base::Bind(&InlineLoginHandlerImpl::CloseTab, |
329 weak_factory_.GetWeakPtr())); | 333 weak_factory_.GetWeakPtr())); |
334 } else if (!continue_url.empty()) { | |
335 // TODO(isherman): If the user opts to choose what is synced, this code is | |
336 // reached, but then the tab is hijacked by chrome://settings/syncSetup. | |
Ilya Sherman
2014/03/14 05:42:56
I'm not sure what to do about this. Conceptually,
guohui
2014/03/14 22:09:44
yup sync setup should open in the current tab, and
| |
337 contents->GetController().LoadURL(GURL(continue_url), | |
338 content::Referrer(), | |
339 content::PAGE_TRANSITION_AUTO_TOPLEVEL, | |
340 std::string()); | |
330 } else { | 341 } else { |
331 OneClickSigninHelper::RedirectToNtpOrAppsPageIfNecessary(contents, source); | 342 OneClickSigninHelper::RedirectToNtpOrAppsPageIfNecessary(contents, source); |
332 } | 343 } |
333 } | 344 } |
334 | 345 |
335 void InlineLoginHandlerImpl::CloseTab() { | 346 void InlineLoginHandlerImpl::CloseTab() { |
336 content::WebContents* tab = web_ui()->GetWebContents(); | 347 content::WebContents* tab = web_ui()->GetWebContents(); |
337 Browser* browser = chrome::FindBrowserWithWebContents(tab); | 348 Browser* browser = chrome::FindBrowserWithWebContents(tab); |
338 if (browser) { | 349 if (browser) { |
339 TabStripModel* tab_strip_model = browser->tab_strip_model(); | 350 TabStripModel* tab_strip_model = browser->tab_strip_model(); |
340 if (tab_strip_model) { | 351 if (tab_strip_model) { |
341 int index = tab_strip_model->GetIndexOfWebContents(tab); | 352 int index = tab_strip_model->GetIndexOfWebContents(tab); |
342 if (index != TabStripModel::kNoTab) { | 353 if (index != TabStripModel::kNoTab) { |
343 tab_strip_model->ExecuteContextMenuCommand( | 354 tab_strip_model->ExecuteContextMenuCommand( |
344 index, TabStripModel::CommandCloseTab); | 355 index, TabStripModel::CommandCloseTab); |
345 } | 356 } |
346 } | 357 } |
347 } | 358 } |
348 } | 359 } |
OLD | NEW |