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

Unified Diff: chrome/browser/sync/engine/syncapi.h

Issue 6902101: Refactor sync passphrase setup flow and fix passphrase tests (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Remove OnPassphraseFailed; Plumb enum all the way through; Shave yak. Created 9 years, 8 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
Index: chrome/browser/sync/engine/syncapi.h
diff --git a/chrome/browser/sync/engine/syncapi.h b/chrome/browser/sync/engine/syncapi.h
index 1011a299d6ca4d9697cf1f728e0231336fc41106..0e1f6b5f7a75db1cc0a387c38641238adf4a83cb 100644
--- a/chrome/browser/sync/engine/syncapi.h
+++ b/chrome/browser/sync/engine/syncapi.h
@@ -107,6 +107,35 @@ class HttpPostProviderFactory;
class SyncManager;
class WriteTransaction;
+// Reasons due to which browser_sync::Cryptographer might require a passphrase.
+enum PassphraseRequiredReason {
+ UNKNOWN = 0, // Initial value
+ ENCRYPTION = 1, // The cryptographer requires a passphrase for
tim (not reviewing) 2011/04/29 01:21:48 Since this is in the syncapi ns, we should probabl
Raghu Simha 2011/04/29 18:59:14 Done.
+ // its first attempt at encryption.
+ DECRYPTION = 2, // The cryptographer requires a passphrase for
+ // its first attempt at decryption.
+ DECRYPTION_FAILED = 3, // The cryptographer requires a new passphrase
tim (not reviewing) 2011/04/29 01:21:48 SET_PASSPHRASE_FAILED
Raghu Simha 2011/04/29 18:59:14 Done.
+ // because its attempt at decryption with the
+ // cached passphrase was unsuccessful.
+};
+
+// Returns the string representation of a PassphraseRequiredReason value.
+std::string PassphraseRequiredReasonToString(PassphraseRequiredReason reason) {
+ switch (reason) {
+ case UNKNOWN:
+ return "UNKNOWN";
+ case ENCRYPTION:
+ return "ENCRYPTION";
+ case DECRYPTION:
+ return "DECRYPTION";
+ case DECRYPTION_FAILED:
+ return "DECRYPTION_FAILED";
+ default:
+ NOTREACHED();
+ return "INVALID_REASON";
+ }
+}
+
// A UserShare encapsulates the syncable pieces that represent an authenticated
// user and their data (share).
// This encompasses all pieces required to build transaction objects on the
@@ -779,18 +808,12 @@ class SyncManager {
virtual void OnUpdatedToken(const std::string& token) = 0;
// Called when user interaction is required to obtain a valid passphrase.
- // If the passphrase is required to decrypt something that has
- // already been encrypted (and thus has to match the existing key),
- // |for_decryption| will be true. If the passphrase is needed for
- // encryption, |for_decryption| will be false.
- virtual void OnPassphraseRequired(bool for_decryption) = 0;
-
- // Called only by SyncInternal::SetPassphrase to indiciate that an attempted
- // passphrase failed to decrypt pending keys. This is different from
- // OnPassphraseRequired in that it denotes we finished an attempt to set
- // a passphrase. OnPassphraseRequired means we have data we could not
- // decrypt yet, and can come from numerous places.
- virtual void OnPassphraseFailed() = 0;
+ // - If the passphrase is required for encryption, |reason| is ENCRYPTION.
+ // - If the passphrase is required for the decryption of data that has
+ // already been encrypted, |reason| will be DECRYPTION.
+ // - If the passphrase is required because decryption failed, and a new
+ // passphrase is required, |reason| will be DECRYPTION_FAILED.
+ virtual void OnPassphraseRequired(PassphraseRequiredReason reason) = 0;
// Called when the passphrase provided by the user has been accepted and is
// now used to encrypt sync data. |bootstrap_token| is an opaque base64
« no previous file with comments | « no previous file | chrome/browser/sync/engine/syncapi.cc » ('j') | chrome/browser/sync/js_sync_manager_observer_unittest.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698