| 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/webui/sync_setup_handler.h" | 5 #include "chrome/browser/ui/webui/sync_setup_handler.h" |
| 6 | 6 |
| 7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
| 8 #include "base/bind.h" | 8 #include "base/bind.h" |
| 9 #include "base/bind_helpers.h" | 9 #include "base/bind_helpers.h" |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 #include "chrome/browser/profiles/profile_info_cache.h" | 23 #include "chrome/browser/profiles/profile_info_cache.h" |
| 24 #include "chrome/browser/profiles/profile_manager.h" | 24 #include "chrome/browser/profiles/profile_manager.h" |
| 25 #include "chrome/browser/profiles/profile_metrics.h" | 25 #include "chrome/browser/profiles/profile_metrics.h" |
| 26 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" | 26 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" |
| 27 #include "chrome/browser/signin/signin_manager_factory.h" | 27 #include "chrome/browser/signin/signin_manager_factory.h" |
| 28 #include "chrome/browser/signin/signin_promo.h" | 28 #include "chrome/browser/signin/signin_promo.h" |
| 29 #include "chrome/browser/sync/profile_sync_service.h" | 29 #include "chrome/browser/sync/profile_sync_service.h" |
| 30 #include "chrome/browser/sync/profile_sync_service_factory.h" | 30 #include "chrome/browser/sync/profile_sync_service_factory.h" |
| 31 #include "chrome/browser/ui/browser_finder.h" | 31 #include "chrome/browser/ui/browser_finder.h" |
| 32 #include "chrome/browser/ui/browser_navigator.h" | 32 #include "chrome/browser/ui/browser_navigator.h" |
| 33 #include "chrome/browser/ui/browser_window.h" |
| 33 #include "chrome/browser/ui/singleton_tabs.h" | 34 #include "chrome/browser/ui/singleton_tabs.h" |
| 34 #include "chrome/browser/ui/sync/signin_histogram.h" | 35 #include "chrome/browser/ui/sync/signin_histogram.h" |
| 35 #include "chrome/browser/ui/webui/signin/login_ui_service.h" | 36 #include "chrome/browser/ui/webui/signin/login_ui_service.h" |
| 36 #include "chrome/browser/ui/webui/signin/login_ui_service_factory.h" | 37 #include "chrome/browser/ui/webui/signin/login_ui_service_factory.h" |
| 37 #include "chrome/common/chrome_switches.h" | 38 #include "chrome/common/chrome_switches.h" |
| 38 #include "chrome/common/pref_names.h" | 39 #include "chrome/common/pref_names.h" |
| 39 #include "chrome/common/url_constants.h" | 40 #include "chrome/common/url_constants.h" |
| 40 #include "components/signin/core/browser/profile_oauth2_token_service.h" | 41 #include "components/signin/core/browser/profile_oauth2_token_service.h" |
| 41 #include "components/signin/core/browser/signin_error_controller.h" | 42 #include "components/signin/core/browser/signin_error_controller.h" |
| 43 #include "components/signin/core/common/profile_management_switches.h" |
| 42 #include "components/sync_driver/sync_prefs.h" | 44 #include "components/sync_driver/sync_prefs.h" |
| 43 #include "content/public/browser/render_view_host.h" | 45 #include "content/public/browser/render_view_host.h" |
| 44 #include "content/public/browser/web_contents.h" | 46 #include "content/public/browser/web_contents.h" |
| 45 #include "content/public/browser/web_contents_delegate.h" | 47 #include "content/public/browser/web_contents_delegate.h" |
| 46 #include "google_apis/gaia/gaia_auth_util.h" | 48 #include "google_apis/gaia/gaia_auth_util.h" |
| 47 #include "google_apis/gaia/gaia_constants.h" | 49 #include "google_apis/gaia/gaia_constants.h" |
| 48 #include "grit/chromium_strings.h" | 50 #include "grit/chromium_strings.h" |
| 49 #include "grit/generated_resources.h" | 51 #include "grit/generated_resources.h" |
| 50 #include "grit/locale_settings.h" | 52 #include "grit/locale_settings.h" |
| 51 #include "net/base/url_util.h" | 53 #include "net/base/url_util.h" |
| (...skipping 458 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 510 browser->profile())->GetAuthenticatedUsername(); | 512 browser->profile())->GetAuthenticatedUsername(); |
| 511 if (!email.empty()) { | 513 if (!email.empty()) { |
| 512 UMA_HISTOGRAM_ENUMERATION("Signin.Reauth", | 514 UMA_HISTOGRAM_ENUMERATION("Signin.Reauth", |
| 513 signin::HISTOGRAM_SHOWN, | 515 signin::HISTOGRAM_SHOWN, |
| 514 signin::HISTOGRAM_MAX); | 516 signin::HISTOGRAM_MAX); |
| 515 | 517 |
| 516 SigninErrorController* error_controller = | 518 SigninErrorController* error_controller = |
| 517 ProfileOAuth2TokenServiceFactory::GetForProfile(browser->profile())-> | 519 ProfileOAuth2TokenServiceFactory::GetForProfile(browser->profile())-> |
| 518 signin_error_controller(); | 520 signin_error_controller(); |
| 519 DCHECK(error_controller->HasError()); | 521 DCHECK(error_controller->HasError()); |
| 520 url = signin::GetReauthURL(browser->profile(), | 522 if (switches::IsNewProfileManagement()) { |
| 521 error_controller->error_account_id()); | 523 browser->window()->ShowAvatarBubbleFromAvatarButton( |
| 524 BrowserWindow::AVATAR_BUBBLE_MODE_REAUTH); |
| 525 } else { |
| 526 url = signin::GetReauthURL(browser->profile(), |
| 527 error_controller->error_account_id()); |
| 528 } |
| 522 } else { | 529 } else { |
| 523 url = signin::GetPromoURL(signin::SOURCE_SETTINGS, true); | 530 if (switches::IsNewProfileManagement()) { |
| 531 browser->window()->ShowAvatarBubbleFromAvatarButton( |
| 532 BrowserWindow::AVATAR_BUBBLE_MODE_SIGNIN); |
| 533 } else { |
| 534 url = signin::GetPromoURL(signin::SOURCE_SETTINGS, true); |
| 535 } |
| 524 } | 536 } |
| 525 | 537 |
| 526 chrome::ShowSingletonTab(browser, url); | 538 if (url.is_valid()) |
| 539 chrome::ShowSingletonTab(browser, url); |
| 527 } | 540 } |
| 528 #endif | 541 #endif |
| 529 | 542 |
| 530 bool SyncSetupHandler::PrepareSyncSetup() { | 543 bool SyncSetupHandler::PrepareSyncSetup() { |
| 531 | 544 |
| 532 // If the wizard is already visible, just focus that one. | 545 // If the wizard is already visible, just focus that one. |
| 533 if (FocusExistingWizardIfPresent()) { | 546 if (FocusExistingWizardIfPresent()) { |
| 534 if (!IsActiveLogin()) | 547 if (!IsActiveLogin()) |
| 535 CloseSyncSetup(); | 548 CloseSyncSetup(); |
| 536 return false; | 549 return false; |
| (...skipping 385 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 922 | 935 |
| 923 LoginUIService* service = GetLoginUIService(); | 936 LoginUIService* service = GetLoginUIService(); |
| 924 DCHECK(service); | 937 DCHECK(service); |
| 925 service->current_login_ui()->FocusUI(); | 938 service->current_login_ui()->FocusUI(); |
| 926 return true; | 939 return true; |
| 927 } | 940 } |
| 928 | 941 |
| 929 LoginUIService* SyncSetupHandler::GetLoginUIService() const { | 942 LoginUIService* SyncSetupHandler::GetLoginUIService() const { |
| 930 return LoginUIServiceFactory::GetForProfile(GetProfile()); | 943 return LoginUIServiceFactory::GetForProfile(GetProfile()); |
| 931 } | 944 } |
| OLD | NEW |