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 24 matching lines...) Expand all Loading... | |
35 #include "chrome/browser/ui/browser_window.h" | 35 #include "chrome/browser/ui/browser_window.h" |
36 #include "chrome/browser/ui/singleton_tabs.h" | 36 #include "chrome/browser/ui/singleton_tabs.h" |
37 #include "chrome/browser/ui/sync/signin_histogram.h" | 37 #include "chrome/browser/ui/sync/signin_histogram.h" |
38 #include "chrome/browser/ui/webui/signin/login_ui_service.h" | 38 #include "chrome/browser/ui/webui/signin/login_ui_service.h" |
39 #include "chrome/browser/ui/webui/signin/login_ui_service_factory.h" | 39 #include "chrome/browser/ui/webui/signin/login_ui_service_factory.h" |
40 #include "chrome/common/chrome_switches.h" | 40 #include "chrome/common/chrome_switches.h" |
41 #include "chrome/common/pref_names.h" | 41 #include "chrome/common/pref_names.h" |
42 #include "chrome/common/url_constants.h" | 42 #include "chrome/common/url_constants.h" |
43 #include "components/signin/core/browser/profile_oauth2_token_service.h" | 43 #include "components/signin/core/browser/profile_oauth2_token_service.h" |
44 #include "components/signin/core/browser/signin_error_controller.h" | 44 #include "components/signin/core/browser/signin_error_controller.h" |
45 #include "components/signin/core/browser/signin_metrics.h" | |
45 #include "components/signin/core/common/profile_management_switches.h" | 46 #include "components/signin/core/common/profile_management_switches.h" |
46 #include "components/sync_driver/sync_prefs.h" | 47 #include "components/sync_driver/sync_prefs.h" |
47 #include "content/public/browser/render_view_host.h" | 48 #include "content/public/browser/render_view_host.h" |
48 #include "content/public/browser/web_contents.h" | 49 #include "content/public/browser/web_contents.h" |
49 #include "content/public/browser/web_contents_delegate.h" | 50 #include "content/public/browser/web_contents_delegate.h" |
50 #include "google_apis/gaia/gaia_auth_util.h" | 51 #include "google_apis/gaia/gaia_auth_util.h" |
51 #include "google_apis/gaia/gaia_constants.h" | 52 #include "google_apis/gaia/gaia_constants.h" |
52 #include "grit/chromium_strings.h" | 53 #include "grit/chromium_strings.h" |
53 #include "grit/generated_resources.h" | 54 #include "grit/generated_resources.h" |
54 #include "grit/locale_settings.h" | 55 #include "grit/locale_settings.h" |
(...skipping 743 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
798 void SyncSetupHandler::HandleStartSignin(const base::ListValue* args) { | 799 void SyncSetupHandler::HandleStartSignin(const base::ListValue* args) { |
799 // Should only be called if the user is not already signed in. | 800 // Should only be called if the user is not already signed in. |
800 DCHECK(SigninManagerFactory::GetForProfile(GetProfile())-> | 801 DCHECK(SigninManagerFactory::GetForProfile(GetProfile())-> |
801 GetAuthenticatedUsername().empty()); | 802 GetAuthenticatedUsername().empty()); |
802 OpenSyncSetup(); | 803 OpenSyncSetup(); |
803 } | 804 } |
804 | 805 |
805 void SyncSetupHandler::HandleStopSyncing(const base::ListValue* args) { | 806 void SyncSetupHandler::HandleStopSyncing(const base::ListValue* args) { |
806 if (GetSyncService()) | 807 if (GetSyncService()) |
807 ProfileSyncService::SyncEvent(ProfileSyncService::STOP_FROM_OPTIONS); | 808 ProfileSyncService::SyncEvent(ProfileSyncService::STOP_FROM_OPTIONS); |
809 signin_metrics::LogSignout(signin_metrics::USER_CLICKED_SIGNOUT); | |
808 SigninManagerFactory::GetForProfile(GetProfile())->SignOut(); | 810 SigninManagerFactory::GetForProfile(GetProfile())->SignOut(); |
Evan Stade
2014/06/19 01:55:12
I think you should make SignOut take a parameter (
Mike Lerman
2014/06/19 17:55:48
Done.
| |
809 | 811 |
810 bool delete_profile = false; | 812 bool delete_profile = false; |
811 if (args->GetBoolean(0, &delete_profile) && delete_profile) { | 813 if (args->GetBoolean(0, &delete_profile) && delete_profile) { |
812 web_ui()->CallJavascriptFunction( | 814 web_ui()->CallJavascriptFunction( |
813 "BrowserOptions.deleteCurrentProfile"); | 815 "BrowserOptions.deleteCurrentProfile"); |
814 } | 816 } |
815 } | 817 } |
816 #endif | 818 #endif |
817 | 819 |
818 void SyncSetupHandler::HandleCloseTimeout(const base::ListValue* args) { | 820 void SyncSetupHandler::HandleCloseTimeout(const base::ListValue* args) { |
(...skipping 23 matching lines...) Expand all Loading... | |
842 // state. Note: In order to disable sync across restarts on Chrome OS, we | 844 // state. Note: In order to disable sync across restarts on Chrome OS, we |
843 // must call StopSyncingPermanently(), which suppresses sync startup in | 845 // must call StopSyncingPermanently(), which suppresses sync startup in |
844 // addition to disabling it. | 846 // addition to disabling it. |
845 if (sync_service) { | 847 if (sync_service) { |
846 DVLOG(1) << "Sync setup aborted by user action"; | 848 DVLOG(1) << "Sync setup aborted by user action"; |
847 sync_service->StopSyncingPermanently(); | 849 sync_service->StopSyncingPermanently(); |
848 #if !defined(OS_CHROMEOS) | 850 #if !defined(OS_CHROMEOS) |
849 // Sign out the user on desktop Chrome if they click cancel during | 851 // Sign out the user on desktop Chrome if they click cancel during |
850 // initial setup. | 852 // initial setup. |
851 // TODO(rsimha): Revisit this for M30. See http://crbug.com/252049. | 853 // TODO(rsimha): Revisit this for M30. See http://crbug.com/252049. |
852 if (sync_service->FirstSetupInProgress()) | 854 if (sync_service->FirstSetupInProgress()) { |
855 signin_metrics::LogSignout(signin_metrics::ABORT_SIGNIN); | |
853 SigninManagerFactory::GetForProfile(GetProfile())->SignOut(); | 856 SigninManagerFactory::GetForProfile(GetProfile())->SignOut(); |
857 } | |
854 #endif | 858 #endif |
855 } | 859 } |
856 } | 860 } |
857 | 861 |
858 GetLoginUIService()->LoginUIClosed(this); | 862 GetLoginUIService()->LoginUIClosed(this); |
859 } | 863 } |
860 | 864 |
861 // Alert the sync service anytime the sync setup dialog is closed. This can | 865 // Alert the sync service anytime the sync setup dialog is closed. This can |
862 // happen due to the user clicking the OK or Cancel button, or due to the | 866 // happen due to the user clicking the OK or Cancel button, or due to the |
863 // dialog being closed by virtue of sync being disabled in the background. | 867 // dialog being closed by virtue of sync being disabled in the background. |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
944 | 948 |
945 LoginUIService* service = GetLoginUIService(); | 949 LoginUIService* service = GetLoginUIService(); |
946 DCHECK(service); | 950 DCHECK(service); |
947 service->current_login_ui()->FocusUI(); | 951 service->current_login_ui()->FocusUI(); |
948 return true; | 952 return true; |
949 } | 953 } |
950 | 954 |
951 LoginUIService* SyncSetupHandler::GetLoginUIService() const { | 955 LoginUIService* SyncSetupHandler::GetLoginUIService() const { |
952 return LoginUIServiceFactory::GetForProfile(GetProfile()); | 956 return LoginUIServiceFactory::GetForProfile(GetProfile()); |
953 } | 957 } |
OLD | NEW |