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

Unified Diff: components/password_manager/core/browser/password_autofill_manager.h

Issue 184103016: Autofill: Refactoring to support fetching password after a username is selected (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Get unit tests compiling. Created 6 years, 9 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: components/password_manager/core/browser/password_autofill_manager.h
diff --git a/components/password_manager/core/browser/password_autofill_manager.h b/components/password_manager/core/browser/password_autofill_manager.h
new file mode 100644
index 0000000000000000000000000000000000000000..e2c3df908b0d12196047051b7babbeaabf8d6e01
--- /dev/null
+++ b/components/password_manager/core/browser/password_autofill_manager.h
@@ -0,0 +1,103 @@
+// Copyright 2013 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 COMPONENTS_PASSWORD_MANAGER_CORE_BROWSER_PASSWORD_AUTOFILL_MANAGER_H_
+#define COMPONENTS_PASSWORD_MANAGER_CORE_BROWSER_PASSWORD_AUTOFILL_MANAGER_H_
+
+// This file was contains some repeated code from
+// chrome/renderer/autofill/password_autofill_manager because as we move to the
+// new Autofill UI we needs these functions in both the browser and renderer.
+// Once the move is completed the repeated code in the renderer half should be
+// removed.
+// http://crbug.com/51644
Garrett Casto 2014/03/14 08:25:22 I can't tell if this should be updated or removed.
Patrick Dubroy 2014/03/14 12:07:19 Removed, because I'm pretty sure this is obsolete.
Garrett Casto 2014/03/14 23:24:22 FWIW, the explanatory text and crbug.com/118601 de
+
+#include <map>
+
+#include "base/gtest_prod_util.h"
+#include "components/autofill/core/browser/autofill_manager_delegate.h"
+#include "components/autofill/core/browser/autofill_popup_delegate.h"
+#include "components/autofill/core/common/password_form_fill_data.h"
+
+class PasswordManagerClient;
+
+namespace gfx {
+class RectF;
+}
+
+// This class is responsible for filling password forms.
+class PasswordAutofillManager : public autofill::AutofillPopupDelegate {
+ public:
+ PasswordAutofillManager(
+ PasswordManagerClient* password_manager_client,
+ autofill::AutofillManagerDelegate* autofill_manager_delegate);
+ virtual ~PasswordAutofillManager();
+
+ // AutofillPopupDelegate implementation.
+ virtual void OnPopupShown() OVERRIDE;
+ virtual void OnPopupHidden() OVERRIDE;
+ virtual bool ShouldRepostEvent(const ui::MouseEvent& event) OVERRIDE;
+ virtual void DidSelectSuggestion(int identifier) OVERRIDE;
+ virtual void DidAcceptSuggestion(const base::string16& value,
+ int identifier) OVERRIDE;
+ virtual void RemoveSuggestion(const base::string16& value,
+ int identifier) OVERRIDE;
+ virtual void ClearPreviewedForm() OVERRIDE;
+
+ // Invoked when a password mapping is added.
+ void AddPasswordFormMapping(
+ const autofill::FormFieldData& username_element,
+ const autofill::PasswordFormFillData& password);
+
+ void ShowPasswordSuggestions(
+ const autofill::FormFieldData& field,
+ const gfx::RectF& bounds,
+ const std::vector<base::string16>& suggestions,
+ const std::vector<base::string16>& realms);
+
+ // Invoked to clear any page specific cached values.
+ void Reset();
+
+ private:
+ FRIEND_TEST_ALL_PREFIXES(PasswordAutofillManagerTest,
+ AcceptAutofillSuggestion);
+
+ // TODO(csharp): Modify the AutofillExternalDeletegate code so that it can
Garrett Casto 2014/03/14 08:25:22 Update comment.
Patrick Dubroy 2014/03/14 12:07:19 I think this is also obsolete -- removed.
+ // figure out if a entry is a password one without using this mapping.
+ // crbug.com/118601
+ typedef std::map<autofill::FormFieldData, autofill::PasswordFormFillData>
+ LoginToPasswordInfoMap;
+
+ // Attempts to fill the password associated with user name |username|, and
+ // returns true if it was successful.
+ bool AcceptAutofillSuggestion(const autofill::FormFieldData& field,
+ const base::string16& username);
+
+ // If |current_username| matches a username for one of the login mappings in
+ // |fill_data|, returns true and assigns the password to |out_password|.
+ // Otherwise, returns false and leaves |out_password| untouched.
+ bool GetPasswordForUsername(
+ const base::string16& current_username,
+ const autofill::PasswordFormFillData& fill_data,
+ base::string16* out_password);
+
+ // Finds login information for a |node| that was previously filled.
+ bool FindLoginInfo(const autofill::FormFieldData& field,
+ autofill::PasswordFormFillData* found_password);
+
+ // The logins we have filled so far with their associated info.
+ LoginToPasswordInfoMap login_to_password_info_;
+
+ // Provides embedder-level operations on passwords. Must outlive |this|.
+ PasswordManagerClient* const password_manager_client_; // weak
+
+ autofill::AutofillManagerDelegate* const autofill_manager_delegate_; // weak
+
+ autofill::FormFieldData form_field_;
+
+ base::WeakPtrFactory<PasswordAutofillManager> weak_ptr_factory_;
+
+ DISALLOW_COPY_AND_ASSIGN(PasswordAutofillManager);
+};
+
+#endif // COMPONENTS_PASSWORD_MANAGER_CORE_BROWSER_PASSWORD_AUTOFILL_MANAGER_H_

Powered by Google App Engine
This is Rietveld 408576698