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

Unified Diff: chrome/browser/signin/easy_unlock_auth_attempt.h

Issue 585213002: [Easy signin] Wire up userClick auth attempt to easy unlock app and back (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@easy_signin_focused_user_changed_observer
Patch Set: fix screenlock private test Created 6 years, 3 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/signin/easy_unlock_auth_attempt.h
diff --git a/chrome/browser/signin/easy_unlock_auth_attempt.h b/chrome/browser/signin/easy_unlock_auth_attempt.h
new file mode 100644
index 0000000000000000000000000000000000000000..312074500cb88f78af0700f0e9e9ce5c36d0dc70
--- /dev/null
+++ b/chrome/browser/signin/easy_unlock_auth_attempt.h
@@ -0,0 +1,71 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_SIGNIN_EASY_UNLOCK_AUTH_ATTEMPT_H_
+#define CHROME_BROWSER_SIGNIN_EASY_UNLOCK_AUTH_ATTEMPT_H_
+
+#include <string>
+
+#include "base/macros.h"
+
+class Profile;
+
+// Class responsible for handling easy unlock auth attempts (both for unlocking
+// the screen and logging in). The auth protocol is started by calling |Start|,
+// which notifies the easy unlock app about auth attempt. When the auth result
+// is available, |FinalizeUnlock| or |FinalizeSignin| should be called,
+// depending on auth type.
+// To cancel the in progress auth attempt, delete the |EasyUnlockAuthAttempt|
+// object.
+class EasyUnlockAuthAttempt {
+ public:
+ // The auth type.
+ enum Type {
+ TYPE_UNLOCK,
+ TYPE_SIGNIN
+ };
+
+ EasyUnlockAuthAttempt(Profile* profile,
+ const std::string& user_id,
+ Type type);
+ ~EasyUnlockAuthAttempt();
+
+ // Starts the auth attempt by sending screenlockPrivate.onAuthAttempted event
+ // to easy unlock app. Returns whether the event was successfully dispatched.
+ bool Start(const std::string& user_id);
+
+ // Finalizes an unlock attempt. It unlocks the screen if |success| is true.
+ // If |this| has TYPE_SIGNIN type, calling this method will cause signin
+ // failure equivalent to cancelling the attempt.
+ void FinalizeUnlock(const std::string& user_id, bool success);
+
+ // Finalizes signin attempt. It tries to log in using the secret derived from
+ // |wrapped_secret| decrypted by |session_key|. If the decryption fails, it
+ // fails the signin attempt.
+ // If called on an object with TYPE_UNLOCK type, it will cause unlock failure
+ // equivalent to cancelling the request.
+ void FinalizeSignin(const std::string& user_id,
+ const std::string& wrapped_secret,
+ const std::string& session_key);
+
+ private:
+ // The internal attempt state.
+ enum State {
+ STATE_IDLE,
+ STATE_RUNNING,
+ STATE_DONE
+ };
+
+ // Cancels the attempt.
+ void Cancel(const std::string& user_id);
+
+ Profile* profile_;
+ State state_;
+ std::string user_id_;
+ Type type_;
+
+ DISALLOW_COPY_AND_ASSIGN(EasyUnlockAuthAttempt);
+};
+
+#endif // CHROME_BROWSER_SIGNIN_EASY_UNLOCK_AUTH_ATTEMPT_H_

Powered by Google App Engine
This is Rietveld 408576698