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" |
11 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
12 #include "base/json/json_reader.h" | 12 #include "base/json/json_reader.h" |
13 #include "base/json/json_writer.h" | 13 #include "base/json/json_writer.h" |
14 #include "base/utf_string_conversions.h" | 14 #include "base/utf_string_conversions.h" |
15 #include "base/values.h" | 15 #include "base/values.h" |
16 #include "chrome/app/chrome_command_ids.h" | 16 #include "chrome/app/chrome_command_ids.h" |
17 #include "chrome/browser/google/google_util.h" | 17 #include "chrome/browser/google/google_util.h" |
| 18 #include "chrome/browser/lifetime/application_lifetime.h" |
18 #include "chrome/browser/profiles/profile.h" | 19 #include "chrome/browser/profiles/profile.h" |
19 #include "chrome/browser/profiles/profile_info_cache.h" | 20 #include "chrome/browser/profiles/profile_info_cache.h" |
20 #include "chrome/browser/profiles/profile_manager.h" | 21 #include "chrome/browser/profiles/profile_manager.h" |
21 #include "chrome/browser/profiles/profile_metrics.h" | 22 #include "chrome/browser/profiles/profile_metrics.h" |
22 #include "chrome/browser/signin/signin_manager.h" | 23 #include "chrome/browser/signin/signin_manager.h" |
23 #include "chrome/browser/signin/signin_manager_factory.h" | 24 #include "chrome/browser/signin/signin_manager_factory.h" |
24 #include "chrome/browser/sync/profile_sync_service.h" | 25 #include "chrome/browser/sync/profile_sync_service.h" |
25 #include "chrome/browser/sync/profile_sync_service_factory.h" | 26 #include "chrome/browser/sync/profile_sync_service_factory.h" |
26 #include "chrome/browser/ui/browser.h" | |
27 #include "chrome/browser/ui/browser_list.h" | |
28 #include "chrome/browser/ui/webui/signin/login_ui_service.h" | 27 #include "chrome/browser/ui/webui/signin/login_ui_service.h" |
29 #include "chrome/browser/ui/webui/signin/login_ui_service_factory.h" | 28 #include "chrome/browser/ui/webui/signin/login_ui_service_factory.h" |
30 #include "chrome/browser/ui/webui/sync_promo/sync_promo_ui.h" | 29 #include "chrome/browser/ui/webui/sync_promo/sync_promo_ui.h" |
31 #include "chrome/common/chrome_switches.h" | 30 #include "chrome/common/chrome_switches.h" |
32 #include "chrome/common/net/gaia/gaia_constants.h" | 31 #include "chrome/common/net/gaia/gaia_constants.h" |
33 #include "chrome/common/url_constants.h" | 32 #include "chrome/common/url_constants.h" |
34 #include "content/public/browser/render_view_host.h" | 33 #include "content/public/browser/render_view_host.h" |
35 #include "content/public/browser/render_view_host_delegate.h" | 34 #include "content/public/browser/render_view_host_delegate.h" |
36 #include "content/public/browser/web_contents.h" | 35 #include "content/public/browser/web_contents.h" |
37 #include "grit/chromium_strings.h" | 36 #include "grit/chromium_strings.h" |
(...skipping 773 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
811 | 810 |
812 void SyncSetupHandler::HandleShowErrorUI(const ListValue* args) { | 811 void SyncSetupHandler::HandleShowErrorUI(const ListValue* args) { |
813 DCHECK(!configuring_sync_); | 812 DCHECK(!configuring_sync_); |
814 | 813 |
815 ProfileSyncService* service = GetSyncService(); | 814 ProfileSyncService* service = GetSyncService(); |
816 DCHECK(service); | 815 DCHECK(service); |
817 | 816 |
818 #if defined(OS_CHROMEOS) | 817 #if defined(OS_CHROMEOS) |
819 if (service->GetAuthError().state() != GoogleServiceAuthError::NONE) { | 818 if (service->GetAuthError().state() != GoogleServiceAuthError::NONE) { |
820 DLOG(INFO) << "Signing out the user to fix a sync error."; | 819 DLOG(INFO) << "Signing out the user to fix a sync error."; |
821 BrowserList::GetLastActive()->ExecuteCommand(IDC_EXIT); | 820 browser::AttemptUserExit(); |
822 return; | 821 return; |
823 } | 822 } |
824 #endif | 823 #endif |
825 | 824 |
826 // Bring up the existing wizard, or just display it on this page. | 825 // Bring up the existing wizard, or just display it on this page. |
827 if (!FocusExistingWizardIfPresent()) | 826 if (!FocusExistingWizardIfPresent()) |
828 OpenSyncSetup(false); | 827 OpenSyncSetup(false); |
829 } | 828 } |
830 | 829 |
831 void SyncSetupHandler::HandleShowSetupUI(const ListValue* args) { | 830 void SyncSetupHandler::HandleShowSetupUI(const ListValue* args) { |
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1004 if (i != current_profile_index && AreUserNamesEqual( | 1003 if (i != current_profile_index && AreUserNamesEqual( |
1005 cache.GetUserNameOfProfileAtIndex(i), username_utf16)) { | 1004 cache.GetUserNameOfProfileAtIndex(i), username_utf16)) { |
1006 *error_message = l10n_util::GetStringUTF16( | 1005 *error_message = l10n_util::GetStringUTF16( |
1007 IDS_SYNC_USER_NAME_IN_USE_ERROR); | 1006 IDS_SYNC_USER_NAME_IN_USE_ERROR); |
1008 return false; | 1007 return false; |
1009 } | 1008 } |
1010 } | 1009 } |
1011 | 1010 |
1012 return true; | 1011 return true; |
1013 } | 1012 } |
OLD | NEW |