Chromium Code Reviews| 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/chrome_pages.h" | 5 #include "chrome/browser/ui/chrome_pages.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/strings/string_number_conversions.h" | 9 #include "base/strings/string_number_conversions.h" |
| 10 #include "base/strings/stringprintf.h" | 10 #include "base/strings/stringprintf.h" |
| (...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 350 params.path_behavior = NavigateParams::IGNORE_AND_NAVIGATE; | 350 params.path_behavior = NavigateParams::IGNORE_AND_NAVIGATE; |
| 351 ShowSingletonTabOverwritingNTP(browser, params); | 351 ShowSingletonTabOverwritingNTP(browser, params); |
| 352 } | 352 } |
| 353 | 353 |
| 354 void ShowSearchEngineSettings(Browser* browser) { | 354 void ShowSearchEngineSettings(Browser* browser) { |
| 355 content::RecordAction(UserMetricsAction("EditSearchEngines")); | 355 content::RecordAction(UserMetricsAction("EditSearchEngines")); |
| 356 ShowSettingsSubPage(browser, kSearchEnginesSubPage); | 356 ShowSettingsSubPage(browser, kSearchEnginesSubPage); |
| 357 } | 357 } |
| 358 | 358 |
| 359 #if !defined(OS_ANDROID) && !defined(OS_IOS) | 359 #if !defined(OS_ANDROID) && !defined(OS_IOS) |
| 360 void ShowBrowserSignin(Browser* browser, signin_metrics::Source source) { | 360 void ShowBrowserSignin(Browser* browser, |
| 361 signin_metrics::AccessPoint access_point) { | |
| 361 Profile* original_profile = browser->profile()->GetOriginalProfile(); | 362 Profile* original_profile = browser->profile()->GetOriginalProfile(); |
| 362 SigninManagerBase* manager = | 363 SigninManagerBase* manager = |
| 363 SigninManagerFactory::GetForProfile(original_profile); | 364 SigninManagerFactory::GetForProfile(original_profile); |
| 364 DCHECK(manager->IsSigninAllowed()); | 365 DCHECK(manager->IsSigninAllowed()); |
| 365 // If the browser's profile is an incognito profile, make sure to use | 366 // If the browser's profile is an incognito profile, make sure to use |
| 366 // a browser window from the original profile. The user cannot sign in | 367 // a browser window from the original profile. The user cannot sign in |
| 367 // from an incognito window. | 368 // from an incognito window. |
| 368 bool switched_browser = false; | 369 bool switched_browser = false; |
| 369 scoped_ptr<ScopedTabbedBrowserDisplayer> displayer; | 370 scoped_ptr<ScopedTabbedBrowserDisplayer> displayer; |
| 370 if (browser->profile()->IsOffTheRecord()) { | 371 if (browser->profile()->IsOffTheRecord()) { |
| 371 switched_browser = true; | 372 switched_browser = true; |
| 372 displayer.reset(new ScopedTabbedBrowserDisplayer( | 373 displayer.reset(new ScopedTabbedBrowserDisplayer( |
| 373 original_profile, chrome::HOST_DESKTOP_TYPE_NATIVE)); | 374 original_profile, chrome::HOST_DESKTOP_TYPE_NATIVE)); |
| 374 browser = displayer->browser(); | 375 browser = displayer->browser(); |
| 375 } | 376 } |
| 376 | 377 |
| 377 signin_metrics::LogSigninSource(source); | 378 // Since the extension is a separate application, it might steal focus |
| 378 | |
| 379 // Since the app launcher is a separate application, it might steal focus | |
| 380 // away from Chrome, and accidentally close the avatar bubble. The same will | 379 // away from Chrome, and accidentally close the avatar bubble. The same will |
| 381 // happen if we had to switch browser windows to show the sign in page. In | 380 // happen if we had to switch browser windows to show the sign in page. In |
| 382 // this case, fallback to the full-tab signin page. | 381 // this case, fallback to the full-tab signin page. |
| 383 bool show_avatar_bubble = | 382 bool show_avatar_bubble = |
| 384 source != signin_metrics::SOURCE_APP_LAUNCHER && !switched_browser; | 383 access_point != signin_metrics::ACCESS_POINT_EXTENSIONS && |
| 384 !switched_browser; | |
| 385 #if defined(OS_CHROMEOS) | 385 #if defined(OS_CHROMEOS) |
| 386 // ChromeOS doesn't have the avatar bubble. | 386 // ChromeOS doesn't have the avatar bubble. |
| 387 show_avatar_bubble = false; | 387 show_avatar_bubble = false; |
| 388 #endif | 388 #endif |
| 389 | 389 |
| 390 if (show_avatar_bubble) { | 390 if (show_avatar_bubble) { |
| 391 browser->window()->ShowAvatarBubbleFromAvatarButton( | 391 browser->window()->ShowAvatarBubbleFromAvatarButton( |
| 392 BrowserWindow::AVATAR_BUBBLE_MODE_SIGNIN, | 392 BrowserWindow::AVATAR_BUBBLE_MODE_SIGNIN, |
| 393 signin::ManageAccountsParams()); | 393 signin::ManageAccountsParams(), access_point); |
| 394 } else { | 394 } else { |
| 395 NavigateToSingletonTab(browser, GURL(signin::GetPromoURL(source, false))); | 395 NavigateToSingletonTab( |
| 396 browser, GURL(signin::GetPromoURL( | |
|
sky
2015/12/03 22:45:28
Doesn't GetPromoURL return a GURL?
gogerald1
2015/12/04 20:49:09
Done. Both the old and new code return a GURL.
| |
| 397 access_point, | |
| 398 signin_metrics::REASON_SIGNIN_PRIMARY_ACCOUNT, false))); | |
| 396 DCHECK_GT(browser->tab_strip_model()->count(), 0); | 399 DCHECK_GT(browser->tab_strip_model()->count(), 0); |
| 397 } | 400 } |
| 398 } | 401 } |
| 399 | 402 |
| 400 void ShowBrowserSigninOrSettings( | 403 void ShowBrowserSigninOrSettings(Browser* browser, |
| 401 Browser* browser, | 404 signin_metrics::AccessPoint access_point) { |
| 402 signin_metrics::Source source) { | |
| 403 Profile* original_profile = browser->profile()->GetOriginalProfile(); | 405 Profile* original_profile = browser->profile()->GetOriginalProfile(); |
| 404 SigninManagerBase* manager = | 406 SigninManagerBase* manager = |
| 405 SigninManagerFactory::GetForProfile(original_profile); | 407 SigninManagerFactory::GetForProfile(original_profile); |
| 406 DCHECK(manager->IsSigninAllowed()); | 408 DCHECK(manager->IsSigninAllowed()); |
| 407 if (manager->IsAuthenticated()) | 409 if (manager->IsAuthenticated()) |
| 408 ShowSettings(browser); | 410 ShowSettings(browser); |
| 409 else | 411 else |
| 410 ShowBrowserSignin(browser, source); | 412 ShowBrowserSignin(browser, access_point); |
| 411 } | 413 } |
| 412 #endif | 414 #endif |
| 413 | 415 |
| 414 } // namespace chrome | 416 } // namespace chrome |
| OLD | NEW |