Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CHROME_BROWSER_EXTENSIONS_API_PASSWORDS_PRIVATE_PASSWORDS_PRIVATE_API_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_API_PASSWORDS_PRIVATE_PASSWORDS_PRIVATE_API_H_ |
| 6 #define CHROME_BROWSER_EXTENSIONS_API_PASSWORDS_PRIVATE_PASSWORDS_PRIVATE_API_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_API_PASSWORDS_PRIVATE_PASSWORDS_PRIVATE_API_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| 11 #include "chrome/browser/extensions/api/passwords_private/passwords_private_dele gate.h" | |
| 12 #include "chrome/browser/ui/passwords/password_manager_presenter.h" | |
| 11 #include "extensions/browser/extension_function.h" | 13 #include "extensions/browser/extension_function.h" |
| 12 | 14 |
| 13 namespace extensions { | 15 namespace extensions { |
| 14 | 16 |
| 15 class PasswordsPrivateCanPasswordAccountBeManagedFunction : | 17 class PasswordsPrivateCanPasswordAccountBeManagedFunction : |
| 16 public UIThreadExtensionFunction { | 18 public UIThreadExtensionFunction { |
| 17 public: | 19 public: |
| 18 PasswordsPrivateCanPasswordAccountBeManagedFunction() {} | 20 PasswordsPrivateCanPasswordAccountBeManagedFunction() {} |
| 19 DECLARE_EXTENSION_FUNCTION("passwordsPrivate.canPasswordAccountBeManaged", | 21 DECLARE_EXTENSION_FUNCTION("passwordsPrivate.canPasswordAccountBeManaged", |
| 20 PASSWORDSPRIVATE_CANPASSWORDACCOUNTBEMANAGED); | 22 PASSWORDSPRIVATE_CANPASSWORDACCOUNTBEMANAGED); |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 59 // ExtensionFunction overrides. | 61 // ExtensionFunction overrides. |
| 60 ResponseAction Run() override; | 62 ResponseAction Run() override; |
| 61 | 63 |
| 62 private: | 64 private: |
| 63 DISALLOW_COPY_AND_ASSIGN(PasswordsPrivateRemovePasswordExceptionFunction); | 65 DISALLOW_COPY_AND_ASSIGN(PasswordsPrivateRemovePasswordExceptionFunction); |
| 64 }; | 66 }; |
| 65 | 67 |
| 66 class PasswordsPrivateGetPlaintextPasswordFunction : | 68 class PasswordsPrivateGetPlaintextPasswordFunction : |
| 67 public UIThreadExtensionFunction { | 69 public UIThreadExtensionFunction { |
| 68 public: | 70 public: |
| 69 PasswordsPrivateGetPlaintextPasswordFunction() {} | 71 PasswordsPrivateGetPlaintextPasswordFunction(); |
| 70 DECLARE_EXTENSION_FUNCTION("passwordsPrivate.GetPlaintextPassword", | 72 DECLARE_EXTENSION_FUNCTION("passwordsPrivate.getPlaintextPassword", |
| 71 PASSWORDSPRIVATE_GETPLAINTEXTPASSWORD); | 73 PASSWORDSPRIVATE_GETPLAINTEXTPASSWORD); |
| 72 | 74 |
| 73 protected: | 75 protected: |
| 74 ~PasswordsPrivateGetPlaintextPasswordFunction() override; | 76 ~PasswordsPrivateGetPlaintextPasswordFunction() override; |
| 75 | 77 |
| 76 // ExtensionFunction overrides. | 78 // ExtensionFunction overrides. |
| 77 ResponseAction Run() override; | 79 ResponseAction Run() override; |
| 78 | 80 |
| 79 private: | 81 private: |
| 82 // Called by the observer when the password has been retrieved so that this | |
| 83 // function can return the password value. | |
| 84 void ReplyWithPlaintextPassword(const std::string& plaintext_password); | |
| 85 | |
| 86 // Observer used by PasswordsPrivateGetPlaintextPasswordFunction to listen | |
| 87 // for when PasswordsPrivateDelegate fetches the requested plaintext | |
| 88 // password. | |
| 89 class PlaintextPasswordObserver : | |
|
Ken Rockot(use gerrit already)
2015/05/22 16:42:28
You can just declare the existence of the class he
Kyle Horimoto
2015/05/22 17:52:53
Done.
| |
| 90 public extensions::PasswordsPrivateDelegate::Observer { | |
| 91 public: | |
| 92 PlaintextPasswordObserver( | |
| 93 const extensions::api::passwords_private::LoginPair& login_pair, | |
| 94 const scoped_refptr<extensions:: | |
| 95 PasswordsPrivateGetPlaintextPasswordFunction> fn_needing_reply, | |
| 96 extensions::PasswordsPrivateDelegate* delegate); | |
| 97 ~PlaintextPasswordObserver() override; | |
| 98 | |
| 99 // extensions::PasswordsPrivateDelegate::Observer overrides; | |
| 100 void OnPlaintextPasswordFetched( | |
| 101 const std::string& origin_url, | |
| 102 const std::string& username, | |
| 103 const std::string& password_value) override; | |
| 104 | |
| 105 private: | |
| 106 // The LoginPair whose password is being requested. | |
| 107 extensions::api::passwords_private::LoginPair login_pair_; | |
| 108 | |
| 109 // The function waiting on a response containing the password. A | |
| 110 // scoped_refptr is used to ensure that the function is not deleted before | |
| 111 // the plaintext password has been returned. | |
| 112 scoped_refptr<extensions::PasswordsPrivateGetPlaintextPasswordFunction> | |
| 113 fn_needing_reply_; | |
| 114 | |
| 115 // The delegate this class is observing. | |
| 116 extensions::PasswordsPrivateDelegate* delegate_; | |
| 117 }; | |
| 118 | |
| 119 PlaintextPasswordObserver* observer_; | |
| 120 | |
| 80 DISALLOW_COPY_AND_ASSIGN(PasswordsPrivateGetPlaintextPasswordFunction); | 121 DISALLOW_COPY_AND_ASSIGN(PasswordsPrivateGetPlaintextPasswordFunction); |
| 81 }; | 122 }; |
| 82 | 123 |
| 83 } // namespace extensions | 124 } // namespace extensions |
| 84 | 125 |
| 85 #endif // CHROME_BROWSER_EXTENSIONS_API_PASSWORDS_PRIVATE_PASSWORDS_PRIVATE_API _H_ | 126 #endif // CHROME_BROWSER_EXTENSIONS_API_PASSWORDS_PRIVATE_PASSWORDS_PRIVATE_API _H_ |
| OLD | NEW |