OLD | NEW |
(Empty) | |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef CHROME_BROWSER_SIGNIN_EASY_UNLOCK_AUTH_ATTEMPT_H_ |
| 6 #define CHROME_BROWSER_SIGNIN_EASY_UNLOCK_AUTH_ATTEMPT_H_ |
| 7 |
| 8 #include <string> |
| 9 |
| 10 #include "base/macros.h" |
| 11 |
| 12 class Profile; |
| 13 |
| 14 // Class responsible for handling easy unlock auth attempts (both for unlocking |
| 15 // the screen and logging in). The auth protocol is started by calling |Start|, |
| 16 // which notifies the easy unlock app about auth attempt. When the auth result |
| 17 // is available, |FinalizeUnlock| or |FinalizeSignin| should be called, |
| 18 // depending on auth type. |
| 19 // To cancel the in progress auth attempt, delete the |EasyUnlockAuthAttempt| |
| 20 // object. |
| 21 class EasyUnlockAuthAttempt { |
| 22 public: |
| 23 // The auth type. |
| 24 enum Type { |
| 25 TYPE_UNLOCK, |
| 26 TYPE_SIGNIN |
| 27 }; |
| 28 |
| 29 EasyUnlockAuthAttempt(Profile* profile, |
| 30 const std::string& user_id, |
| 31 Type type); |
| 32 ~EasyUnlockAuthAttempt(); |
| 33 |
| 34 // Starts the auth attempt by sending screenlockPrivate.onAuthAttempted event |
| 35 // to easy unlock app. Returns whether the event was successfully dispatched. |
| 36 bool Start(const std::string& user_id); |
| 37 |
| 38 // Finalizes an unlock attempt. It unlocks the screen if |success| is true. |
| 39 // If |this| has TYPE_SIGNIN type, calling this method will cause signin |
| 40 // failure equivalent to cancelling the attempt. |
| 41 void FinalizeUnlock(const std::string& user_id, bool success); |
| 42 |
| 43 // Finalizes signin attempt. It tries to log in using the secret derived from |
| 44 // |wrapped_secret| decrypted by |session_key|. If the decryption fails, it |
| 45 // fails the signin attempt. |
| 46 // If called on an object with TYPE_UNLOCK type, it will cause unlock failure |
| 47 // equivalent to cancelling the request. |
| 48 void FinalizeSignin(const std::string& user_id, |
| 49 const std::string& wrapped_secret, |
| 50 const std::string& session_key); |
| 51 |
| 52 private: |
| 53 // The internal attempt state. |
| 54 enum State { |
| 55 STATE_IDLE, |
| 56 STATE_RUNNING, |
| 57 STATE_DONE |
| 58 }; |
| 59 |
| 60 // Cancels the attempt. |
| 61 void Cancel(const std::string& user_id); |
| 62 |
| 63 Profile* profile_; |
| 64 State state_; |
| 65 std::string user_id_; |
| 66 Type type_; |
| 67 |
| 68 DISALLOW_COPY_AND_ASSIGN(EasyUnlockAuthAttempt); |
| 69 }; |
| 70 |
| 71 #endif // CHROME_BROWSER_SIGNIN_EASY_UNLOCK_AUTH_ATTEMPT_H_ |
OLD | NEW |