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

Unified Diff: chrome/browser/extensions/api/passwords_private/passwords_private_api.h

Issue 1142693003: Implement the chrome.passwordsPrivate API. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add password_ui_view_android.h. Created 5 years, 7 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/extensions/api/passwords_private/passwords_private_api.h
diff --git a/chrome/browser/extensions/api/passwords_private/passwords_private_api.h b/chrome/browser/extensions/api/passwords_private/passwords_private_api.h
index 4cef1917f65877cd7aac77e2b9afeac96a7b7e94..0b1178e4389ded0dbddda8b498cdd587a0ec1303 100644
--- a/chrome/browser/extensions/api/passwords_private/passwords_private_api.h
+++ b/chrome/browser/extensions/api/passwords_private/passwords_private_api.h
@@ -8,6 +8,8 @@
#include <string>
#include "base/macros.h"
+#include "chrome/browser/extensions/api/passwords_private/passwords_private_delegate.h"
+#include "chrome/browser/ui/passwords/password_manager_presenter.h"
#include "extensions/browser/extension_function.h"
namespace extensions {
@@ -66,8 +68,8 @@ class PasswordsPrivateRemovePasswordExceptionFunction :
class PasswordsPrivateGetPlaintextPasswordFunction :
public UIThreadExtensionFunction {
public:
- PasswordsPrivateGetPlaintextPasswordFunction() {}
- DECLARE_EXTENSION_FUNCTION("passwordsPrivate.GetPlaintextPassword",
+ PasswordsPrivateGetPlaintextPasswordFunction();
+ DECLARE_EXTENSION_FUNCTION("passwordsPrivate.getPlaintextPassword",
PASSWORDSPRIVATE_GETPLAINTEXTPASSWORD);
protected:
@@ -77,6 +79,45 @@ class PasswordsPrivateGetPlaintextPasswordFunction :
ResponseAction Run() override;
private:
+ // Called by the observer when the password has been retrieved so that this
+ // function can return the password value.
+ void ReplyWithPlaintextPassword(const std::string& plaintext_password);
+
+ // Observer used by PasswordsPrivateGetPlaintextPasswordFunction to listen
+ // for when PasswordsPrivateDelegate fetches the requested plaintext
+ // password.
+ 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.
+ public extensions::PasswordsPrivateDelegate::Observer {
+ public:
+ PlaintextPasswordObserver(
+ const extensions::api::passwords_private::LoginPair& login_pair,
+ const scoped_refptr<extensions::
+ PasswordsPrivateGetPlaintextPasswordFunction> fn_needing_reply,
+ extensions::PasswordsPrivateDelegate* delegate);
+ ~PlaintextPasswordObserver() override;
+
+ // extensions::PasswordsPrivateDelegate::Observer overrides;
+ void OnPlaintextPasswordFetched(
+ const std::string& origin_url,
+ const std::string& username,
+ const std::string& password_value) override;
+
+ private:
+ // The LoginPair whose password is being requested.
+ extensions::api::passwords_private::LoginPair login_pair_;
+
+ // The function waiting on a response containing the password. A
+ // scoped_refptr is used to ensure that the function is not deleted before
+ // the plaintext password has been returned.
+ scoped_refptr<extensions::PasswordsPrivateGetPlaintextPasswordFunction>
+ fn_needing_reply_;
+
+ // The delegate this class is observing.
+ extensions::PasswordsPrivateDelegate* delegate_;
+ };
+
+ PlaintextPasswordObserver* observer_;
+
DISALLOW_COPY_AND_ASSIGN(PasswordsPrivateGetPlaintextPasswordFunction);
};

Powered by Google App Engine
This is Rietveld 408576698