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

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

Issue 7466024: [Sync] Support receiving early passphrase required information in Sync UI. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Comments addressed + fix unit test Created 9 years, 5 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
« no previous file with comments | « chrome/browser/sync/engine/syncapi.cc ('k') | chrome/browser/sync/sync_setup_flow.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 <stddef.h> 7 #include <stddef.h>
8 #include <map> 8 #include <map>
9 #include <ostream> 9 #include <ostream>
10 #include <set> 10 #include <set>
(...skipping 707 matching lines...) Expand 10 before | Expand all | Expand 10 after
718 DCHECK(backend_.get()); 718 DCHECK(backend_.get());
719 DCHECK(backend_->IsNigoriEnabled()); 719 DCHECK(backend_->IsNigoriEnabled());
720 720
721 // TODO(lipalani) : add this check to other locations as well. 721 // TODO(lipalani) : add this check to other locations as well.
722 if (unrecoverable_error_detected_) { 722 if (unrecoverable_error_detected_) {
723 // When unrecoverable error is detected we post a task to shutdown the 723 // When unrecoverable error is detected we post a task to shutdown the
724 // backend. The task might not have executed yet. 724 // backend. The task might not have executed yet.
725 return; 725 return;
726 } 726 }
727 727
728 VLOG(1) << "Passphrase required with reason: "
729 << sync_api::PassphraseRequiredReasonToString(reason);
728 passphrase_required_reason_ = reason; 730 passphrase_required_reason_ = reason;
729 731
730 // We will skip the passphrase prompt and suppress the warning if the 732 // We will skip the passphrase prompt and suppress the warning if the
731 // passphrase is needed for decryption but the user is not syncing an 733 // passphrase is needed for decryption but the user is not syncing an
732 // encrypted data type on this machine. Otherwise we look for one. 734 // encrypted data type on this machine. Otherwise we look for one.
733 if (!IsEncryptedDatatypeEnabled() && IsPassphraseRequiredForDecryption()) { 735 if (!IsEncryptedDatatypeEnabled() && IsPassphraseRequiredForDecryption()) {
734 VLOG(1) << "Not decrypting and no encrypted datatypes enabled" 736 VLOG(1) << "Not decrypting and no encrypted datatypes enabled"
735 << ", accepted passphrase."; 737 << ", accepted passphrase.";
736 OnPassphraseAccepted(); 738 OnPassphraseAccepted();
737 } 739 }
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
771 // this time. 773 // this time.
772 syncable::ModelTypeSet types; 774 syncable::ModelTypeSet types;
773 GetPreferredDataTypes(&types); 775 GetPreferredDataTypes(&types);
774 776
775 // Reset passphrase_required_reason_ before configuring the DataTypeManager 777 // Reset passphrase_required_reason_ before configuring the DataTypeManager
776 // since we know we no longer require the passphrase. 778 // since we know we no longer require the passphrase.
777 passphrase_required_reason_ = sync_api::REASON_PASSPHRASE_NOT_REQUIRED; 779 passphrase_required_reason_ = sync_api::REASON_PASSPHRASE_NOT_REQUIRED;
778 780
779 if (data_type_manager_.get()) { 781 if (data_type_manager_.get()) {
780 // Unblock the data type manager if necessary. 782 // Unblock the data type manager if necessary.
783 // This will always trigger a SYNC_CONFIGURE_DONE on completion, which will
784 // step the UI wizard into DONE state (even if no datatypes have changed).
781 data_type_manager_->Configure(types, 785 data_type_manager_->Configure(types,
782 sync_api::CONFIGURE_REASON_RECONFIGURATION); 786 sync_api::CONFIGURE_REASON_RECONFIGURATION);
783 } 787 }
784 788
785 NotifyObservers(); 789 NotifyObservers();
786
787 // TODO(tim): We shouldn't call this if !HasSyncSetupCompleted and the user
788 // isn't actually at the ENTER_PASSPHRASE screen. It results in a
789 // LOG(WARNING) currently.
790 wizard_.Step(SyncSetupWizard::DONE);
791 } 790 }
792 791
793 void ProfileSyncService::OnEncryptionComplete( 792 void ProfileSyncService::OnEncryptionComplete(
794 const syncable::ModelTypeSet& encrypted_types) { 793 const syncable::ModelTypeSet& encrypted_types) {
795 NotifyObservers(); 794 NotifyObservers();
796 } 795 }
797 796
798 void ProfileSyncService::OnMigrationNeededForTypes( 797 void ProfileSyncService::OnMigrationNeededForTypes(
799 const syncable::ModelTypeSet& types) { 798 const syncable::ModelTypeSet& types) {
800 DCHECK(backend_initialized_); 799 DCHECK(backend_initialized_);
(...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after
1107 1106
1108 // We create the migrator at the same time. 1107 // We create the migrator at the same time.
1109 migrator_.reset( 1108 migrator_.reset(
1110 new browser_sync::BackendMigrator(this, data_type_manager_.get())); 1109 new browser_sync::BackendMigrator(this, data_type_manager_.get()));
1111 } 1110 }
1112 1111
1113 syncable::ModelTypeSet types; 1112 syncable::ModelTypeSet types;
1114 GetPreferredDataTypes(&types); 1113 GetPreferredDataTypes(&types);
1115 if (IsPassphraseRequiredForDecryption()) { 1114 if (IsPassphraseRequiredForDecryption()) {
1116 if (IsEncryptedDatatypeEnabled()) { 1115 if (IsEncryptedDatatypeEnabled()) {
1117 // We need a passphrase still. Prompt the user for a passphrase, and 1116 // We need a passphrase still. We don't bother to attempt to configure
1118 // DataTypeManager::Configure() will get called once the passphrase is 1117 // until we receive an OnPassphraseAccepted (which triggers a configure).
1119 // accepted. 1118 VLOG(1) << "ProfileSyncService::ConfigureDataTypeManager bailing out "
1120 VLOG(0) << "ProfileSyncService::ConfigureDataTypeManager bailing out "
1121 << "because a passphrase required"; 1119 << "because a passphrase required";
1122 OnPassphraseRequired(passphrase_required_reason_);
1123 return; 1120 return;
1124 } else { 1121 } else {
1125 // We've been informed that a passphrase is required for decryption, but 1122 // We've been informed that a passphrase is required for decryption, but
1126 // now there are no encrypted data types enabled, so change the value of 1123 // now there are no encrypted data types enabled, so change the value of
1127 // passphrase_required_reason_ to its default value. (NotifyObservers() 1124 // passphrase_required_reason_ to its default value. (NotifyObservers()
1128 // will be called when configuration completes). 1125 // will be called when configuration completes).
1129 passphrase_required_reason_ = sync_api::REASON_PASSPHRASE_NOT_REQUIRED; 1126 passphrase_required_reason_ = sync_api::REASON_PASSPHRASE_NOT_REQUIRED;
1130 } 1127 }
1131 } 1128 }
1132 1129
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
1198 ChangeProcessor* change_processor) { 1195 ChangeProcessor* change_processor) {
1199 if (!backend_.get()) 1196 if (!backend_.get())
1200 return; 1197 return;
1201 backend_->DeactivateDataType(data_type_controller, change_processor); 1198 backend_->DeactivateDataType(data_type_controller, change_processor);
1202 } 1199 }
1203 1200
1204 void ProfileSyncService::SetPassphrase(const std::string& passphrase, 1201 void ProfileSyncService::SetPassphrase(const std::string& passphrase,
1205 bool is_explicit, 1202 bool is_explicit,
1206 bool is_creation) { 1203 bool is_creation) {
1207 if (ShouldPushChanges() || IsPassphraseRequired()) { 1204 if (ShouldPushChanges() || IsPassphraseRequired()) {
1205 VLOG(1) << "Setting " << (is_explicit ? "explicit" : "implicit")
1206 << " passphrase " << (is_creation ? " for creation" : "");
1208 backend_->SetPassphrase(passphrase, is_explicit); 1207 backend_->SetPassphrase(passphrase, is_explicit);
1209 } else { 1208 } else {
1210 if (is_explicit) { 1209 if (is_explicit) {
1211 cached_passphrase_.value = passphrase; 1210 cached_passphrase_.value = passphrase;
1212 cached_passphrase_.is_explicit = is_explicit; 1211 cached_passphrase_.is_explicit = is_explicit;
1213 cached_passphrase_.is_creation = is_creation; 1212 cached_passphrase_.is_creation = is_creation;
1214 } else { 1213 } else {
1215 gaia_password_ = passphrase; 1214 gaia_password_ = passphrase;
1216 } 1215 }
1217 } 1216 }
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after
1404 // is initialized, all enabled data types are consistent with one 1403 // is initialized, all enabled data types are consistent with one
1405 // another, and no unrecoverable error has transpired. 1404 // another, and no unrecoverable error has transpired.
1406 if (unrecoverable_error_detected_) 1405 if (unrecoverable_error_detected_)
1407 return false; 1406 return false;
1408 1407
1409 if (!data_type_manager_.get()) 1408 if (!data_type_manager_.get())
1410 return false; 1409 return false;
1411 1410
1412 return data_type_manager_->state() == DataTypeManager::CONFIGURED; 1411 return data_type_manager_->state() == DataTypeManager::CONFIGURED;
1413 } 1412 }
OLDNEW
« no previous file with comments | « chrome/browser/sync/engine/syncapi.cc ('k') | chrome/browser/sync/sync_setup_flow.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698