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 928 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
939 } | 939 } |
940 #endif | 940 #endif |
941 } | 941 } |
942 | 942 |
943 Profile* SyncSetupHandler::GetProfile() const { | 943 Profile* SyncSetupHandler::GetProfile() const { |
944 return Profile::FromWebUI(web_ui()); | 944 return Profile::FromWebUI(web_ui()); |
945 } | 945 } |
946 | 946 |
947 ProfileSyncService* SyncSetupHandler::GetSyncService() const { | 947 ProfileSyncService* SyncSetupHandler::GetSyncService() const { |
948 Profile* profile = GetProfile(); | 948 Profile* profile = GetProfile(); |
949 return profile->IsSyncAccessible() ? | 949 ProfileSyncService* service = NULL; |
950 ProfileSyncServiceFactory::GetForProfile(GetProfile()) : NULL; | 950 if (profile->IsSyncAccessible()) |
| 951 service = ProfileSyncServiceFactory::GetForProfile(GetProfile()); |
| 952 if (service->IsManaged()) |
| 953 service = NULL; |
| 954 return service; |
951 } | 955 } |
952 | 956 |
953 void SyncSetupHandler::SigninSuccess() { | 957 void SyncSetupHandler::SigninSuccess() { |
954 ProfileSyncService* service = GetSyncService(); | 958 ProfileSyncService* service = GetSyncService(); |
955 DCHECK(!service || service->sync_initialized()); | 959 DCHECK(!service || service->sync_initialized()); |
956 // Stop a timer to handle timeout in waiting for checking network connection. | 960 // Stop a timer to handle timeout in waiting for checking network connection. |
957 backend_start_timer_.reset(); | 961 backend_start_timer_.reset(); |
958 | 962 |
959 // If we have signed in while sync is already setup, it must be due to some | 963 // If we have signed in while sync is already setup, it must be due to some |
960 // kind of re-authentication flow. In that case, just close the signin dialog | 964 // kind of re-authentication flow. In that case, just close the signin dialog |
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1140 void SyncSetupHandler::HandleCloseTimeout(const ListValue* args) { | 1144 void SyncSetupHandler::HandleCloseTimeout(const ListValue* args) { |
1141 CloseSyncSetup(); | 1145 CloseSyncSetup(); |
1142 } | 1146 } |
1143 | 1147 |
1144 void SyncSetupHandler::CloseSyncSetup() { | 1148 void SyncSetupHandler::CloseSyncSetup() { |
1145 // TODO(atwilson): Move UMA tracking of signin events out of sync module. | 1149 // TODO(atwilson): Move UMA tracking of signin events out of sync module. |
1146 ProfileSyncService* sync_service = GetSyncService(); | 1150 ProfileSyncService* sync_service = GetSyncService(); |
1147 if (IsActiveLogin()) { | 1151 if (IsActiveLogin()) { |
1148 // Don't log a cancel event if the sync setup dialog is being | 1152 // Don't log a cancel event if the sync setup dialog is being |
1149 // automatically closed due to an auth error. | 1153 // automatically closed due to an auth error. |
1150 if ((!sync_service || !sync_service->HasSyncSetupCompleted()) && | 1154 if (!sync_service || (!sync_service->HasSyncSetupCompleted() && |
1151 sync_service->GetAuthError().state() == GoogleServiceAuthError::NONE) { | 1155 sync_service->GetAuthError().state() == GoogleServiceAuthError::NONE)) { |
1152 if (signin_tracker_.get()) { | 1156 if (signin_tracker_.get()) { |
1153 ProfileSyncService::SyncEvent( | 1157 ProfileSyncService::SyncEvent( |
1154 ProfileSyncService::CANCEL_DURING_SIGNON); | 1158 ProfileSyncService::CANCEL_DURING_SIGNON); |
1155 } else if (configuring_sync_) { | 1159 } else if (configuring_sync_) { |
1156 ProfileSyncService::SyncEvent( | 1160 ProfileSyncService::SyncEvent( |
1157 ProfileSyncService::CANCEL_DURING_CONFIGURE); | 1161 ProfileSyncService::CANCEL_DURING_CONFIGURE); |
1158 } else { | 1162 } else { |
1159 ProfileSyncService::SyncEvent( | 1163 ProfileSyncService::SyncEvent( |
1160 ProfileSyncService::CANCEL_FROM_SIGNON_WITHOUT_AUTH); | 1164 ProfileSyncService::CANCEL_FROM_SIGNON_WITHOUT_AUTH); |
1161 } | 1165 } |
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1373 return LoginUIServiceFactory::GetForProfile(GetProfile()); | 1377 return LoginUIServiceFactory::GetForProfile(GetProfile()); |
1374 } | 1378 } |
1375 | 1379 |
1376 void SyncSetupHandler::CloseOverlay() { | 1380 void SyncSetupHandler::CloseOverlay() { |
1377 // Stop a timer to handle timeout in waiting for sync setup. | 1381 // Stop a timer to handle timeout in waiting for sync setup. |
1378 backend_start_timer_.reset(); | 1382 backend_start_timer_.reset(); |
1379 | 1383 |
1380 CloseSyncSetup(); | 1384 CloseSyncSetup(); |
1381 web_ui()->CallJavascriptFunction("OptionsPage.closeOverlay"); | 1385 web_ui()->CallJavascriptFunction("OptionsPage.closeOverlay"); |
1382 } | 1386 } |
OLD | NEW |