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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/sync/profile_sync_service.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/sync/profile_sync_service.cc
diff --git a/chrome/browser/sync/profile_sync_service.cc b/chrome/browser/sync/profile_sync_service.cc
index f5a1945eaca019addc39afabcba06db7cde9bbe2..d81f5a139cecd05d2c8899d1a0f274aca42250fe 100644
--- a/chrome/browser/sync/profile_sync_service.cc
+++ b/chrome/browser/sync/profile_sync_service.cc
@@ -74,6 +74,10 @@
#include "sync/util/cryptographer.h"
#include "ui/base/l10n/l10n_util.h"
+#if defined(OS_ANDROID)
+#include "sync/internal_api/public/read_transaction.h"
+#endif
+
using browser_sync::ChangeProcessor;
using browser_sync::DataTypeController;
using browser_sync::DataTypeManager;
@@ -187,6 +191,19 @@ bool ProfileSyncService::IsSyncTokenAvailable() {
return false;
return token_service->HasTokenForService(GaiaConstants::kSyncService);
}
+#if defined(OS_ANDROID)
+bool ProfileSyncService::ShouldEnablePasswordSyncForAndroid() const {
+ const syncer::ModelTypeSet registered_types = GetRegisteredDataTypes();
+ const syncer::ModelTypeSet preferred_types =
+ sync_prefs_.GetPreferredDataTypes(registered_types);
+ if (!preferred_types.Has(syncer::PASSWORDS))
+ return false;
+ // On Android we do not want to prompt user to enter a passphrase. If
+ // passwords cannot be decrypted we just disable them.
+ syncer::ReadTransaction trans(FROM_HERE, GetUserShare());
+ return IsCryptographerReady(&trans);
+}
+#endif
void ProfileSyncService::Initialize() {
DCHECK(!invalidator_registrar_.get());
@@ -998,6 +1015,15 @@ void ProfileSyncService::OnPassphraseAccepted() {
// types are enabled, and we don't want to clobber the true passphrase error.
passphrase_required_reason_ = syncer::REASON_PASSPHRASE_NOT_REQUIRED;
+#if defined(OS_ANDROID)
+ // Re-enable passwords if we have disabled them.
+ if (failed_datatypes_handler_.GetFailedTypes().Has(syncer::PASSWORDS) &&
+ ShouldEnablePasswordSyncForAndroid()) {
+ // Clear the data type errors.
+ failed_datatypes_handler_.OnUserChoseDatatypes();
+ }
+#endif
+
// Make sure the data types that depend on the passphrase are started at
// this time.
const syncer::ModelTypeSet types = GetPreferredDataTypes();
@@ -1464,6 +1490,13 @@ void ProfileSyncService::ConfigureDataTypeManager() {
base::Unretained(this))));
}
+#if defined(OS_ANDROID)
+ if (GetPreferredDataTypes().Has(syncer::PASSWORDS) &&
+ !ShouldEnablePasswordSyncForAndroid()) {
+ DisableBrokenDatatype(syncer::PASSWORDS, FROM_HERE, "Not supported.");
+ }
+#endif
+
const syncer::ModelTypeSet types = GetPreferredDataTypes();
if (IsPassphraseRequiredForDecryption()) {
// We need a passphrase still. We don't bother to attempt to configure
« 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