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

Side by Side Diff: chrome/browser/sync/glue/sync_backend_host.cc

Issue 6537027: Revert 75287 - [Sync] Initial support for encrypting any datatype (no UI hook... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 years, 10 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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 "build/build_config.h" 5 #include "build/build_config.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/compiler_specific.h" 9 #include "base/compiler_specific.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 12 matching lines...) Expand all
23 #include "chrome/browser/sync/glue/database_model_worker.h" 23 #include "chrome/browser/sync/glue/database_model_worker.h"
24 #include "chrome/browser/sync/glue/history_model_worker.h" 24 #include "chrome/browser/sync/glue/history_model_worker.h"
25 #include "chrome/browser/sync/glue/sync_backend_host.h" 25 #include "chrome/browser/sync/glue/sync_backend_host.h"
26 #include "chrome/browser/sync/glue/http_bridge.h" 26 #include "chrome/browser/sync/glue/http_bridge.h"
27 #include "chrome/browser/sync/glue/password_model_worker.h" 27 #include "chrome/browser/sync/glue/password_model_worker.h"
28 #include "chrome/browser/sync/js_arg_list.h" 28 #include "chrome/browser/sync/js_arg_list.h"
29 #include "chrome/browser/sync/sessions/session_state.h" 29 #include "chrome/browser/sync/sessions/session_state.h"
30 // TODO(tim): Remove this! We should have a syncapi pass-thru instead. 30 // TODO(tim): Remove this! We should have a syncapi pass-thru instead.
31 #include "chrome/browser/sync/syncable/directory_manager.h" // Cryptographer. 31 #include "chrome/browser/sync/syncable/directory_manager.h" // Cryptographer.
32 #include "chrome/browser/sync/syncable/model_type.h" 32 #include "chrome/browser/sync/syncable/model_type.h"
33 #include "chrome/browser/sync/syncable/nigori_util.h"
34 #include "chrome/common/chrome_switches.h" 33 #include "chrome/common/chrome_switches.h"
35 #include "chrome/common/chrome_version_info.h" 34 #include "chrome/common/chrome_version_info.h"
36 #include "chrome/common/net/gaia/gaia_constants.h" 35 #include "chrome/common/net/gaia/gaia_constants.h"
37 #include "chrome/common/notification_service.h" 36 #include "chrome/common/notification_service.h"
38 #include "chrome/common/notification_type.h" 37 #include "chrome/common/notification_type.h"
39 #include "chrome/common/pref_names.h" 38 #include "chrome/common/pref_names.h"
40 #include "webkit/glue/webkit_glue.h" 39 #include "webkit/glue/webkit_glue.h"
41 40
42 static const int kSaveChangesIntervalSeconds = 10; 41 static const int kSaveChangesIntervalSeconds = 10;
43 static const FilePath::CharType kSyncDataFolderName[] = 42 static const FilePath::CharType kSyncDataFolderName[] =
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 it != types.end(); ++it) { 118 it != types.end(); ++it) {
120 registrar_.routing_info[(*it)] = GROUP_PASSIVE; 119 registrar_.routing_info[(*it)] = GROUP_PASSIVE;
121 } 120 }
122 121
123 PasswordStore* password_store = 122 PasswordStore* password_store =
124 profile_->GetPasswordStore(Profile::IMPLICIT_ACCESS); 123 profile_->GetPasswordStore(Profile::IMPLICIT_ACCESS);
125 if (password_store) { 124 if (password_store) {
126 registrar_.workers[GROUP_PASSWORD] = 125 registrar_.workers[GROUP_PASSWORD] =
127 new PasswordModelWorker(password_store); 126 new PasswordModelWorker(password_store);
128 } else { 127 } else {
129 LOG_IF(WARNING, types.count(syncable::PASSWORDS) > 0) << "Password store " 128 LOG(WARNING) << "Password store not initialized, cannot sync passwords";
130 << "not initialized, cannot sync passwords";
131 registrar_.routing_info.erase(syncable::PASSWORDS); 129 registrar_.routing_info.erase(syncable::PASSWORDS);
132 } 130 }
133 131
134 // Nigori is populated by default now. 132 // TODO(tim): Remove this special case once NIGORI is populated by
135 registrar_.routing_info[syncable::NIGORI] = GROUP_PASSIVE; 133 // default. We piggy back off of the passwords flag for now to not
134 // require both encryption and passwords flags.
135 bool enable_encryption = !CommandLine::ForCurrentProcess()->HasSwitch(
136 switches::kDisableSyncPasswords) || types.count(syncable::PASSWORDS);
137 if (enable_encryption)
138 registrar_.routing_info[syncable::NIGORI] = GROUP_PASSIVE;
136 139
137 InitCore(Core::DoInitializeOptions( 140 InitCore(Core::DoInitializeOptions(
138 sync_service_url, 141 sync_service_url,
139 MakeHttpBridgeFactory(baseline_context_getter), 142 MakeHttpBridgeFactory(baseline_context_getter),
140 credentials, 143 credentials,
141 delete_sync_data_folder, 144 delete_sync_data_folder,
142 notifier_options, 145 notifier_options,
143 RestoreEncryptionBootstrapToken(), 146 RestoreEncryptionBootstrapToken(),
144 false)); 147 false));
145 } 148 }
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after
397 // downloading updates for newly added data types. Once this is 400 // downloading updates for newly added data types. Once this is
398 // complete, the configure_ready_task_ is run via an 401 // complete, the configure_ready_task_ is run via an
399 // OnInitializationComplete notification. 402 // OnInitializationComplete notification.
400 if (deleted_type || !core_->syncapi()->InitialSyncEndedForAllEnabledTypes()) { 403 if (deleted_type || !core_->syncapi()->InitialSyncEndedForAllEnabledTypes()) {
401 // We can only nudge when we've either deleted a dataype or added one, else 404 // We can only nudge when we've either deleted a dataype or added one, else
402 // we break all the profile sync unit tests. 405 // we break all the profile sync unit tests.
403 RequestNudge(); 406 RequestNudge();
404 } 407 }
405 } 408 }
406 409
407 void SyncBackendHost::EncryptDataTypes(
408 const syncable::ModelTypeSet& encrypted_types) {
409 core_thread_.message_loop()->PostTask(FROM_HERE,
410 NewRunnableMethod(core_.get(),
411 &SyncBackendHost::Core::DoEncryptDataTypes,
412 encrypted_types));
413 }
414
415 void SyncBackendHost::RequestNudge() { 410 void SyncBackendHost::RequestNudge() {
416 core_thread_.message_loop()->PostTask(FROM_HERE, 411 core_thread_.message_loop()->PostTask(FROM_HERE,
417 NewRunnableMethod(core_.get(), &SyncBackendHost::Core::DoRequestNudge)); 412 NewRunnableMethod(core_.get(), &SyncBackendHost::Core::DoRequestNudge));
418 } 413 }
419 414
420 void SyncBackendHost::ActivateDataType( 415 void SyncBackendHost::ActivateDataType(
421 DataTypeController* data_type_controller, 416 DataTypeController* data_type_controller,
422 ChangeProcessor* change_processor) { 417 ChangeProcessor* change_processor) {
423 base::AutoLock lock(registrar_lock_); 418 base::AutoLock lock(registrar_lock_);
424 419
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
509 if (!host_) 504 if (!host_)
510 return; 505 return;
511 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 506 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
512 TokenAvailableDetails details(GaiaConstants::kSyncService, token); 507 TokenAvailableDetails details(GaiaConstants::kSyncService, token);
513 NotificationService::current()->Notify( 508 NotificationService::current()->Notify(
514 NotificationType::TOKEN_UPDATED, 509 NotificationType::TOKEN_UPDATED,
515 NotificationService::AllSources(), 510 NotificationService::AllSources(),
516 Details<const TokenAvailableDetails>(&details)); 511 Details<const TokenAvailableDetails>(&details));
517 } 512 }
518 513
519 void SyncBackendHost::Core::NotifyEncryptionComplete(
520 const syncable::ModelTypeSet& encrypted_types) {
521 if (!host_)
522 return;
523 DCHECK_EQ(MessageLoop::current(), host_->frontend_loop_);
524 host_->frontend_->OnEncryptionComplete(encrypted_types);
525 }
526
527 SyncBackendHost::Core::DoInitializeOptions::DoInitializeOptions( 514 SyncBackendHost::Core::DoInitializeOptions::DoInitializeOptions(
528 const GURL& service_url, 515 const GURL& service_url,
529 sync_api::HttpPostProviderFactory* http_bridge_factory, 516 sync_api::HttpPostProviderFactory* http_bridge_factory,
530 const sync_api::SyncCredentials& credentials, 517 const sync_api::SyncCredentials& credentials,
531 bool delete_sync_data_folder, 518 bool delete_sync_data_folder,
532 const notifier::NotifierOptions& notifier_options, 519 const notifier::NotifierOptions& notifier_options,
533 std::string restored_key_for_bootstrapping, 520 std::string restored_key_for_bootstrapping,
534 bool setup_for_test_mode) 521 bool setup_for_test_mode)
535 : service_url(service_url), 522 : service_url(service_url),
536 http_bridge_factory(http_bridge_factory), 523 http_bridge_factory(http_bridge_factory),
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
675 DCHECK(MessageLoop::current() == host_->core_thread_.message_loop()); 662 DCHECK(MessageLoop::current() == host_->core_thread_.message_loop());
676 syncapi_->StartSyncing(); 663 syncapi_->StartSyncing();
677 } 664 }
678 665
679 void SyncBackendHost::Core::DoSetPassphrase(const std::string& passphrase, 666 void SyncBackendHost::Core::DoSetPassphrase(const std::string& passphrase,
680 bool is_explicit) { 667 bool is_explicit) {
681 DCHECK(MessageLoop::current() == host_->core_thread_.message_loop()); 668 DCHECK(MessageLoop::current() == host_->core_thread_.message_loop());
682 syncapi_->SetPassphrase(passphrase, is_explicit); 669 syncapi_->SetPassphrase(passphrase, is_explicit);
683 } 670 }
684 671
685 void SyncBackendHost::Core::DoEncryptDataTypes(
686 const syncable::ModelTypeSet& encrypted_types) {
687 DCHECK(MessageLoop::current() == host_->core_thread_.message_loop());
688 syncapi_->EncryptDataTypes(encrypted_types);
689 }
690
691 UIModelWorker* SyncBackendHost::ui_worker() { 672 UIModelWorker* SyncBackendHost::ui_worker() {
692 ModelSafeWorker* w = registrar_.workers[GROUP_UI]; 673 ModelSafeWorker* w = registrar_.workers[GROUP_UI];
693 if (w == NULL) 674 if (w == NULL)
694 return NULL; 675 return NULL;
695 if (w->GetModelSafeGroup() != GROUP_UI) 676 if (w->GetModelSafeGroup() != GROUP_UI)
696 NOTREACHED(); 677 NOTREACHED();
697 return static_cast<UIModelWorker*>(w); 678 return static_cast<UIModelWorker*>(w);
698 } 679 }
699 680
700 void SyncBackendHost::Core::DoShutdown(bool sync_disabled) { 681 void SyncBackendHost::Core::DoShutdown(bool sync_disabled) {
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after
900 void SyncBackendHost::Core::OnClearServerDataSucceeded() { 881 void SyncBackendHost::Core::OnClearServerDataSucceeded() {
901 host_->frontend_loop_->PostTask(FROM_HERE, NewRunnableMethod(this, 882 host_->frontend_loop_->PostTask(FROM_HERE, NewRunnableMethod(this,
902 &Core::HandleClearServerDataSucceededOnFrontendLoop)); 883 &Core::HandleClearServerDataSucceededOnFrontendLoop));
903 } 884 }
904 885
905 void SyncBackendHost::Core::OnClearServerDataFailed() { 886 void SyncBackendHost::Core::OnClearServerDataFailed() {
906 host_->frontend_loop_->PostTask(FROM_HERE, NewRunnableMethod(this, 887 host_->frontend_loop_->PostTask(FROM_HERE, NewRunnableMethod(this,
907 &Core::HandleClearServerDataFailedOnFrontendLoop)); 888 &Core::HandleClearServerDataFailedOnFrontendLoop));
908 } 889 }
909 890
910 void SyncBackendHost::Core::OnEncryptionComplete(
911 const syncable::ModelTypeSet& encrypted_types) {
912 host_->frontend_loop_->PostTask(
913 FROM_HERE,
914 NewRunnableMethod(this, &Core::NotifyEncryptionComplete,
915 encrypted_types));
916 }
917
918 void SyncBackendHost::Core::RouteJsEvent( 891 void SyncBackendHost::Core::RouteJsEvent(
919 const std::string& name, const JsArgList& args, 892 const std::string& name, const JsArgList& args,
920 const JsEventHandler* target) { 893 const JsEventHandler* target) {
921 host_->frontend_loop_->PostTask( 894 host_->frontend_loop_->PostTask(
922 FROM_HERE, NewRunnableMethod( 895 FROM_HERE, NewRunnableMethod(
923 this, &Core::RouteJsEventOnFrontendLoop, name, args, target)); 896 this, &Core::RouteJsEventOnFrontendLoop, name, args, target));
924 } 897 }
925 898
926 void SyncBackendHost::Core::HandleStopSyncingPermanentlyOnFrontendLoop() { 899 void SyncBackendHost::Core::HandleStopSyncingPermanentlyOnFrontendLoop() {
927 if (!host_ || !host_->frontend_) 900 if (!host_ || !host_->frontend_)
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
1054 } 1027 }
1055 1028
1056 void SyncBackendHost::Core::DoProcessMessage( 1029 void SyncBackendHost::Core::DoProcessMessage(
1057 const std::string& name, const JsArgList& args, 1030 const std::string& name, const JsArgList& args,
1058 const JsEventHandler* sender) { 1031 const JsEventHandler* sender) {
1059 DCHECK_EQ(MessageLoop::current(), host_->core_thread_.message_loop()); 1032 DCHECK_EQ(MessageLoop::current(), host_->core_thread_.message_loop());
1060 syncapi_->GetJsBackend()->ProcessMessage(name, args, sender); 1033 syncapi_->GetJsBackend()->ProcessMessage(name, args, sender);
1061 } 1034 }
1062 1035
1063 } // namespace browser_sync 1036 } // namespace browser_sync
OLDNEW
« no previous file with comments | « chrome/browser/sync/glue/sync_backend_host.h ('k') | chrome/browser/sync/js_sync_manager_observer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698