summaryrefslogtreecommitdiffstats
path: root/chrome/renderer/password_autocomplete_manager.h
diff options
context:
space:
mode:
authorjcivelli@google.com <jcivelli@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2010-07-14 17:36:08 +0000
committerjcivelli@google.com <jcivelli@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2010-07-14 17:36:08 +0000
commit03f57072cd19125c59fbc1d7c76f2856ca200850 (patch)
tree80eadc11ae10e48c8c21fe2bc6dfe50dd4a32ec6 /chrome/renderer/password_autocomplete_manager.h
parenta2a7fcfe13e9d42c35cb79a0c57d02c3ce7778ea (diff)
downloadchromium_src-03f57072cd19125c59fbc1d7c76f2856ca200850.zip
chromium_src-03f57072cd19125c59fbc1d7c76f2856ca200850.tar.gz
chromium_src-03f57072cd19125c59fbc1d7c76f2856ca200850.tar.bz2
First step in moving the password autocomplete code from the WebKit API
to the Chromium code. This is currently behind a #define that will be defined in the WebKit API when the change is finished on that side. PasswordAutocompleteManager replaces webpasswordautocompletelistener_impl.cc, it is responsible for trigering password autocomplete The unit-tests in webpasswordautocompletelistener_unittest.cc have been ported to password_autocomplete_manager_unittest.cc. They are now test shell unit-tests so we don't have to use a wrapper around WebElements. BUG=None TEST=The new code is not yet enabled. Test that the password autocomplete still works as expected. Review URL: http://codereview.chromium.org/2827030 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@52342 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/renderer/password_autocomplete_manager.h')
-rw-r--r--chrome/renderer/password_autocomplete_manager.h90
1 files changed, 90 insertions, 0 deletions
diff --git a/chrome/renderer/password_autocomplete_manager.h b/chrome/renderer/password_autocomplete_manager.h
new file mode 100644
index 0000000..a931026
--- /dev/null
+++ b/chrome/renderer/password_autocomplete_manager.h
@@ -0,0 +1,90 @@
+// Copyright (c) 2010 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_RENDERER_PASSWORD_AUTOCOMPLETE_MANAGER_H_
+#define CHROME_RENDERER_PASSWORD_AUTOCOMPLETE_MANAGER_H_
+
+#include <map>
+#include <vector>
+
+#include "base/task.h"
+#include "webkit/glue/password_form_dom_manager.h"
+#include "third_party/WebKit/WebKit/chromium/public/WebInputElement.h"
+
+class RenderView;
+namespace WebKit {
+class WebKeyboardEvent;
+class WebView;
+}
+
+// This class is responsible for filling password forms.
+// There is one PasswordAutocompleteManager per RenderView.
+class PasswordAutocompleteManager {
+ public:
+ explicit PasswordAutocompleteManager(RenderView* render_view);
+ virtual ~PasswordAutocompleteManager() {}
+
+ // Invoked by the renderer when it receives the password info from the
+ // browser. This triggers a password autocomplete (if wait_for_username is
+ // false on |form_data|).
+ void ReceivedPasswordFormFillData(WebKit::WebView* view,
+ const webkit_glue::PasswordFormDomManager::FillData& form_data);
+
+ // Invoked when the passed frame is closing. Gives us a chance to clear any
+ // reference we may have to elements in that frame.
+ void FrameClosing(const WebKit::WebFrame* frame);
+
+ // Fills the password associated with |user_input|, using its current value
+ // as the actual user name. Returns true if the password field was filled,
+ // false otherwise, typically if there was no matching suggestions for the
+ // currently typed username.
+ bool FillPassword(const WebKit::WebInputElement& user_input);
+
+ // Fills |login_input| and |password| with the most relevant suggestion from
+ // |fill_data| and shows a popup with other suggestions.
+ void PerformInlineAutocomplete(
+ const WebKit::WebInputElement& username,
+ const WebKit::WebInputElement& password,
+ const webkit_glue::PasswordFormDomManager::FillData& fill_data);
+
+ // WebViewClient editor related calls forwarded by the RenderView.
+ void TextFieldDidBeginEditing(const WebKit::WebInputElement& element);
+ void TextFieldDidEndEditing(const WebKit::WebInputElement& element);
+ void TextDidChangeInTextField(const WebKit::WebInputElement& element);
+ void TextFieldHandlingKeyDown(const WebKit::WebInputElement& element,
+ const WebKit::WebKeyboardEvent& event);
+
+ private:
+ struct PasswordInfo {
+ WebKit::WebInputElement password_field;
+ webkit_glue::PasswordFormDomManager::FillData fill_data;
+ bool backspace_pressed_last;
+ PasswordInfo() : backspace_pressed_last(false) {}
+ };
+ typedef std::map<WebKit::WebElement, PasswordInfo> LoginToPasswordInfoMap;
+
+ void GetSuggestions(
+ const webkit_glue::PasswordFormDomManager::FillData& fill_data,
+ const string16& input,
+ std::vector<string16>* suggestions);
+
+ bool ShowSuggestionPopup(
+ const webkit_glue::PasswordFormDomManager::FillData& fill_data,
+ const WebKit::WebInputElement& user_input);
+
+ bool FillUserNameAndPassword(
+ WebKit::WebInputElement* username_element,
+ WebKit::WebInputElement* password_element,
+ const webkit_glue::PasswordFormDomManager::FillData& fill_data,
+ bool exact_username_match);
+
+ // The logins we have filled so far with their associated info.
+ LoginToPasswordInfoMap login_to_password_info_;
+
+ ScopedRunnableMethodFactory<PasswordAutocompleteManager> method_factory_;
+
+ DISALLOW_COPY_AND_ASSIGN(PasswordAutocompleteManager);
+};
+
+#endif // CHROME_RENDERER_PASSWORD_AUTOCOMPLETE_MANAGER_H_