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

Unified 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: resolve Drew's comments. Created 8 years, 9 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/sync/profile_sync_service.cc
diff --git a/chrome/browser/sync/profile_sync_service.cc b/chrome/browser/sync/profile_sync_service.cc
index 5257b6a8d80ae2b68c6bda3994bf83895148dcf1..410a7b2f11219d252682a05c97764137c21b1993 100644
--- a/chrome/browser/sync/profile_sync_service.cc
+++ b/chrome/browser/sync/profile_sync_service.cc
@@ -40,6 +40,8 @@
#include "chrome/browser/sync/glue/typed_url_data_type_controller.h"
#include "chrome/browser/sync/internal_api/configure_reason.h"
#include "chrome/browser/sync/internal_api/sync_manager.h"
+#include "chrome/browser/sync/internal_api/write_node.h"
+#include "chrome/browser/sync/internal_api/write_transaction.h"
#include "chrome/browser/sync/profile_sync_components_factory_impl.h"
#include "chrome/browser/sync/sync_global_error.h"
#include "chrome/browser/sync/user_selectable_sync_type.h"
@@ -201,6 +203,7 @@ void ProfileSyncService::Initialize() {
}
void ProfileSyncService::TryStart() {
+ LOG(WARNING) << "TryStart";
if (!sync_prefs_.IsStartSuppressed() && AreCredentialsAvailable()) {
if (HasSyncSetupCompleted() || auto_start_enabled_) {
// If sync setup has completed we always start the backend.
@@ -220,6 +223,8 @@ void ProfileSyncService::TryStart() {
// trigger an unrecoverable error.
OnUnrecoverableError(FROM_HERE, "Sync credentials lost.");
}
+ } else {
+ LOG(WARNING) << "TryStart: did nothing.";
}
}
@@ -332,6 +337,7 @@ void ProfileSyncService::InitializeBackend(bool delete_stale_data) {
new browser_sync::BackendUnrecoverableErrorHandler(
MakeWeakHandle(AsWeakPtr())));
+ LOG(WARNING) << "Initializing backend";
backend_->Initialize(
this,
MakeWeakHandle(sync_js_controller_.AsWeakPtr()),
@@ -344,6 +350,7 @@ void ProfileSyncService::InitializeBackend(bool delete_stale_data) {
}
void ProfileSyncService::CreateBackend() {
+ LOG(WARNING) << "CreateBackend";
backend_.reset(
new SyncBackendHost(profile_->GetDebugName(),
profile_, sync_prefs_.AsWeakPtr()));
@@ -619,6 +626,7 @@ void ProfileSyncService::OnDisableDatatype(
void ProfileSyncService::OnBackendInitialized(
const WeakHandle<JsBackend>& js_backend, bool success) {
+ LOG(WARNING) << "OnBackendInitialized() : " << success;
if (!HasSyncSetupCompleted()) {
UMA_HISTOGRAM_BOOLEAN("Sync.BackendInitializeFirstTimeSuccess", success);
} else {
@@ -665,6 +673,7 @@ void ProfileSyncService::OnBackendInitialized(
}
void ProfileSyncService::OnSyncCycleCompleted() {
+ LOG(WARNING) << "OnSyncCycleCompleted";
UpdateLastSyncedTime();
if (GetSessionModelAssociator()) {
// Trigger garbage collection of old sessions now that we've downloaded
@@ -777,10 +786,12 @@ GoogleServiceAuthError ConnectionStatusToAuthError(
void ProfileSyncService::OnConnectionStatusChange(
sync_api::ConnectionStatus status) {
+ LOG(WARNING) << "OnConnectionStatusChange";
UpdateAuthErrorState(ConnectionStatusToAuthError(status));
}
void ProfileSyncService::OnStopSyncingPermanently() {
+ LOG(WARNING) << "OnStopSyncingPermanently";
UpdateAuthErrorState(
GoogleServiceAuthError(GoogleServiceAuthError::SERVICE_UNAVAILABLE));
sync_prefs_.SetStartSuppressed(true);
@@ -788,6 +799,7 @@ void ProfileSyncService::OnStopSyncingPermanently() {
}
void ProfileSyncService::OnClearServerDataTimeout() {
+ LOG(WARNING) << "OnClearServerDataTimeout";
if (clear_server_data_state_ != CLEAR_SUCCEEDED &&
clear_server_data_state_ != CLEAR_FAILED) {
clear_server_data_state_ = CLEAR_FAILED;
@@ -796,6 +808,7 @@ void ProfileSyncService::OnClearServerDataTimeout() {
}
void ProfileSyncService::OnClearServerDataFailed() {
+ LOG(WARNING) << "OnClearServerDataFailed";
clear_server_data_timer_.Stop();
// Only once clear has succeeded there is no longer a need to transition to
@@ -809,6 +822,7 @@ void ProfileSyncService::OnClearServerDataFailed() {
}
void ProfileSyncService::OnClearServerDataSucceeded() {
+ LOG(WARNING) << "OnClearServerDataSucceeded";
clear_server_data_timer_.Stop();
// Even if the timout fired, we still transition to the succeeded state as
@@ -822,6 +836,7 @@ void ProfileSyncService::OnClearServerDataSucceeded() {
void ProfileSyncService::OnPassphraseRequired(
sync_api::PassphraseRequiredReason reason,
const sync_pb::EncryptedData& pending_keys) {
+ LOG(WARNING) << "OnPassphraseRequired";
DCHECK(backend_.get());
DCHECK(backend_->IsNigoriEnabled());
@@ -841,6 +856,7 @@ void ProfileSyncService::OnPassphraseRequired(
}
void ProfileSyncService::OnPassphraseAccepted() {
+ LOG(WARNING) << "OnPassphraseAccepted";
DVLOG(1) << "Received OnPassphraseAccepted.";
// If we are not using an explicit passphrase, and we have a cache of the gaia
// password, use it for encryption at this point.
@@ -879,6 +895,7 @@ void ProfileSyncService::OnEncryptedTypesChanged(
}
void ProfileSyncService::OnEncryptionComplete() {
+ LOG(WARNING) << "OnEncryptionComplete";
DVLOG(1) << "Encryption complete";
if (encryption_pending_ && encrypt_everything_) {
encryption_pending_ = false;
@@ -899,6 +916,7 @@ void ProfileSyncService::OnMigrationNeededForTypes(
}
void ProfileSyncService::OnActionableError(const SyncProtocolError& error) {
+ LOG(WARNING) << "OnActionableError";
last_actionable_error_ = error;
DCHECK_NE(last_actionable_error_.action,
browser_sync::UNKNOWN_ACTION);
@@ -1071,6 +1089,26 @@ void ProfileSyncService::UpdateSelectedTypesHistogram(
}
}
+void ProfileSyncService::RefreshSpareBootstrapToken(
+ const std::string& passphrase) {
+ // All accesses to the cryptographer are protected by a transaction.
+ sync_api::WriteTransaction trans(FROM_HERE, GetUserShare());
Andrew T Wilson (Slow) 2012/04/03 22:22:33 I think we want to create our own cryptographer he
kochi 2012/04/03 23:21:48 Done as Nicolas suggested. On 2012/04/03 22:22:33
+ browser_sync::Cryptographer* cryptographer = trans.GetCryptographer();
+ browser_sync::KeyParams key_params = {"localhost", "dummy", passphrase};
+ sync_api::WriteNode node(&trans);
+ if (!node.InitByTagLookup(browser_sync::kNigoriTag)) {
Andrew T Wilson (Slow) 2012/04/03 22:22:33 We don't need a real nigori node here - we can cre
kochi 2012/04/03 23:21:48 Done as Nicolas suggested. On 2012/04/03 22:22:33,
+ NOTREACHED();
+ return;
+ }
+
+ std::string bootstrap_token;
+ if (!cryptographer->AddKey(key_params)) {
+ NOTREACHED() << "Failed to add key to cryptographer.";
+ }
+ cryptographer->GetBootstrapToken(&bootstrap_token);
+ sync_prefs_.SetSpareBootstrapToken(bootstrap_token);
+}
+
void ProfileSyncService::OnUserChoseDatatypes(bool sync_everything,
syncable::ModelTypeSet chosen_types) {
if (!backend_.get() &&
@@ -1429,6 +1467,7 @@ void ProfileSyncService::Observe(int type,
// backend starts up.
ConsumeCachedPassphraseIfPossible();
}
+ RefreshSpareBootstrapToken(successful->password);
if (!sync_initialized() ||
GetAuthError().state() != GoogleServiceAuthError::NONE) {
// Track the fact that we're still waiting for auth to complete.
@@ -1437,6 +1476,7 @@ void ProfileSyncService::Observe(int type,
break;
}
case chrome::NOTIFICATION_TOKEN_REQUEST_FAILED: {
+ LOG(WARNING) << "Got NOTIFICATION_TOKEN_REQUEST_FAILED";
const TokenService::TokenRequestFailedDetails& token_details =
*(content::Details<const TokenService::TokenRequestFailedDetails>(
details).ptr());
@@ -1448,6 +1488,7 @@ void ProfileSyncService::Observe(int type,
break;
}
case chrome::NOTIFICATION_TOKEN_AVAILABLE: {
+ LOG(WARNING) << "Got NOTIFICATION_TOKEN_AVAILABLE";
const TokenService::TokenAvailableDetails& token_details =
*(content::Details<const TokenService::TokenAvailableDetails>(
details).ptr());
@@ -1461,6 +1502,7 @@ void ProfileSyncService::Observe(int type,
break;
}
case chrome::NOTIFICATION_TOKEN_LOADING_FINISHED: {
+ LOG(WARNING) << "Got NOTIFICATION_TOKEN_LOADING_FINISHED";
// This notification gets fired when TokenService loads the tokens
// from storage.
if (AreCredentialsAvailable()) {
@@ -1535,9 +1577,15 @@ void ProfileSyncService::StopAndSuppress() {
ShutdownImpl(false);
}
-void ProfileSyncService::UnsuppressAndStart() {
+void ProfileSyncService::Unsuppress() {
+ LOG(WARNING) << "Unsuppress()";
Andrew T Wilson (Slow) 2012/04/03 22:22:33 See previous comment - not sure if we should break
kochi 2012/04/03 23:21:48 Done.
DCHECK(profile_);
sync_prefs_.SetStartSuppressed(false);
+}
+
+void ProfileSyncService::UnsuppressAndStart() {
+ LOG(WARNING) << "UnsuppressAndStart()";
+ Unsuppress();
// Set username in SigninManager, as SigninManager::OnGetUserInfoSuccess
// is never called for some clients.
if (signin_ && signin_->GetAuthenticatedUsername().empty()) {

Powered by Google App Engine
This is Rietveld 408576698