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

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

Issue 6902101: Refactor sync passphrase setup flow and fix passphrase tests (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix unit test. Created 9 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) 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 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 const char* ProfileSyncService::kDevServerUrl = 62 const char* ProfileSyncService::kDevServerUrl =
63 "https://clients4.google.com/chrome-sync/dev"; 63 "https://clients4.google.com/chrome-sync/dev";
64 64
65 static const int kSyncClearDataTimeoutInSeconds = 60; // 1 minute. 65 static const int kSyncClearDataTimeoutInSeconds = 60; // 1 minute.
66 66
67 ProfileSyncService::ProfileSyncService(ProfileSyncFactory* factory, 67 ProfileSyncService::ProfileSyncService(ProfileSyncFactory* factory,
68 Profile* profile, 68 Profile* profile,
69 const std::string& cros_user) 69 const std::string& cros_user)
70 : last_auth_error_(AuthError::None()), 70 : last_auth_error_(AuthError::None()),
71 observed_passphrase_required_(false), 71 observed_passphrase_required_(false),
72 observed_passphrase_failed_(false),
72 passphrase_required_for_decryption_(false), 73 passphrase_required_for_decryption_(false),
73 passphrase_migration_in_progress_(false), 74 passphrase_migration_in_progress_(false),
74 factory_(factory), 75 factory_(factory),
75 profile_(profile), 76 profile_(profile),
76 cros_user_(cros_user), 77 cros_user_(cros_user),
77 sync_service_url_(kDevServerUrl), 78 sync_service_url_(kDevServerUrl),
78 backend_initialized_(false), 79 backend_initialized_(false),
79 is_auth_in_progress_(false), 80 is_auth_in_progress_(false),
80 wizard_(ALLOW_THIS_IN_INITIALIZER_LIST(this)), 81 wizard_(ALLOW_THIS_IN_INITIALIZER_LIST(this)),
81 unrecoverable_error_detected_(false), 82 unrecoverable_error_detected_(false),
(...skipping 545 matching lines...) Expand 10 before | Expand all | Expand 10 after
627 } 628 }
628 629
629 NotifyObservers(); 630 NotifyObservers();
630 } 631 }
631 632
632 void ProfileSyncService::OnPassphraseAccepted() { 633 void ProfileSyncService::OnPassphraseAccepted() {
633 // Make sure the data types that depend on the passphrase are started at 634 // Make sure the data types that depend on the passphrase are started at
634 // this time. 635 // this time.
635 syncable::ModelTypeSet types; 636 syncable::ModelTypeSet types;
636 GetPreferredDataTypes(&types); 637 GetPreferredDataTypes(&types);
637 // Reset "passphrase_required" flag before configuring the DataTypeManager 638
638 // since we know we no longer require the passphrase. 639 // Reset "passphrase_required" and "passphrase_failed" flags before
640 // configuring the DataTypeManager since we know we no longer require the
641 // passphrase.
639 observed_passphrase_required_ = false; 642 observed_passphrase_required_ = false;
643 observed_passphrase_failed_ = false;
644
640 if (data_type_manager_.get()) 645 if (data_type_manager_.get())
641 data_type_manager_->Configure(types); 646 data_type_manager_->Configure(types);
642 647
643 NotifyObservers(); 648 NotifyObservers();
644 649
645 wizard_.Step(SyncSetupWizard::DONE); 650 wizard_.Step(SyncSetupWizard::DONE);
646 } 651 }
647 652
653 void ProfileSyncService::OnPassphraseFailed() {
654 observed_passphrase_failed_ = true;
655 OnPassphraseRequired(true);
tim (not reviewing) 2011/04/28 17:18:00 This seems like a step in the wrong direction. We
Raghu Simha 2011/04/28 17:44:21 Like I explained in the other comment, this is to
656 }
657
648 void ProfileSyncService::OnEncryptionComplete( 658 void ProfileSyncService::OnEncryptionComplete(
649 const syncable::ModelTypeSet& encrypted_types) { 659 const syncable::ModelTypeSet& encrypted_types) {
650 if (encrypted_types_ != encrypted_types) { 660 if (encrypted_types_ != encrypted_types) {
651 encrypted_types_ = encrypted_types; 661 encrypted_types_ = encrypted_types;
652 NotifyObservers(); 662 NotifyObservers();
653 } 663 }
654 } 664 }
655 665
656 void ProfileSyncService::OnMigrationNeededForTypes( 666 void ProfileSyncService::OnMigrationNeededForTypes(
657 const syncable::ModelTypeSet& types) { 667 const syncable::ModelTypeSet& types) {
(...skipping 621 matching lines...) Expand 10 before | Expand all | Expand 10 after
1279 // is initialized, all enabled data types are consistent with one 1289 // is initialized, all enabled data types are consistent with one
1280 // another, and no unrecoverable error has transpired. 1290 // another, and no unrecoverable error has transpired.
1281 if (unrecoverable_error_detected_) 1291 if (unrecoverable_error_detected_)
1282 return false; 1292 return false;
1283 1293
1284 if (!data_type_manager_.get()) 1294 if (!data_type_manager_.get())
1285 return false; 1295 return false;
1286 1296
1287 return data_type_manager_->state() == DataTypeManager::CONFIGURED; 1297 return data_type_manager_->state() == DataTypeManager::CONFIGURED;
1288 } 1298 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698