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

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

Issue 11946058: Add password sync for Android. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 7 years, 11 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
« no previous file with comments | « chrome/browser/sync/profile_sync_service.h ('k') | no next file » | 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 <cstddef> 7 #include <cstddef>
8 #include <map> 8 #include <map>
9 #include <set> 9 #include <set>
10 #include <utility> 10 #include <utility>
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 #include "sync/internal_api/public/sync_encryption_handler.h" 67 #include "sync/internal_api/public/sync_encryption_handler.h"
68 #include "sync/internal_api/public/util/experiments.h" 68 #include "sync/internal_api/public/util/experiments.h"
69 #include "sync/internal_api/public/util/sync_string_conversions.h" 69 #include "sync/internal_api/public/util/sync_string_conversions.h"
70 #include "sync/js/js_arg_list.h" 70 #include "sync/js/js_arg_list.h"
71 #include "sync/js/js_event_details.h" 71 #include "sync/js/js_event_details.h"
72 #include "sync/notifier/invalidator_registrar.h" 72 #include "sync/notifier/invalidator_registrar.h"
73 #include "sync/notifier/invalidator_state.h" 73 #include "sync/notifier/invalidator_state.h"
74 #include "sync/util/cryptographer.h" 74 #include "sync/util/cryptographer.h"
75 #include "ui/base/l10n/l10n_util.h" 75 #include "ui/base/l10n/l10n_util.h"
76 76
77 #if defined(OS_ANDROID)
78 #include "sync/internal_api/public/read_transaction.h"
79 #endif
80
77 using browser_sync::ChangeProcessor; 81 using browser_sync::ChangeProcessor;
78 using browser_sync::DataTypeController; 82 using browser_sync::DataTypeController;
79 using browser_sync::DataTypeManager; 83 using browser_sync::DataTypeManager;
80 using browser_sync::SyncBackendHost; 84 using browser_sync::SyncBackendHost;
81 using syncer::ModelType; 85 using syncer::ModelType;
82 using syncer::ModelTypeSet; 86 using syncer::ModelTypeSet;
83 using syncer::JsBackend; 87 using syncer::JsBackend;
84 using syncer::JsController; 88 using syncer::JsController;
85 using syncer::JsEventDetails; 89 using syncer::JsEventDetails;
86 using syncer::JsEventHandler; 90 using syncer::JsEventHandler;
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
180 // Sync is logged in if there is a non-empty authenticated username. 184 // Sync is logged in if there is a non-empty authenticated username.
181 return !signin_->GetAuthenticatedUsername().empty(); 185 return !signin_->GetAuthenticatedUsername().empty();
182 } 186 }
183 187
184 bool ProfileSyncService::IsSyncTokenAvailable() { 188 bool ProfileSyncService::IsSyncTokenAvailable() {
185 TokenService* token_service = TokenServiceFactory::GetForProfile(profile_); 189 TokenService* token_service = TokenServiceFactory::GetForProfile(profile_);
186 if (!token_service) 190 if (!token_service)
187 return false; 191 return false;
188 return token_service->HasTokenForService(GaiaConstants::kSyncService); 192 return token_service->HasTokenForService(GaiaConstants::kSyncService);
189 } 193 }
194 #if defined(OS_ANDROID)
195 bool ProfileSyncService::ShouldEnablePasswordSyncForAndroid() const {
196 const syncer::ModelTypeSet registered_types = GetRegisteredDataTypes();
197 const syncer::ModelTypeSet preferred_types =
198 sync_prefs_.GetPreferredDataTypes(registered_types);
199 if (!preferred_types.Has(syncer::PASSWORDS))
200 return false;
201 // On Android we do not want to prompt user to enter a passphrase. If
202 // passwords cannot be decrypted we just disable them.
203 syncer::ReadTransaction trans(FROM_HERE, GetUserShare());
204 return IsCryptographerReady(&trans);
205 }
206 #endif
190 207
191 void ProfileSyncService::Initialize() { 208 void ProfileSyncService::Initialize() {
192 DCHECK(!invalidator_registrar_.get()); 209 DCHECK(!invalidator_registrar_.get());
193 invalidator_registrar_.reset(new syncer::InvalidatorRegistrar()); 210 invalidator_registrar_.reset(new syncer::InvalidatorRegistrar());
194 211
195 InitSettings(); 212 InitSettings();
196 213
197 // We clear this here (vs Shutdown) because we want to remember that an error 214 // We clear this here (vs Shutdown) because we want to remember that an error
198 // happened on shutdown so we can display details (message, location) about it 215 // happened on shutdown so we can display details (message, location) about it
199 // in about:sync. 216 // in about:sync.
(...skipping 791 matching lines...) Expand 10 before | Expand all | Expand 10 after
991 // consumed our cached passphrase. Clear it now. 1008 // consumed our cached passphrase. Clear it now.
992 if (!cached_passphrase_.empty()) 1009 if (!cached_passphrase_.empty())
993 cached_passphrase_.clear(); 1010 cached_passphrase_.clear();
994 1011
995 // Reset passphrase_required_reason_ since we know we no longer require the 1012 // Reset passphrase_required_reason_ since we know we no longer require the
996 // passphrase. We do this here rather than down in ResolvePassphraseRequired() 1013 // passphrase. We do this here rather than down in ResolvePassphraseRequired()
997 // because that can be called by OnPassphraseRequired() if no encrypted data 1014 // because that can be called by OnPassphraseRequired() if no encrypted data
998 // types are enabled, and we don't want to clobber the true passphrase error. 1015 // types are enabled, and we don't want to clobber the true passphrase error.
999 passphrase_required_reason_ = syncer::REASON_PASSPHRASE_NOT_REQUIRED; 1016 passphrase_required_reason_ = syncer::REASON_PASSPHRASE_NOT_REQUIRED;
1000 1017
1018 #if defined(OS_ANDROID)
1019 // Re-enable passwords if we have disabled them.
1020 if (failed_datatypes_handler_.GetFailedTypes().Has(syncer::PASSWORDS) &&
1021 ShouldEnablePasswordSyncForAndroid()) {
1022 // Clear the data type errors.
1023 failed_datatypes_handler_.OnUserChoseDatatypes();
1024 }
1025 #endif
1026
1001 // Make sure the data types that depend on the passphrase are started at 1027 // Make sure the data types that depend on the passphrase are started at
1002 // this time. 1028 // this time.
1003 const syncer::ModelTypeSet types = GetPreferredDataTypes(); 1029 const syncer::ModelTypeSet types = GetPreferredDataTypes();
1004 1030
1005 if (data_type_manager_.get()) { 1031 if (data_type_manager_.get()) {
1006 // Unblock the data type manager if necessary. 1032 // Unblock the data type manager if necessary.
1007 data_type_manager_->Configure(types, 1033 data_type_manager_->Configure(types,
1008 syncer::CONFIGURE_REASON_RECONFIGURATION); 1034 syncer::CONFIGURE_REASON_RECONFIGURATION);
1009 } 1035 }
1010 1036
(...skipping 446 matching lines...) Expand 10 before | Expand all | Expand 10 after
1457 1483
1458 // We create the migrator at the same time. 1484 // We create the migrator at the same time.
1459 migrator_.reset( 1485 migrator_.reset(
1460 new browser_sync::BackendMigrator( 1486 new browser_sync::BackendMigrator(
1461 profile_->GetDebugName(), GetUserShare(), 1487 profile_->GetDebugName(), GetUserShare(),
1462 this, data_type_manager_.get(), 1488 this, data_type_manager_.get(),
1463 base::Bind(&ProfileSyncService::StartSyncingWithServer, 1489 base::Bind(&ProfileSyncService::StartSyncingWithServer,
1464 base::Unretained(this)))); 1490 base::Unretained(this))));
1465 } 1491 }
1466 1492
1493 #if defined(OS_ANDROID)
1494 if (GetPreferredDataTypes().Has(syncer::PASSWORDS) &&
1495 !ShouldEnablePasswordSyncForAndroid()) {
1496 DisableBrokenDatatype(syncer::PASSWORDS, FROM_HERE, "Not supported.");
1497 }
1498 #endif
1499
1467 const syncer::ModelTypeSet types = GetPreferredDataTypes(); 1500 const syncer::ModelTypeSet types = GetPreferredDataTypes();
1468 if (IsPassphraseRequiredForDecryption()) { 1501 if (IsPassphraseRequiredForDecryption()) {
1469 // We need a passphrase still. We don't bother to attempt to configure 1502 // We need a passphrase still. We don't bother to attempt to configure
1470 // until we receive an OnPassphraseAccepted (which triggers a configure). 1503 // until we receive an OnPassphraseAccepted (which triggers a configure).
1471 DVLOG(1) << "ProfileSyncService::ConfigureDataTypeManager bailing out " 1504 DVLOG(1) << "ProfileSyncService::ConfigureDataTypeManager bailing out "
1472 << "because a passphrase required"; 1505 << "because a passphrase required";
1473 NotifyObservers(); 1506 NotifyObservers();
1474 return; 1507 return;
1475 } 1508 }
1476 syncer::ConfigureReason reason = syncer::CONFIGURE_REASON_UNKNOWN; 1509 syncer::ConfigureReason reason = syncer::CONFIGURE_REASON_UNKNOWN;
(...skipping 449 matching lines...) Expand 10 before | Expand all | Expand 10 after
1926 // See http://stackoverflow.com/questions/6224121/is-new-this-myclass-undefine d-behaviour-after-directly-calling-the-destru. 1959 // See http://stackoverflow.com/questions/6224121/is-new-this-myclass-undefine d-behaviour-after-directly-calling-the-destru.
1927 ProfileSyncService* old_this = this; 1960 ProfileSyncService* old_this = this;
1928 this->~ProfileSyncService(); 1961 this->~ProfileSyncService();
1929 new(old_this) ProfileSyncService( 1962 new(old_this) ProfileSyncService(
1930 new ProfileSyncComponentsFactoryImpl(profile, 1963 new ProfileSyncComponentsFactoryImpl(profile,
1931 CommandLine::ForCurrentProcess()), 1964 CommandLine::ForCurrentProcess()),
1932 profile, 1965 profile,
1933 signin, 1966 signin,
1934 behavior); 1967 behavior);
1935 } 1968 }
OLDNEW
« no previous file with comments | « chrome/browser/sync/profile_sync_service.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698