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

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

Issue 2828021: Take 2: sync changes to support encryption (Closed)
Patch Set: fix flaky password test under valgrind Created 10 years, 6 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
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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 <map> 7 #include <map>
8 #include <set> 8 #include <set>
9 9
10 #include "app/l10n_util.h" 10 #include "app/l10n_util.h"
11 #include "base/callback.h" 11 #include "base/callback.h"
12 #include "base/command_line.h" 12 #include "base/command_line.h"
13 #include "base/file_path.h" 13 #include "base/file_path.h"
14 #include "base/file_util.h" 14 #include "base/file_util.h"
15 #include "base/histogram.h" 15 #include "base/histogram.h"
16 #include "base/logging.h" 16 #include "base/logging.h"
17 #include "base/stl_util-inl.h" 17 #include "base/stl_util-inl.h"
18 #include "base/string_util.h" 18 #include "base/string_util.h"
19 #include "base/task.h" 19 #include "base/task.h"
20 #include "chrome/browser/chrome_thread.h" 20 #include "chrome/browser/chrome_thread.h"
21 #include "chrome/browser/history/history_types.h" 21 #include "chrome/browser/history/history_types.h"
22 #include "chrome/browser/platform_util.h" 22 #include "chrome/browser/platform_util.h"
23 #include "chrome/browser/pref_service.h" 23 #include "chrome/browser/pref_service.h"
24 #include "chrome/browser/profile.h" 24 #include "chrome/browser/profile.h"
25 #include "chrome/browser/sync/engine/syncapi.h" 25 #include "chrome/browser/sync/engine/syncapi.h"
26 #include "chrome/browser/sync/glue/change_processor.h" 26 #include "chrome/browser/sync/glue/change_processor.h"
27 #include "chrome/browser/sync/glue/data_type_controller.h" 27 #include "chrome/browser/sync/glue/data_type_controller.h"
28 #include "chrome/browser/sync/glue/data_type_manager.h" 28 #include "chrome/browser/sync/glue/data_type_manager.h"
29 #include "chrome/browser/sync/profile_sync_factory.h" 29 #include "chrome/browser/sync/profile_sync_factory.h"
30 #include "chrome/browser/sync/syncable/directory_manager.h"
30 #include "chrome/common/chrome_switches.h" 31 #include "chrome/common/chrome_switches.h"
31 #include "chrome/common/notification_details.h" 32 #include "chrome/common/notification_details.h"
32 #include "chrome/common/notification_service.h" 33 #include "chrome/common/notification_service.h"
33 #include "chrome/common/notification_source.h" 34 #include "chrome/common/notification_source.h"
34 #include "chrome/common/notification_type.h" 35 #include "chrome/common/notification_type.h"
35 #include "chrome/common/pref_names.h" 36 #include "chrome/common/pref_names.h"
36 #include "chrome/common/time_format.h" 37 #include "chrome/common/time_format.h"
37 #include "grit/generated_resources.h" 38 #include "grit/generated_resources.h"
38 #include "net/base/cookie_monster.h" 39 #include "net/base/cookie_monster.h"
39 40
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 ALLOW_THIS_IN_INITIALIZER_LIST(scoped_runnable_method_factory_(this)) { 72 ALLOW_THIS_IN_INITIALIZER_LIST(scoped_runnable_method_factory_(this)) {
72 DCHECK(factory); 73 DCHECK(factory);
73 DCHECK(profile); 74 DCHECK(profile);
74 DCHECK(network_change_notifier_thread_); 75 DCHECK(network_change_notifier_thread_);
75 registrar_.Add(this, 76 registrar_.Add(this,
76 NotificationType::SYNC_CONFIGURE_START, 77 NotificationType::SYNC_CONFIGURE_START,
77 NotificationService::AllSources()); 78 NotificationService::AllSources());
78 registrar_.Add(this, 79 registrar_.Add(this,
79 NotificationType::SYNC_CONFIGURE_DONE, 80 NotificationType::SYNC_CONFIGURE_DONE,
80 NotificationService::AllSources()); 81 NotificationService::AllSources());
82 registrar_.Add(this,
83 NotificationType::SYNC_PASSPHRASE_REQUIRED,
84 NotificationService::AllSources());
85 registrar_.Add(this,
86 NotificationType::SYNC_PASSPHRASE_ACCEPTED,
87 NotificationService::AllSources());
81 88
82 // By default, dev & chromium users will go to the development servers. 89 // By default, dev & chromium users will go to the development servers.
83 // Dev servers have more features than standard sync servers. 90 // Dev servers have more features than standard sync servers.
84 // Chrome stable and beta builds will go to the standard sync servers. 91 // Chrome stable and beta builds will go to the standard sync servers.
85 #if defined(GOOGLE_CHROME_BUILD) 92 #if defined(GOOGLE_CHROME_BUILD)
86 // For stable, this is "". For dev, this is "dev". For beta, this is "beta". 93 // For stable, this is "". For dev, this is "dev". For beta, this is "beta".
87 // For linux Chromium builds, this could be anything depending on the 94 // For linux Chromium builds, this could be anything depending on the
88 // distribution, so always direct those users to dev server urls. 95 // distribution, so always direct those users to dev server urls.
89 // If this is an official build, it will always be one of the above. 96 // If this is an official build, it will always be one of the above.
90 string16 channel = platform_util::GetVersionStringModifier(); 97 string16 channel = platform_util::GetVersionStringModifier();
(...skipping 552 matching lines...) Expand 10 before | Expand all | Expand 10 after
643 // The data_type_controllers_ are determined by command-line flags; that's 650 // The data_type_controllers_ are determined by command-line flags; that's
644 // effectively what controls the values returned here. 651 // effectively what controls the values returned here.
645 for (DataTypeController::TypeMap::const_iterator it = 652 for (DataTypeController::TypeMap::const_iterator it =
646 data_type_controllers_.begin(); 653 data_type_controllers_.begin();
647 it != data_type_controllers_.end(); ++it) { 654 it != data_type_controllers_.end(); ++it) {
648 registered_types->insert((*it).first); 655 registered_types->insert((*it).first);
649 } 656 }
650 } 657 }
651 658
652 bool ProfileSyncService::IsCryptographerReady() const { 659 bool ProfileSyncService::IsCryptographerReady() const {
653 // TODO(albertb): Replace this once the crypto patch lands. 660 return backend_->GetUserShareHandle()->
654 return true; 661 dir_manager->cryptographer()->is_ready();
662 }
663
664 void ProfileSyncService::SetPassphrase(const std::string& passphrase) {
665 backend_->SetPassphrase(passphrase);
655 } 666 }
656 667
657 void ProfileSyncService::StartProcessingChangesIfReady() { 668 void ProfileSyncService::StartProcessingChangesIfReady() {
658 DCHECK(backend_initialized_); 669 DCHECK(backend_initialized_);
659 670
660 if (bootstrap_sync_authentication_) { 671 if (bootstrap_sync_authentication_) {
661 SetSyncSetupCompleted(); 672 SetSyncSetupCompleted();
662 } 673 }
663 674
664 data_type_manager_.reset( 675 data_type_manager_.reset(
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
703 if (result != DataTypeManager::OK) { 714 if (result != DataTypeManager::OK) {
704 OnUnrecoverableError(FROM_HERE, "Sync Configuration failed."); 715 OnUnrecoverableError(FROM_HERE, "Sync Configuration failed.");
705 return; 716 return;
706 } 717 }
707 718
708 // TODO(sync): Less wizard, more toast. 719 // TODO(sync): Less wizard, more toast.
709 wizard_.Step(SyncSetupWizard::DONE); 720 wizard_.Step(SyncSetupWizard::DONE);
710 FOR_EACH_OBSERVER(Observer, observers_, OnStateChanged()); 721 FOR_EACH_OBSERVER(Observer, observers_, OnStateChanged());
711 break; 722 break;
712 } 723 }
724 case NotificationType::SYNC_PASSPHRASE_REQUIRED: {
725 // TODO(sync): Show the passphrase UI here.
726 SetPassphrase("dummy passphrase");
727 break;
728 }
729 case NotificationType::SYNC_PASSPHRASE_ACCEPTED: {
730 // Make sure the data types that depend on the passphrase are started at
731 // this time.
732 syncable::ModelTypeSet types;
733 GetPreferredDataTypes(&types);
734 data_type_manager_->Configure(types);
735
736 FOR_EACH_OBSERVER(Observer, observers_, OnStateChanged());
737 break;
738 }
713 default: { 739 default: {
714 NOTREACHED(); 740 NOTREACHED();
715 } 741 }
716 } 742 }
717 } 743 }
718 744
719 void ProfileSyncService::AddObserver(Observer* observer) { 745 void ProfileSyncService::AddObserver(Observer* observer) {
720 observers_.AddObserver(observer); 746 observers_.AddObserver(observer);
721 } 747 }
722 748
(...skipping 16 matching lines...) Expand all
739 // is initialized, all enabled data types are consistent with one 765 // is initialized, all enabled data types are consistent with one
740 // another, and no unrecoverable error has transpired. 766 // another, and no unrecoverable error has transpired.
741 if (unrecoverable_error_detected_) 767 if (unrecoverable_error_detected_)
742 return false; 768 return false;
743 769
744 if (!data_type_manager_.get()) 770 if (!data_type_manager_.get())
745 return false; 771 return false;
746 772
747 return data_type_manager_->state() == DataTypeManager::CONFIGURED; 773 return data_type_manager_->state() == DataTypeManager::CONFIGURED;
748 } 774 }
OLDNEW
« no previous file with comments | « chrome/browser/sync/profile_sync_service.h ('k') | chrome/browser/sync/profile_sync_service_password_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698