Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(275)

Side by Side Diff: chrome/browser/ui/webui/options/sync_setup_handler.cc

Issue 809313009: Make the SigninErrorController a PKS. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Copyrighted: 2015 Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/options/sync_setup_handler.h" 5 #include "chrome/browser/ui/webui/options/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"
11 #include "base/compiler_specific.h" 11 #include "base/compiler_specific.h"
12 #include "base/i18n/time_formatting.h" 12 #include "base/i18n/time_formatting.h"
13 #include "base/json/json_reader.h" 13 #include "base/json/json_reader.h"
14 #include "base/json/json_writer.h" 14 #include "base/json/json_writer.h"
15 #include "base/metrics/histogram.h" 15 #include "base/metrics/histogram.h"
16 #include "base/prefs/pref_service.h" 16 #include "base/prefs/pref_service.h"
17 #include "base/strings/utf_string_conversions.h" 17 #include "base/strings/utf_string_conversions.h"
18 #include "base/values.h" 18 #include "base/values.h"
19 #include "chrome/app/chrome_command_ids.h" 19 #include "chrome/app/chrome_command_ids.h"
20 #include "chrome/browser/browser_process.h" 20 #include "chrome/browser/browser_process.h"
21 #include "chrome/browser/lifetime/application_lifetime.h" 21 #include "chrome/browser/lifetime/application_lifetime.h"
22 #include "chrome/browser/profiles/profile.h" 22 #include "chrome/browser/profiles/profile.h"
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/signin_error_controller_factory.h"
27 #include "chrome/browser/signin/signin_header_helper.h" 27 #include "chrome/browser/signin/signin_header_helper.h"
28 #include "chrome/browser/signin/signin_manager_factory.h" 28 #include "chrome/browser/signin/signin_manager_factory.h"
29 #include "chrome/browser/signin/signin_promo.h" 29 #include "chrome/browser/signin/signin_promo.h"
30 #include "chrome/browser/sync/profile_sync_service.h" 30 #include "chrome/browser/sync/profile_sync_service.h"
31 #include "chrome/browser/sync/profile_sync_service_factory.h" 31 #include "chrome/browser/sync/profile_sync_service_factory.h"
32 #include "chrome/browser/ui/browser_finder.h" 32 #include "chrome/browser/ui/browser_finder.h"
33 #include "chrome/browser/ui/browser_navigator.h" 33 #include "chrome/browser/ui/browser_navigator.h"
34 #include "chrome/browser/ui/browser_window.h" 34 #include "chrome/browser/ui/browser_window.h"
35 #include "chrome/browser/ui/singleton_tabs.h" 35 #include "chrome/browser/ui/singleton_tabs.h"
36 #include "chrome/browser/ui/webui/options/options_handlers_helper.h" 36 #include "chrome/browser/ui/webui/options/options_handlers_helper.h"
37 #include "chrome/browser/ui/webui/signin/login_ui_service.h" 37 #include "chrome/browser/ui/webui/signin/login_ui_service.h"
38 #include "chrome/browser/ui/webui/signin/login_ui_service_factory.h" 38 #include "chrome/browser/ui/webui/signin/login_ui_service_factory.h"
39 #include "chrome/common/chrome_switches.h" 39 #include "chrome/common/chrome_switches.h"
40 #include "chrome/common/url_constants.h" 40 #include "chrome/common/url_constants.h"
41 #include "chrome/grit/chromium_strings.h" 41 #include "chrome/grit/chromium_strings.h"
42 #include "chrome/grit/generated_resources.h" 42 #include "chrome/grit/generated_resources.h"
43 #include "chrome/grit/locale_settings.h" 43 #include "chrome/grit/locale_settings.h"
44 #include "components/google/core/browser/google_util.h" 44 #include "components/google/core/browser/google_util.h"
45 #include "components/signin/core/browser/profile_oauth2_token_service.h"
46 #include "components/signin/core/browser/signin_error_controller.h" 45 #include "components/signin/core/browser/signin_error_controller.h"
47 #include "components/signin/core/browser/signin_metrics.h" 46 #include "components/signin/core/browser/signin_metrics.h"
48 #include "components/signin/core/common/profile_management_switches.h" 47 #include "components/signin/core/common/profile_management_switches.h"
49 #include "components/sync_driver/sync_prefs.h" 48 #include "components/sync_driver/sync_prefs.h"
50 #include "content/public/browser/render_view_host.h" 49 #include "content/public/browser/render_view_host.h"
51 #include "content/public/browser/web_contents.h" 50 #include "content/public/browser/web_contents.h"
52 #include "content/public/browser/web_contents_delegate.h" 51 #include "content/public/browser/web_contents_delegate.h"
53 #include "google_apis/gaia/gaia_auth_util.h" 52 #include "google_apis/gaia/gaia_auth_util.h"
54 #include "google_apis/gaia/gaia_constants.h" 53 #include "google_apis/gaia/gaia_constants.h"
55 #include "grit/components_strings.h" 54 #include "grit/components_strings.h"
(...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after
362 // re-auth scenario, and we need to ensure that the user signs in with the 361 // re-auth scenario, and we need to ensure that the user signs in with the
363 // same email address. 362 // same email address.
364 GURL url; 363 GURL url;
365 if (SigninManagerFactory::GetForProfile( 364 if (SigninManagerFactory::GetForProfile(
366 browser->profile())->IsAuthenticated()) { 365 browser->profile())->IsAuthenticated()) {
367 UMA_HISTOGRAM_ENUMERATION("Signin.Reauth", 366 UMA_HISTOGRAM_ENUMERATION("Signin.Reauth",
368 signin_metrics::HISTOGRAM_REAUTH_SHOWN, 367 signin_metrics::HISTOGRAM_REAUTH_SHOWN,
369 signin_metrics::HISTOGRAM_REAUTH_MAX); 368 signin_metrics::HISTOGRAM_REAUTH_MAX);
370 369
371 SigninErrorController* error_controller = 370 SigninErrorController* error_controller =
372 ProfileOAuth2TokenServiceFactory::GetForProfile(browser->profile())-> 371 SigninErrorControllerFactory::GetForProfile(browser->profile());
373 signin_error_controller();
374 DCHECK(error_controller->HasError()); 372 DCHECK(error_controller->HasError());
375 if (switches::IsNewAvatarMenu() && !force_new_tab) { 373 if (switches::IsNewAvatarMenu() && !force_new_tab) {
376 browser->window()->ShowAvatarBubbleFromAvatarButton( 374 browser->window()->ShowAvatarBubbleFromAvatarButton(
377 BrowserWindow::AVATAR_BUBBLE_MODE_REAUTH, 375 BrowserWindow::AVATAR_BUBBLE_MODE_REAUTH,
378 signin::ManageAccountsParams()); 376 signin::ManageAccountsParams());
379 } else { 377 } else {
380 url = signin::GetReauthURL(browser->profile(), 378 url = signin::GetReauthURL(browser->profile(),
381 error_controller->error_account_id()); 379 error_controller->error_account_id());
382 } 380 }
383 } else { 381 } else {
(...skipping 350 matching lines...) Expand 10 before | Expand all | Expand 10 after
734 // 5) User clicks [Advanced Settings] button on options page while already 732 // 5) User clicks [Advanced Settings] button on options page while already
735 // logged in. 733 // logged in.
736 // 6) One-click signin (credentials are already available, so should display 734 // 6) One-click signin (credentials are already available, so should display
737 // sync configure UI, not login UI). 735 // sync configure UI, not login UI).
738 // 7) User re-enables sync after disabling it via advanced settings. 736 // 7) User re-enables sync after disabling it via advanced settings.
739 #if !defined(OS_CHROMEOS) 737 #if !defined(OS_CHROMEOS)
740 SigninManagerBase* signin = 738 SigninManagerBase* signin =
741 SigninManagerFactory::GetForProfile(GetProfile()); 739 SigninManagerFactory::GetForProfile(GetProfile());
742 740
743 if (!signin->IsAuthenticated() || 741 if (!signin->IsAuthenticated() ||
744 ProfileOAuth2TokenServiceFactory::GetForProfile(GetProfile())-> 742 SigninErrorControllerFactory::GetForProfile(GetProfile())->HasError()) {
745 signin_error_controller()->HasError()) {
746 // User is not logged in (cases 1-2), or login has been specially requested 743 // User is not logged in (cases 1-2), or login has been specially requested
747 // because previously working credentials have expired (case 3). Close sync 744 // because previously working credentials have expired (case 3). Close sync
748 // setup including any visible overlays, and display the gaia auth page. 745 // setup including any visible overlays, and display the gaia auth page.
749 // Control will be returned to the sync settings page once auth is complete. 746 // Control will be returned to the sync settings page once auth is complete.
750 CloseUI(); 747 CloseUI();
751 DisplayGaiaLogin(); 748 DisplayGaiaLogin();
752 return; 749 return;
753 } 750 }
754 #endif 751 #endif
755 if (!GetSyncService()) { 752 if (!GetSyncService()) {
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
923 "SyncSetupOverlay.showSyncSetupPage", page, args); 920 "SyncSetupOverlay.showSyncSetupPage", page, args);
924 921
925 // Make sure the tab used for the Gaia sign in does not cover the settings 922 // Make sure the tab used for the Gaia sign in does not cover the settings
926 // tab. 923 // tab.
927 FocusUI(); 924 FocusUI();
928 } 925 }
929 926
930 LoginUIService* SyncSetupHandler::GetLoginUIService() const { 927 LoginUIService* SyncSetupHandler::GetLoginUIService() const {
931 return LoginUIServiceFactory::GetForProfile(GetProfile()); 928 return LoginUIServiceFactory::GetForProfile(GetProfile());
932 } 929 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698