summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjcivelli@google.com <jcivelli@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2010-11-02 20:04:49 +0000
committerjcivelli@google.com <jcivelli@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2010-11-02 20:04:49 +0000
commitd9b888cdf9ad654a3f2e5c22b935e68db77a71ef (patch)
tree84ffed720a70031d4db103f9d799ebd42f1f37ff
parent844c8edc70381ca48add0fb38d61db890a42f869 (diff)
downloadchromium_src-d9b888cdf9ad654a3f2e5c22b935e68db77a71ef.zip
chromium_src-d9b888cdf9ad654a3f2e5c22b935e68db77a71ef.tar.gz
chromium_src-d9b888cdf9ad654a3f2e5c22b935e68db77a71ef.tar.bz2
Chromium part of the autofill refactor: removing now unused code.
BUG=None TEST=All tests should pass. Autocomplete/autofill should still work. Review URL: http://codereview.chromium.org/4231001 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@64797 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/renderer/password_autocomplete_manager_unittest.cc30
-rw-r--r--chrome/renderer/render_view.cc18
-rw-r--r--chrome/renderer/render_view.h3
-rw-r--r--webkit/glue/dom_operations.cc165
-rw-r--r--webkit/glue/dom_operations.h7
5 files changed, 9 insertions, 214 deletions
diff --git a/chrome/renderer/password_autocomplete_manager_unittest.cc b/chrome/renderer/password_autocomplete_manager_unittest.cc
index 8b1f451..2fc323f 100644
--- a/chrome/renderer/password_autocomplete_manager_unittest.cc
+++ b/chrome/renderer/password_autocomplete_manager_unittest.cc
@@ -152,26 +152,9 @@ class PasswordAutocompleteManagerTest : public RenderViewTest {
DISALLOW_COPY_AND_ASSIGN(PasswordAutocompleteManagerTest);
};
-#if defined(WEBKIT_BUG_41283_IS_FIXED)
-#define MAYBE_InitialAutocomplete InitialAutocomplete
-#define MAYBE_NoInitialAutocompleteForReadOnly NoInitialAutocompleteForReadOnly
-#define MAYBE_PasswordClearOnEdit PasswordClearOnEdit
-#define MAYBE_WaitUsername WaitUsername
-#define MAYBE_InlineAutocomplete InlineAutocomplete
-#define MAYBE_SuggestionSelect SuggestionSelect
-#else
-#define MAYBE_InitialAutocomplete DISABLED_InitialAutocomplete
-#define MAYBE_NoInitialAutocompleteForReadOnly \
- DISABLED_NoInitialAutocompleteForReadOnly
-#define MAYBE_PasswordClearOnEdit DISABLED_PasswordClearOnEdit
-#define MAYBE_WaitUsername DISABLED_WaitUsername
-#define MAYBE_InlineAutocomplete DISABLED_InlineAutocomplete
-#define MAYBE_SuggestionSelect DISABLED_SuggestionSelect
-#endif
-
// Tests that the password login is autocompleted as expected when the browser
// sends back the password info.
-TEST_F(PasswordAutocompleteManagerTest, MAYBE_InitialAutocomplete) {
+TEST_F(PasswordAutocompleteManagerTest, InitialAutocomplete) {
/*
* Right now we are not sending the message to the browser because we are
* loading a data URL and the security origin canAccessPasswordManager()
@@ -203,8 +186,7 @@ TEST_F(PasswordAutocompleteManagerTest, MAYBE_InitialAutocomplete) {
}
// Tests that changing the username does not fill a read-only password field.
-TEST_F(PasswordAutocompleteManagerTest,
- MAYBE_NoInitialAutocompleteForReadOnly) {
+TEST_F(PasswordAutocompleteManagerTest, NoInitialAutocompleteForReadOnly) {
password_element_.setAttribute(WebString::fromUTF8("readonly"),
WebString::fromUTF8("true"));
@@ -218,7 +200,7 @@ TEST_F(PasswordAutocompleteManagerTest,
}
// Tests that editing the password clears the autocompleted password field.
-TEST_F(PasswordAutocompleteManagerTest, MAYBE_PasswordClearOnEdit) {
+TEST_F(PasswordAutocompleteManagerTest, PasswordClearOnEdit) {
// Simulate the browser sending back the login info, it triggers the
// autocomplete.
SimulateOnFillPasswordForm(fill_data_);
@@ -232,7 +214,7 @@ TEST_F(PasswordAutocompleteManagerTest, MAYBE_PasswordClearOnEdit) {
// Tests that we only autocomplete on focus lost and with a full username match
// when |wait_for_username| is true.
-TEST_F(PasswordAutocompleteManagerTest, MAYBE_WaitUsername) {
+TEST_F(PasswordAutocompleteManagerTest, WaitUsername) {
// Simulate the browser sending back the login info.
fill_data_.wait_for_username = true;
SimulateOnFillPasswordForm(fill_data_);
@@ -265,7 +247,7 @@ TEST_F(PasswordAutocompleteManagerTest, MAYBE_WaitUsername) {
}
// Tests that inline autocompletion works properly.
-TEST_F(PasswordAutocompleteManagerTest, MAYBE_InlineAutocomplete) {
+TEST_F(PasswordAutocompleteManagerTest, InlineAutocomplete) {
// Simulate the browser sending back the login info.
SimulateOnFillPasswordForm(fill_data_);
@@ -311,7 +293,7 @@ TEST_F(PasswordAutocompleteManagerTest, MAYBE_InlineAutocomplete) {
}
// Tests that selecting and item in the suggestion drop-down works.
-TEST_F(PasswordAutocompleteManagerTest, MAYBE_SuggestionSelect) {
+TEST_F(PasswordAutocompleteManagerTest, SuggestionSelect) {
// Simulate the browser sending back the login info.
SimulateOnFillPasswordForm(fill_data_);
diff --git a/chrome/renderer/render_view.cc b/chrome/renderer/render_view.cc
index 8cd10be..471c2a5 100644
--- a/chrome/renderer/render_view.cc
+++ b/chrome/renderer/render_view.cc
@@ -2025,13 +2025,10 @@ void RenderView::didExecuteCommand(const WebString& command_name) {
void RenderView::textFieldDidEndEditing(
const WebKit::WebInputElement& element) {
-#if defined(WEBKIT_BUG_41283_IS_FIXED)
password_autocomplete_manager_->TextFieldDidEndEditing(element);
-#endif
}
void RenderView::textFieldDidChange(const WebKit::WebInputElement& element) {
-#if defined(WEBKIT_BUG_41283_IS_FIXED)
// We post a task for doing the AutoFill as the caret position is not set
// properly at this point (http://bugs.webkit.org/show_bug.cgi?id=16976) and
// it is needed to trigger autofill.
@@ -2040,7 +2037,6 @@ void RenderView::textFieldDidChange(const WebKit::WebInputElement& element) {
FROM_HERE,
autofill_method_factory_.NewRunnableMethod(
&RenderView::TextFieldDidChangeImpl, element));
-#endif
}
void RenderView::TextFieldDidChangeImpl(
@@ -2079,9 +2075,7 @@ void RenderView::SendPendingAccessibilityNotifications() {
void RenderView::textFieldDidReceiveKeyDown(
const WebKit::WebInputElement& element,
const WebKit::WebKeyboardEvent& event) {
-#if defined(WEBKIT_BUG_41283_IS_FIXED)
password_autocomplete_manager_->TextFieldHandlingKeyDown(element, event);
-#endif
}
bool RenderView::handleCurrentKeyboardEvent() {
@@ -2375,12 +2369,6 @@ void RenderView::didUpdateInspectorSetting(const WebString& key,
value.utf8()));
}
-void RenderView::queryAutofillSuggestions(const WebNode& node,
- const WebString& name,
- const WebString& value) {
- autofill_helper_->QueryAutoFillSuggestions(node);
-}
-
void RenderView::removeAutofillSuggestions(const WebString& name,
const WebString& value) {
autofill_helper_->RemoveAutocompleteSuggestion(name, value);
@@ -2407,12 +2395,10 @@ void RenderView::didClearAutoFillSelection(const WebKit::WebNode& node) {
void RenderView::didAcceptAutocompleteSuggestion(
const WebKit::WebInputElement& user_element) {
-#if defined(WEBKIT_BUG_41283_IS_FIXED)
bool result = password_autocomplete_manager_->FillPassword(user_element);
// Since this user name was selected from a suggestion list, we should always
// have password for it.
DCHECK(result);
-#endif
}
// WebKit::WebWidgetClient ----------------------------------------------------
@@ -4456,12 +4442,8 @@ void RenderView::OnDragSourceSystemDragEnded() {
void RenderView::OnFillPasswordForm(
const webkit_glue::PasswordFormFillData& form_data) {
-#if defined(WEBKIT_BUG_41283_IS_FIXED)
password_autocomplete_manager_->ReceivedPasswordFormFillData(webview(),
form_data);
-#else
- webkit_glue::FillPasswordForm(this->webview(), form_data);
-#endif
}
void RenderView::OnDragTargetDragEnter(const WebDropData& drop_data,
diff --git a/chrome/renderer/render_view.h b/chrome/renderer/render_view.h
index a39aa63..1d23987 100644
--- a/chrome/renderer/render_view.h
+++ b/chrome/renderer/render_view.h
@@ -434,9 +434,6 @@ class RenderView : public RenderWidget,
WebKit::WebAccessibilityNotification notification);
virtual void didUpdateInspectorSetting(const WebKit::WebString& key,
const WebKit::WebString& value);
- virtual void queryAutofillSuggestions(const WebKit::WebNode& node,
- const WebKit::WebString& name,
- const WebKit::WebString& value);
virtual void removeAutofillSuggestions(const WebKit::WebString& name,
const WebKit::WebString& value);
virtual void didAcceptAutoFillSuggestion(const WebKit::WebNode& node,
diff --git a/webkit/glue/dom_operations.cc b/webkit/glue/dom_operations.cc
index aab6f36..2d0fb68 100644
--- a/webkit/glue/dom_operations.cc
+++ b/webkit/glue/dom_operations.cc
@@ -9,30 +9,28 @@
#include "base/compiler_specific.h"
#include "base/string_number_conversions.h"
#include "base/string_split.h"
+#include "base/string_util.h"
#include "third_party/WebKit/WebKit/chromium/public/WebAnimationController.h"
#include "third_party/WebKit/WebKit/chromium/public/WebDocument.h"
#include "third_party/WebKit/WebKit/chromium/public/WebElement.h"
-#include "third_party/WebKit/WebKit/chromium/public/WebFormElement.h"
#include "third_party/WebKit/WebKit/chromium/public/WebFrame.h"
#include "third_party/WebKit/WebKit/chromium/public/WebInputElement.h"
#include "third_party/WebKit/WebKit/chromium/public/WebNode.h"
#include "third_party/WebKit/WebKit/chromium/public/WebNodeCollection.h"
#include "third_party/WebKit/WebKit/chromium/public/WebNodeList.h"
+#include "third_party/WebKit/WebKit/chromium/public/WebString.h"
#include "third_party/WebKit/WebKit/chromium/public/WebVector.h"
#include "third_party/WebKit/WebKit/chromium/public/WebView.h"
-#include "webkit/glue/form_data.h"
-#include "webkit/glue/password_form_dom_manager.h"
-#include "webkit/glue/webpasswordautocompletelistener_impl.h"
using WebKit::WebAnimationController;
using WebKit::WebDocument;
using WebKit::WebElement;
-using WebKit::WebFormElement;
using WebKit::WebFrame;
using WebKit::WebInputElement;
using WebKit::WebNode;
using WebKit::WebNodeCollection;
using WebKit::WebNodeList;
+using WebKit::WebString;
using WebKit::WebVector;
using WebKit::WebView;
@@ -153,163 +151,6 @@ void GetAllSavableResourceLinksForFrame(WebFrame* current_frame,
namespace webkit_glue {
-// Map element name to a list of pointers to corresponding elements to simplify
-// form filling.
-typedef std::map<string16, WebKit::WebInputElement>
- FormInputElementMap;
-
-// Utility struct for form lookup and autofill. When we parse the DOM to lookup
-// a form, in addition to action and origin URL's we have to compare all
-// necessary form elements. To avoid having to look these up again when we want
-// to fill the form, the FindFormElements function stores the pointers
-// in a FormElements* result, referenced to ensure they are safe to use.
-struct FormElements {
- WebFormElement form_element;
- FormInputElementMap input_elements;
- FormElements() {
- }
-};
-
-typedef std::vector<FormElements*> FormElementsList;
-
-// Internal implementation of FillForm API.
-static bool FillFormImpl(FormElements* fe, const FormData& data) {
- if (!fe->form_element.autoComplete())
- return false;
-
- std::map<string16, string16> data_map;
- for (size_t i = 0; i < data.fields.size(); i++)
- data_map[data.fields[i].name()] = data.fields[i].value();
-
- for (FormInputElementMap::iterator it = fe->input_elements.begin();
- it != fe->input_elements.end(); ++it) {
- WebKit::WebInputElement& element = it->second;
- if (!element.value().isEmpty()) // Don't overwrite pre-filled values.
- continue;
- if (element.isPasswordField() &&
- (!element.isEnabledFormControl() || element.hasAttribute("readonly"))) {
- continue; // Don't fill uneditable password fields.
- }
- if (!element.isValidValue(data_map[it->first]))
- continue;
-
- element.setValue(data_map[it->first]);
- element.setAutofilled(true);
- element.dispatchFormControlChangeEvent();
- }
-
- return false;
-}
-
-// Helper to search the given form element for the specified input elements
-// in |data|, and add results to |result|.
-static bool FindFormInputElements(WebFormElement* fe,
- const FormData& data,
- FormElements* result) {
- // Loop through the list of elements we need to find on the form in
- // order to autofill it. If we don't find any one of them, abort
- // processing this form; it can't be the right one.
- for (size_t j = 0; j < data.fields.size(); j++) {
- WebVector<WebNode> temp_elements;
- fe->getNamedElements(data.fields[j].name(), temp_elements);
- if (temp_elements.isEmpty()) {
- // We didn't find a required element. This is not the right form.
- // Make sure no input elements from a partially matched form
- // in this iteration remain in the result set.
- // Note: clear will remove a reference from each InputElement.
- result->input_elements.clear();
- return false;
- }
- // This element matched, add it to our temporary result. It's possible
- // there are multiple matches, but for purposes of identifying the form
- // one suffices and if some function needs to deal with multiple
- // matching elements it can get at them through the FormElement*.
- // Note: This assignment adds a reference to the InputElement.
- result->input_elements[data.fields[j].name()] =
- temp_elements[0].to<WebInputElement>();
- }
- return true;
-}
-
-// Helper to locate form elements identified by |data|.
-static void FindFormElements(WebView* view,
- const FormData& data,
- FormElementsList* results) {
- DCHECK(view);
- DCHECK(results);
- WebFrame* main_frame = view->mainFrame();
- if (!main_frame)
- return;
-
- GURL::Replacements rep;
- rep.ClearQuery();
- rep.ClearRef();
-
- // Loop through each frame.
- for (WebFrame* f = main_frame; f; f = f->traverseNext(false)) {
- WebDocument doc = f->document();
- if (!doc.isHTMLDocument())
- continue;
-
- GURL full_origin(f->url());
- if (data.origin != full_origin.ReplaceComponents(rep))
- continue;
-
- WebVector<WebFormElement> forms;
- f->forms(forms);
-
- for (size_t i = 0; i < forms.size(); ++i) {
- WebFormElement fe = forms[i];
- // Action URL must match.
- GURL full_action(f->document().completeURL(fe.action()));
- if (data.action != full_action.ReplaceComponents(rep))
- continue;
-
- scoped_ptr<FormElements> curr_elements(new FormElements);
- if (!FindFormInputElements(&fe, data, curr_elements.get()))
- continue;
-
- // We found the right element.
- // Note: this assignment adds a reference to |fe|.
- curr_elements->form_element = fe;
- results->push_back(curr_elements.release());
- }
- }
-}
-
-void FillPasswordForm(WebView* view,
- const PasswordFormFillData& data) {
- FormElementsList forms;
- // We own the FormElements* in forms.
- FindFormElements(view, data.basic_data, &forms);
- FormElementsList::iterator iter;
- for (iter = forms.begin(); iter != forms.end(); ++iter) {
- scoped_ptr<FormElements> form_elements(*iter);
-
- // If wait_for_username is true, we don't want to initially fill the form
- // until the user types in a valid username.
- if (!data.wait_for_username)
- FillFormImpl(form_elements.get(), data.basic_data);
-
- // Attach autocomplete listener to enable selecting alternate logins.
- // First, get pointers to username element.
- WebInputElement username_element =
- form_elements->input_elements[data.basic_data.fields[0].name()];
-
- // Get pointer to password element. (We currently only support single
- // password forms).
- WebInputElement password_element =
- form_elements->input_elements[data.basic_data.fields[1].name()];
-
- username_element.document().frame()->registerPasswordListener(
- username_element,
- new WebPasswordAutocompleteListenerImpl(
- new WebInputElementDelegate(username_element),
- new WebInputElementDelegate(password_element),
- data));
- }
-}
-
WebString GetSubResourceLinkFromElement(const WebElement& element) {
const char* attribute_name = NULL;
if (element.hasTagName("img") ||
diff --git a/webkit/glue/dom_operations.h b/webkit/glue/dom_operations.h
index 1b6151b..951eb0f 100644
--- a/webkit/glue/dom_operations.h
+++ b/webkit/glue/dom_operations.h
@@ -21,13 +21,6 @@ class WebView;
// A collection of operations that access the underlying WebKit DOM directly.
namespace webkit_glue {
-struct PasswordFormFillData;
-
-// Fill matching password forms and trigger autocomplete in the case of multiple
-// matching logins.
-void FillPasswordForm(WebKit::WebView* view,
- const PasswordFormFillData& data);
-
// Structure for storage the result of getting all savable resource links
// for current page. The consumer of the SavableResourcesResult is responsible
// for keeping these pointers valid for the lifetime of the