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

Unified Diff: sync/android/java/src/org/chromium/sync/internal_api/pub/SyncDecryptionPassphraseType.java

Issue 655463005: Move passphrase dialog logic to the enum. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2171
Patch Set: Created 6 years, 2 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sync/android/java/src/org/chromium/sync/internal_api/pub/SyncDecryptionPassphraseType.java
diff --git a/sync/android/java/src/org/chromium/sync/internal_api/pub/SyncDecryptionPassphraseType.java b/sync/android/java/src/org/chromium/sync/internal_api/pub/SyncDecryptionPassphraseType.java
index 3010c1a1def8d67a384c01a7a0af42dccf3ba27a..27de932d2dabe35eb349d792a142106fa466b5f1 100644
--- a/sync/android/java/src/org/chromium/sync/internal_api/pub/SyncDecryptionPassphraseType.java
+++ b/sync/android/java/src/org/chromium/sync/internal_api/pub/SyncDecryptionPassphraseType.java
@@ -7,6 +7,9 @@ package org.chromium.sync.internal_api.pub;
import android.os.Parcel;
import android.os.Parcelable;
+import java.util.HashSet;
+import java.util.Set;
+
/**
* This enum describes the type of passphrase required, if any, to decrypt synced data.
*
@@ -51,6 +54,50 @@ public enum SyncDecryptionPassphraseType implements Parcelable {
mNativeValue = nativeValue;
}
+
+ public Set<SyncDecryptionPassphraseType> getVisibleTypes() {
+ Set<SyncDecryptionPassphraseType> visibleTypes = new HashSet<>();
+ switch (this) {
+ case NONE: // Intentional fall through.
+ case IMPLICIT_PASSPHRASE: // Intentional fall through.
+ case KEYSTORE_PASSPHRASE:
+ visibleTypes.add(this);
+ visibleTypes.add(CUSTOM_PASSPHRASE);
+ break;
+ case FROZEN_IMPLICIT_PASSPHRASE:
+ visibleTypes.add(KEYSTORE_PASSPHRASE);
+ visibleTypes.add(FROZEN_IMPLICIT_PASSPHRASE);
+ break;
+ case CUSTOM_PASSPHRASE:
+ visibleTypes.add(KEYSTORE_PASSPHRASE);
+ visibleTypes.add(CUSTOM_PASSPHRASE);
+ break;
+ case INVALID: // Intentional fall through.
+ default:
+ visibleTypes.add(this);
+ break;
+ }
+ return visibleTypes;
+ }
+
+ public Set<SyncDecryptionPassphraseType> getAllowedTypes() {
+ Set<SyncDecryptionPassphraseType> allowedTypes = new HashSet<>();
+ switch (this) {
+ case NONE: // Intentional fall through.
+ case IMPLICIT_PASSPHRASE: // Intentional fall through.
+ case KEYSTORE_PASSPHRASE:
+ allowedTypes.add(this);
+ allowedTypes.add(CUSTOM_PASSPHRASE);
+ break;
+ case FROZEN_IMPLICIT_PASSPHRASE: // Intentional fall through.
+ case CUSTOM_PASSPHRASE: // Intentional fall through.
+ case INVALID: // Intentional fall through.
+ default:
+ break;
+ }
+ return allowedTypes;
+ }
+
public int internalValue() {
// Since the values in this enums are constant and very small, this cast is safe.
return mNativeValue;
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698