| 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/singleton_tabs.h" | 35 #include "chrome/browser/ui/singleton_tabs.h" |
| 36 #include "chrome/browser/ui/sync/signin_histogram.h" | 36 #include "chrome/browser/ui/sync/signin_histogram.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/pref_names.h" | 40 #include "chrome/common/pref_names.h" |
| 41 #include "chrome/common/url_constants.h" | 41 #include "chrome/common/url_constants.h" |
| 42 #include "components/google/core/browser/google_util.h" | 42 #include "components/google/core/browser/google_util.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); |
| 808 SigninManagerFactory::GetForProfile(GetProfile())->SignOut(); | 809 SigninManagerFactory::GetForProfile(GetProfile())->SignOut( |
| 810 signin_metrics::USER_CLICKED_SIGNOUT_SETTINGS); |
| 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 // Note: In order to disable sync across restarts on Chrome OS, | 844 // Note: In order to disable sync across restarts on Chrome OS, |
| 843 // we must call StopSyncingPermanently(), which suppresses sync startup | 845 // we must call StopSyncingPermanently(), which suppresses sync startup |
| 844 // in addition to disabling it. | 846 // in 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()) { |
| 853 SigninManagerFactory::GetForProfile(GetProfile())->SignOut(); | 855 SigninManagerFactory::GetForProfile(GetProfile())->SignOut( |
| 856 signin_metrics::ABORT_SIGNIN); |
| 857 } |
| 854 #endif | 858 #endif |
| 855 } | 859 } |
| 856 } | 860 } |
| 857 } | 861 } |
| 858 | 862 |
| 859 GetLoginUIService()->LoginUIClosed(this); | 863 GetLoginUIService()->LoginUIClosed(this); |
| 860 } | 864 } |
| 861 | 865 |
| 862 // Alert the sync service anytime the sync setup dialog is closed. This can | 866 // Alert the sync service anytime the sync setup dialog is closed. This can |
| 863 // happen due to the user clicking the OK or Cancel button, or due to the | 867 // happen due to the user clicking the OK or Cancel button, or due to the |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 945 | 949 |
| 946 LoginUIService* service = GetLoginUIService(); | 950 LoginUIService* service = GetLoginUIService(); |
| 947 DCHECK(service); | 951 DCHECK(service); |
| 948 service->current_login_ui()->FocusUI(); | 952 service->current_login_ui()->FocusUI(); |
| 949 return true; | 953 return true; |
| 950 } | 954 } |
| 951 | 955 |
| 952 LoginUIService* SyncSetupHandler::GetLoginUIService() const { | 956 LoginUIService* SyncSetupHandler::GetLoginUIService() const { |
| 953 return LoginUIServiceFactory::GetForProfile(GetProfile()); | 957 return LoginUIServiceFactory::GetForProfile(GetProfile()); |
| 954 } | 958 } |
| OLD | NEW |