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 #include "chrome/browser/ui/sync/one_click_signin_sync_starter.h" | 5 #include "chrome/browser/ui/sync/one_click_signin_sync_starter.h" |
6 | 6 |
7 #include "base/prefs/pref_service.h" | 7 #include "base/prefs/pref_service.h" |
8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
9 #include "chrome/browser/browser_process.h" | 9 #include "chrome/browser/browser_process.h" |
10 | 10 |
(...skipping 438 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
449 EnsureBrowser(); | 449 EnsureBrowser(); |
450 | 450 |
451 // If the sign in tab is showing the native signin page or the blank page | 451 // If the sign in tab is showing the native signin page or the blank page |
452 // for web-based flow, and is not about to be closed, use it to show the | 452 // for web-based flow, and is not about to be closed, use it to show the |
453 // settings UI. | 453 // settings UI. |
454 bool use_same_tab = false; | 454 bool use_same_tab = false; |
455 if (web_contents()) { | 455 if (web_contents()) { |
456 GURL current_url = web_contents()->GetLastCommittedURL(); | 456 GURL current_url = web_contents()->GetLastCommittedURL(); |
457 bool is_chrome_signin_url = | 457 bool is_chrome_signin_url = |
458 current_url.GetOrigin().spec() == chrome::kChromeUIChromeSigninURL; | 458 current_url.GetOrigin().spec() == chrome::kChromeUIChromeSigninURL; |
| 459 bool is_same_profile = |
| 460 Profile::FromBrowserContext(web_contents()->GetBrowserContext()) == |
| 461 profile_; |
459 use_same_tab = | 462 use_same_tab = |
460 (is_chrome_signin_url || | 463 (is_chrome_signin_url || |
461 signin::IsContinueUrlForWebBasedSigninFlow(current_url)) && | 464 signin::IsContinueUrlForWebBasedSigninFlow(current_url)) && |
462 !signin::IsAutoCloseEnabledInURL(current_url); | 465 !signin::IsAutoCloseEnabledInURL(current_url) && |
| 466 is_same_profile; |
463 } | 467 } |
464 if (profile_sync_service) { | 468 if (profile_sync_service) { |
465 // Need to navigate to the settings page and display the sync UI. | 469 // Need to navigate to the settings page and display the sync UI. |
466 if (use_same_tab) { | 470 if (use_same_tab) { |
467 ShowSettingsPageInWebContents(web_contents(), | 471 ShowSettingsPageInWebContents(web_contents(), |
468 chrome::kSyncSetupSubPage); | 472 chrome::kSyncSetupSubPage); |
469 } else { | 473 } else { |
470 // If the user is setting up sync for the first time, let them configure | 474 // If the user is setting up sync for the first time, let them configure |
471 // advanced sync settings. However, in the case of re-authentication, | 475 // advanced sync settings. However, in the case of re-authentication, |
472 // return the user to the settings page without showing any config UI. | 476 // return the user to the settings page without showing any config UI. |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
513 false); | 517 false); |
514 contents->OpenURL(params); | 518 contents->OpenURL(params); |
515 | 519 |
516 // Activate the tab. | 520 // Activate the tab. |
517 Browser* browser = chrome::FindBrowserWithWebContents(contents); | 521 Browser* browser = chrome::FindBrowserWithWebContents(contents); |
518 int content_index = | 522 int content_index = |
519 browser->tab_strip_model()->GetIndexOfWebContents(contents); | 523 browser->tab_strip_model()->GetIndexOfWebContents(contents); |
520 browser->tab_strip_model()->ActivateTabAt(content_index, | 524 browser->tab_strip_model()->ActivateTabAt(content_index, |
521 false /* user_gesture */); | 525 false /* user_gesture */); |
522 } | 526 } |
OLD | NEW |