OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/sync/test/integration/profile_sync_service_harness.h" | 5 #include "chrome/browser/sync/test/integration/profile_sync_service_harness.h" |
6 | 6 |
7 #include <cstddef> | 7 #include <cstddef> |
8 #include <iterator> | 8 #include <iterator> |
9 #include <ostream> | 9 #include <ostream> |
10 #include <sstream> | 10 #include <sstream> |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
148 << "SetupSync should not be used for legacy supervised users."; | 148 << "SetupSync should not be used for legacy supervised users."; |
149 | 149 |
150 // Initialize the sync client's profile sync service object. | 150 // Initialize the sync client's profile sync service object. |
151 if (service() == NULL) { | 151 if (service() == NULL) { |
152 LOG(ERROR) << "SetupSync(): service() is null."; | 152 LOG(ERROR) << "SetupSync(): service() is null."; |
153 return false; | 153 return false; |
154 } | 154 } |
155 | 155 |
156 // Tell the sync service that setup is in progress so we don't start syncing | 156 // Tell the sync service that setup is in progress so we don't start syncing |
157 // until we've finished configuration. | 157 // until we've finished configuration. |
158 service()->SetSetupInProgress(true); | 158 sync_blocker_ = service()->GetSetupInProgressHandle(); |
159 | 159 |
160 DCHECK(!username_.empty()); | 160 DCHECK(!username_.empty()); |
161 if (signin_type_ == SigninType::UI_SIGNIN) { | 161 if (signin_type_ == SigninType::UI_SIGNIN) { |
162 Browser* browser = chrome::FindBrowserWithProfile(profile_); | 162 Browser* browser = chrome::FindBrowserWithProfile(profile_); |
163 DCHECK(browser); | 163 DCHECK(browser); |
164 if (!login_ui_test_utils::SignInWithUI(browser, username_, password_)) { | 164 if (!login_ui_test_utils::SignInWithUI(browser, username_, password_)) { |
165 LOG(ERROR) << "Could not sign in to GAIA servers."; | 165 LOG(ERROR) << "Could not sign in to GAIA servers."; |
166 return false; | 166 return false; |
167 } | 167 } |
168 } else if (signin_type_ == SigninType::FAKE_SIGNIN) { | 168 } else if (signin_type_ == SigninType::FAKE_SIGNIN) { |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
298 std::string ProfileSyncServiceHarness::GenerateFakeOAuth2RefreshTokenString() { | 298 std::string ProfileSyncServiceHarness::GenerateFakeOAuth2RefreshTokenString() { |
299 return base::StringPrintf("oauth2_refresh_token_%d", | 299 return base::StringPrintf("oauth2_refresh_token_%d", |
300 ++oauth2_refesh_token_number_); | 300 ++oauth2_refesh_token_number_); |
301 } | 301 } |
302 | 302 |
303 bool ProfileSyncServiceHarness::IsSyncDisabled() const { | 303 bool ProfileSyncServiceHarness::IsSyncDisabled() const { |
304 return !service()->IsSetupInProgress() && !service()->IsFirstSetupComplete(); | 304 return !service()->IsSetupInProgress() && !service()->IsFirstSetupComplete(); |
305 } | 305 } |
306 | 306 |
307 void ProfileSyncServiceHarness::FinishSyncSetup() { | 307 void ProfileSyncServiceHarness::FinishSyncSetup() { |
308 service()->SetSetupInProgress(false); | 308 sync_blocker_.reset(); |
309 service()->SetFirstSetupComplete(); | 309 service()->SetFirstSetupComplete(); |
310 } | 310 } |
311 | 311 |
312 SyncSessionSnapshot ProfileSyncServiceHarness::GetLastSessionSnapshot() const { | 312 SyncSessionSnapshot ProfileSyncServiceHarness::GetLastSessionSnapshot() const { |
313 DCHECK(service() != NULL) << "Sync service has not yet been set up."; | 313 DCHECK(service() != NULL) << "Sync service has not yet been set up."; |
314 if (service()->IsSyncActive()) { | 314 if (service()->IsSyncActive()) { |
315 return service()->GetLastSessionSnapshot(); | 315 return service()->GetLastSessionSnapshot(); |
316 } | 316 } |
317 return SyncSessionSnapshot(); | 317 return SyncSessionSnapshot(); |
318 } | 318 } |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
466 | 466 |
467 std::string ProfileSyncServiceHarness::GetServiceStatus() { | 467 std::string ProfileSyncServiceHarness::GetServiceStatus() { |
468 std::unique_ptr<base::DictionaryValue> value( | 468 std::unique_ptr<base::DictionaryValue> value( |
469 sync_driver::sync_ui_util::ConstructAboutInformation( | 469 sync_driver::sync_ui_util::ConstructAboutInformation( |
470 service(), service()->signin(), chrome::GetChannel())); | 470 service(), service()->signin(), chrome::GetChannel())); |
471 std::string service_status; | 471 std::string service_status; |
472 base::JSONWriter::WriteWithOptions( | 472 base::JSONWriter::WriteWithOptions( |
473 *value, base::JSONWriter::OPTIONS_PRETTY_PRINT, &service_status); | 473 *value, base::JSONWriter::OPTIONS_PRETTY_PRINT, &service_status); |
474 return service_status; | 474 return service_status; |
475 } | 475 } |
OLD | NEW |