Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(104)

Side by Side Diff: chrome/browser/sync/profile_sync_service.cc

Issue 9956097: suppress user/password dialog when re-enabling sync (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: More OS_CHROMEOS guard for compilation. Created 8 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/sync/profile_sync_service.h" 5 #include "chrome/browser/sync/profile_sync_service.h"
6 6
7 #include <cstddef> 7 #include <cstddef>
8 #include <map> 8 #include <map>
9 #include <set> 9 #include <set>
10 #include <utility> 10 #include <utility>
(...skipping 15 matching lines...) Expand all
26 #include "chrome/browser/defaults.h" 26 #include "chrome/browser/defaults.h"
27 #include "chrome/browser/net/chrome_cookie_notification_details.h" 27 #include "chrome/browser/net/chrome_cookie_notification_details.h"
28 #include "chrome/browser/profiles/profile.h" 28 #include "chrome/browser/profiles/profile.h"
29 #include "chrome/browser/signin/signin_manager.h" 29 #include "chrome/browser/signin/signin_manager.h"
30 #include "chrome/browser/signin/signin_manager_factory.h" 30 #include "chrome/browser/signin/signin_manager_factory.h"
31 #include "chrome/browser/signin/token_service.h" 31 #include "chrome/browser/signin/token_service.h"
32 #include "chrome/browser/signin/token_service_factory.h" 32 #include "chrome/browser/signin/token_service_factory.h"
33 #include "chrome/browser/sync/api/sync_error.h" 33 #include "chrome/browser/sync/api/sync_error.h"
34 #include "chrome/browser/sync/backend_migrator.h" 34 #include "chrome/browser/sync/backend_migrator.h"
35 #include "chrome/browser/sync/glue/change_processor.h" 35 #include "chrome/browser/sync/glue/change_processor.h"
36 #include "chrome/browser/sync/glue/chrome_encryptor.h"
36 #include "chrome/browser/sync/glue/chrome_report_unrecoverable_error.h" 37 #include "chrome/browser/sync/glue/chrome_report_unrecoverable_error.h"
37 #include "chrome/browser/sync/glue/data_type_controller.h" 38 #include "chrome/browser/sync/glue/data_type_controller.h"
38 #include "chrome/browser/sync/glue/session_data_type_controller.h" 39 #include "chrome/browser/sync/glue/session_data_type_controller.h"
39 #include "chrome/browser/sync/glue/session_model_associator.h" 40 #include "chrome/browser/sync/glue/session_model_associator.h"
40 #include "chrome/browser/sync/glue/typed_url_data_type_controller.h" 41 #include "chrome/browser/sync/glue/typed_url_data_type_controller.h"
41 #include "chrome/browser/sync/internal_api/configure_reason.h" 42 #include "chrome/browser/sync/internal_api/configure_reason.h"
42 #include "chrome/browser/sync/internal_api/sync_manager.h" 43 #include "chrome/browser/sync/internal_api/sync_manager.h"
43 #include "chrome/browser/sync/profile_sync_components_factory_impl.h" 44 #include "chrome/browser/sync/profile_sync_components_factory_impl.h"
44 #include "chrome/browser/sync/sync_global_error.h" 45 #include "chrome/browser/sync/sync_global_error.h"
45 #include "chrome/browser/sync/user_selectable_sync_type.h" 46 #include "chrome/browser/sync/user_selectable_sync_type.h"
(...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after
390 // Don't start up multiple times. 391 // Don't start up multiple times.
391 if (backend_.get()) { 392 if (backend_.get()) {
392 DVLOG(1) << "Skipping bringing up backend host."; 393 DVLOG(1) << "Skipping bringing up backend host.";
393 return; 394 return;
394 } 395 }
395 396
396 DCHECK(AreCredentialsAvailable()); 397 DCHECK(AreCredentialsAvailable());
397 398
398 last_synced_time_ = sync_prefs_.GetLastSyncedTime(); 399 last_synced_time_ = sync_prefs_.GetLastSyncedTime();
399 400
401 #if defined(OS_CHROMEOS)
402 std::string bootstrap_token = sync_prefs_.GetEncryptionBootstrapToken();
403 if (bootstrap_token.empty()) {
404 sync_prefs_.SetEncryptionBootstrapToken(
405 sync_prefs_.GetSpareBootstrapToken());
406 }
407 #endif
400 CreateBackend(); 408 CreateBackend();
401 409
402 // Initialize the backend. Every time we start up a new SyncBackendHost, 410 // Initialize the backend. Every time we start up a new SyncBackendHost,
403 // we'll want to start from a fresh SyncDB, so delete any old one that might 411 // we'll want to start from a fresh SyncDB, so delete any old one that might
404 // be there. 412 // be there.
405 InitializeBackend(!HasSyncSetupCompleted()); 413 InitializeBackend(!HasSyncSetupCompleted());
406 414
407 if (!sync_global_error_.get()) { 415 if (!sync_global_error_.get()) {
408 sync_global_error_.reset(new SyncGlobalError(this)); 416 sync_global_error_.reset(new SyncGlobalError(this));
409 GlobalErrorServiceFactory::GetForProfile(profile_)->AddGlobalError( 417 GlobalErrorServiceFactory::GetForProfile(profile_)->AddGlobalError(
(...skipping 654 matching lines...) Expand 10 before | Expand all | Expand 10 after
1064 // Selected type has changed - log it. 1072 // Selected type has changed - log it.
1065 UMA_HISTOGRAM_ENUMERATION( 1073 UMA_HISTOGRAM_ENUMERATION(
1066 "Sync.CustomSync", 1074 "Sync.CustomSync",
1067 user_selectable_types[i], 1075 user_selectable_types[i],
1068 browser_sync::user_selectable_type::SELECTABLE_DATATYPE_COUNT + 1); 1076 browser_sync::user_selectable_type::SELECTABLE_DATATYPE_COUNT + 1);
1069 } 1077 }
1070 } 1078 }
1071 } 1079 }
1072 } 1080 }
1073 1081
1082 #if defined(OS_CHROMEOS)
1083 void ProfileSyncService::RefreshSpareBootstrapToken(
1084 const std::string& passphrase) {
1085 browser_sync::ChromeEncryptor encryptor;
1086 browser_sync::Cryptographer temp_cryptographer(&encryptor);
1087 browser_sync::KeyParams key_params = {"localhost", "dummy", passphrase};
arv (Not doing code reviews) 2012/04/04 17:04:21 I have no idea if this is correct. I would add a c
kochi 2012/04/04 17:29:46 Done.
1088
1089 std::string bootstrap_token;
1090 if (!temp_cryptographer.AddKey(key_params)) {
1091 NOTREACHED() << "Failed to add key to cryptographer.";
1092 }
1093 temp_cryptographer.GetBootstrapToken(&bootstrap_token);
1094 sync_prefs_.SetSpareBootstrapToken(bootstrap_token);
1095 }
1096 #endif
1097
1074 void ProfileSyncService::OnUserChoseDatatypes(bool sync_everything, 1098 void ProfileSyncService::OnUserChoseDatatypes(bool sync_everything,
1075 syncable::ModelTypeSet chosen_types) { 1099 syncable::ModelTypeSet chosen_types) {
1076 if (!backend_.get() && 1100 if (!backend_.get() &&
1077 unrecoverable_error_detected_ == false) { 1101 unrecoverable_error_detected_ == false) {
1078 NOTREACHED(); 1102 NOTREACHED();
1079 return; 1103 return;
1080 } 1104 }
1081 1105
1082 UpdateSelectedTypesHistogram(sync_everything, chosen_types); 1106 UpdateSelectedTypesHistogram(sync_everything, chosen_types);
1083 sync_prefs_.SetKeepEverythingSynced(sync_everything); 1107 sync_prefs_.SetKeepEverythingSynced(sync_everything);
(...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after
1431 content::Details<const GoogleServiceSigninSuccessDetails>( 1455 content::Details<const GoogleServiceSigninSuccessDetails>(
1432 details).ptr(); 1456 details).ptr();
1433 DCHECK(!successful->password.empty()); 1457 DCHECK(!successful->password.empty());
1434 if (!sync_prefs_.IsStartSuppressed()) { 1458 if (!sync_prefs_.IsStartSuppressed()) {
1435 cached_passphrase_ = successful->password; 1459 cached_passphrase_ = successful->password;
1436 // Try to consume the passphrase we just cached. If the sync backend 1460 // Try to consume the passphrase we just cached. If the sync backend
1437 // is not running yet, the passphrase will remain cached until the 1461 // is not running yet, the passphrase will remain cached until the
1438 // backend starts up. 1462 // backend starts up.
1439 ConsumeCachedPassphraseIfPossible(); 1463 ConsumeCachedPassphraseIfPossible();
1440 } 1464 }
1465 #if defined(OS_CHROMEOS)
1466 RefreshSpareBootstrapToken(successful->password);
1467 #endif
1441 if (!sync_initialized() || 1468 if (!sync_initialized() ||
1442 GetAuthError().state() != GoogleServiceAuthError::NONE) { 1469 GetAuthError().state() != GoogleServiceAuthError::NONE) {
1443 // Track the fact that we're still waiting for auth to complete. 1470 // Track the fact that we're still waiting for auth to complete.
1444 is_auth_in_progress_ = true; 1471 is_auth_in_progress_ = true;
1445 } 1472 }
1446 break; 1473 break;
1447 } 1474 }
1448 case chrome::NOTIFICATION_TOKEN_REQUEST_FAILED: { 1475 case chrome::NOTIFICATION_TOKEN_REQUEST_FAILED: {
1449 const TokenService::TokenRequestFailedDetails& token_details = 1476 const TokenService::TokenRequestFailedDetails& token_details =
1450 *(content::Details<const TokenService::TokenRequestFailedDetails>( 1477 *(content::Details<const TokenService::TokenRequestFailedDetails>(
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
1595 // See http://stackoverflow.com/questions/6224121/is-new-this-myclass-undefine d-behaviour-after-directly-calling-the-destru. 1622 // See http://stackoverflow.com/questions/6224121/is-new-this-myclass-undefine d-behaviour-after-directly-calling-the-destru.
1596 ProfileSyncService* old_this = this; 1623 ProfileSyncService* old_this = this;
1597 this->~ProfileSyncService(); 1624 this->~ProfileSyncService();
1598 new(old_this) ProfileSyncService( 1625 new(old_this) ProfileSyncService(
1599 new ProfileSyncComponentsFactoryImpl(profile, 1626 new ProfileSyncComponentsFactoryImpl(profile,
1600 CommandLine::ForCurrentProcess()), 1627 CommandLine::ForCurrentProcess()),
1601 profile, 1628 profile,
1602 signin, 1629 signin,
1603 behavior); 1630 behavior);
1604 } 1631 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698