summaryrefslogtreecommitdiffstats
path: root/webkit
diff options
context:
space:
mode:
authoryaar@chromium.org <yaar@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-11-07 01:30:48 +0000
committeryaar@chromium.org <yaar@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-11-07 01:30:48 +0000
commit979c28b833acd88f976e53b156c9ada2f35e9abf (patch)
treee3a0430d7204f6a34c0a93246bad294bb5a852b4 /webkit
parent13bc0d82bd5c294a7e67a8ab61e07dc01c170a27 (diff)
downloadchromium_src-979c28b833acd88f976e53b156c9ada2f35e9abf.zip
chromium_src-979c28b833acd88f976e53b156c9ada2f35e9abf.tar.gz
chromium_src-979c28b833acd88f976e53b156c9ada2f35e9abf.tar.bz2
Move PasswordAutocompleteListener into the WebKit API (AGAIN)
Copy of: http://codereview.chromium.org/360013/show Head to create as new patch due to messy merge. Review URL: http://codereview.chromium.org/376017 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@31350 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit')
-rw-r--r--webkit/api/WebKit.gyp10
-rw-r--r--webkit/api/public/WebElement.h62
-rw-r--r--webkit/api/public/WebFormElement.h (renamed from webkit/api/public/WebForm.h)53
-rw-r--r--webkit/api/public/WebFrame.h15
-rw-r--r--webkit/api/public/WebFrameClient.h4
-rw-r--r--webkit/api/public/WebInputElement.h68
-rw-r--r--webkit/api/public/WebNode.h34
-rw-r--r--webkit/api/public/WebPasswordAutocompleteListener.h (renamed from webkit/api/src/PasswordAutocompleteListener.h)14
-rw-r--r--webkit/api/public/WebPasswordFormData.h4
-rw-r--r--webkit/api/public/WebSearchableFormData.h4
-rw-r--r--webkit/api/src/EditorClientImpl.cpp8
-rw-r--r--webkit/api/src/FrameLoaderClientImpl.cpp4
-rw-r--r--webkit/api/src/WebElement.cpp58
-rw-r--r--webkit/api/src/WebFormElement.cpp (renamed from webkit/api/src/WebForm.cpp)44
-rw-r--r--webkit/api/src/WebFrameImpl.cpp17
-rw-r--r--webkit/api/src/WebFrameImpl.h20
-rw-r--r--webkit/api/src/WebInputElement.cpp89
-rw-r--r--webkit/api/src/WebNode.cpp14
-rw-r--r--webkit/api/src/WebPasswordFormData.cpp2
-rw-r--r--webkit/api/src/WebSearchableFormData.cpp4
-rw-r--r--webkit/glue/dom_operations.cc76
-rw-r--r--webkit/glue/form_field_values.cc13
-rw-r--r--webkit/glue/form_field_values.h6
-rw-r--r--webkit/glue/glue_util.cc8
-rw-r--r--webkit/glue/glue_util.h8
-rw-r--r--webkit/glue/password_form_dom_manager.cc5
-rw-r--r--webkit/glue/password_form_dom_manager.h2
-rw-r--r--webkit/glue/webpasswordautocompletelistener_impl.cc (renamed from webkit/glue/password_autocomplete_listener_impl.cc)78
-rw-r--r--webkit/glue/webpasswordautocompletelistener_impl.h (renamed from webkit/glue/password_autocomplete_listener_impl.h)54
-rw-r--r--webkit/glue/webpasswordautocompletelistener_unittest.cc (renamed from webkit/glue/password_autocomplete_listener_unittest.cc)107
-rw-r--r--webkit/tools/test_shell/test_shell.gyp2
-rw-r--r--webkit/tools/test_shell/test_webview_delegate.cc2
-rw-r--r--webkit/webkit.gyp4
33 files changed, 594 insertions, 299 deletions
diff --git a/webkit/api/WebKit.gyp b/webkit/api/WebKit.gyp
index 0c8d4ca..0f2b4d1 100644
--- a/webkit/api/WebKit.gyp
+++ b/webkit/api/WebKit.gyp
@@ -94,15 +94,17 @@
'public/WebDevToolsFrontendClient.h',
'public/WebDragData.h',
'public/WebEditingAction.h',
+ 'public/WebElement.h',
'public/WebFileChooserCompletion.h',
'public/WebFindOptions.h',
'public/WebFrame.h',
'public/WebFrameClient.h',
'public/WebFontCache.h',
- 'public/WebForm.h',
+ 'public/WebFormElement.h',
'public/WebHistoryItem.h',
'public/WebHTTPBody.h',
'public/WebImage.h',
+ 'public/WebInputElement.h',
'public/WebInputEvent.h',
'public/WebKit.h',
'public/WebKitClient.h',
@@ -119,6 +121,7 @@
'public/WebNotification.h',
'public/WebNotificationPresenter.h',
'public/WebNotificationPermissionCallback.h',
+ 'public/WebPasswordAutocompleteListener.h',
'public/WebPasswordFormData.h',
'public/WebPlugin.h',
'public/WebPluginContainer.h',
@@ -199,7 +202,6 @@
'src/MediaPlayerPrivateChromium.cpp',
'src/NotificationPresenterImpl.h',
'src/NotificationPresenterImpl.cpp',
- 'src/PasswordAutocompleteListener.h',
'src/PlatformMessagePortChannel.cpp',
'src/PlatformMessagePortChannel.h',
'src/ResourceHandle.cpp',
@@ -228,16 +230,18 @@
'src/WebDataSourceImpl.cpp',
'src/WebDataSourceImpl.h',
'src/WebDragData.cpp',
+ 'src/WebElement.cpp',
'src/WebFileChooserCompletionImpl.cpp',
'src/WebFileChooserCompletionImpl.h',
'src/WebFontCache.cpp',
- 'src/WebForm.cpp',
+ 'src/WebFormElement.cpp',
'src/WebFrameImpl.cpp',
'src/WebFrameImpl.h',
'src/WebHistoryItem.cpp',
'src/WebHTTPBody.cpp',
'src/WebImageCG.cpp',
'src/WebImageSkia.cpp',
+ 'src/WebInputElement.cpp',
'src/WebInputEvent.cpp',
'src/WebInputEventConversion.cpp',
'src/WebInputEventConversion.h',
diff --git a/webkit/api/public/WebElement.h b/webkit/api/public/WebElement.h
new file mode 100644
index 0000000..bfdc081
--- /dev/null
+++ b/webkit/api/public/WebElement.h
@@ -0,0 +1,62 @@
+/*
+ * Copyright (C) 2009 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef WebElement_h
+#define WebElement_h
+
+#include "WebNode.h"
+
+#if WEBKIT_IMPLEMENTATION
+namespace WebCore { class Element; }
+namespace WTF { template <typename T> class PassRefPtr; }
+#endif
+
+namespace WebKit {
+
+ // Provides readonly access to some properties of a DOM element node.
+ class WebElement : public WebNode {
+ public:
+ WebElement() : WebNode() { }
+ WebElement(const WebElement& e) : WebNode(e) { }
+
+ WebElement& operator=(const WebElement& e) { WebNode::assign(e); return *this; }
+ WEBKIT_API void assign(const WebElement& e) { WebNode::assign(e); }
+
+#if WEBKIT_IMPLEMENTATION
+ WebElement(const WTF::PassRefPtr<WebCore::Element>&);
+ WebElement& operator=(const WTF::PassRefPtr<WebCore::Element>&);
+ operator WTF::PassRefPtr<WebCore::Element>() const;
+#endif
+
+ };
+
+} // namespace WebKit
+
+#endif
diff --git a/webkit/api/public/WebForm.h b/webkit/api/public/WebFormElement.h
index 6178b9c..693a1e9 100644
--- a/webkit/api/public/WebForm.h
+++ b/webkit/api/public/WebFormElement.h
@@ -28,10 +28,11 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef WebForm_h
-#define WebForm_h
+#ifndef WebFormElement_h
+#define WebFormElement_h
-#include "WebCommon.h"
+#include "WebElement.h"
+#include "WebVector.h"
#if WEBKIT_IMPLEMENTATION
namespace WebCore { class HTMLFormElement; }
@@ -39,41 +40,29 @@ namespace WTF { template <typename T> class PassRefPtr; }
#endif
namespace WebKit {
+ // A container for passing around a reference to a form element. Provides
+ // some information about the form.
+ class WebFormElement : public WebElement {
+ public:
+ ~WebFormElement() { reset(); }
-class WebFormPrivate;
+ WebFormElement() : WebElement() { }
+ WebFormElement(const WebFormElement& e) : WebElement(e) { }
-// A container for passing around a reference to a form element. Provides
-// some information about the form.
-class WebForm {
-public:
- ~WebForm() { reset(); }
-
- WebForm() : m_private(0) { }
- WebForm(const WebForm& f) : m_private(0) { assign(f); }
- WebForm& operator=(const WebForm& f)
- {
- assign(f);
- return *this;
- }
-
- WEBKIT_API void reset();
- WEBKIT_API void assign(const WebForm&);
-
- bool isNull() const { return !m_private; }
-
- // Returns true if the form does not have "autocomplete=off" specified.
- WEBKIT_API bool isAutoCompleteEnabled() const;
+ WebElement& operator=(const WebFormElement& e) { WebElement::assign(e); return *this; }
+ WEBKIT_API void assign(const WebFormElement& e) { WebElement::assign(e); }
#if WEBKIT_IMPLEMENTATION
- WebForm(const WTF::PassRefPtr<WebCore::HTMLFormElement>&);
- WebForm& operator=(const WTF::PassRefPtr<WebCore::HTMLFormElement>&);
- operator WTF::PassRefPtr<WebCore::HTMLFormElement>() const;
+ WebFormElement(const WTF::PassRefPtr<WebCore::HTMLFormElement>&);
+ WebFormElement& operator=(const WTF::PassRefPtr<WebCore::HTMLFormElement>&);
+ operator WTF::PassRefPtr<WebCore::HTMLFormElement>() const;
#endif
-private:
- void assign(WebFormPrivate*);
- WebFormPrivate* m_private;
-};
+ bool autoComplete() const;
+ WebString action();
+ void submit();
+ void getNamedElements(const WebString&, WebVector<WebNode>&);
+ };
} // namespace WebKit
diff --git a/webkit/api/public/WebFrame.h b/webkit/api/public/WebFrame.h
index 84e6ee5..0a3ed00 100644
--- a/webkit/api/public/WebFrame.h
+++ b/webkit/api/public/WebFrame.h
@@ -47,8 +47,10 @@ namespace WebKit {
class WebData;
class WebDataSource;
-class WebForm;
+class WebFormElement;
class WebHistoryItem;
+class WebInputElement;
+class WebPasswordAutocompleteListener;
class WebRange;
class WebSecurityOrigin;
class WebString;
@@ -157,7 +159,7 @@ public:
// Content ------------------------------------------------------------
- virtual void forms(WebVector<WebForm>&) const = 0;
+ virtual void forms(WebVector<WebFormElement>&) const = 0;
// Scripting ----------------------------------------------------------
@@ -421,6 +423,15 @@ public:
// of matches found during the scoping effort.
virtual void resetMatchCount() = 0;
+ // Password autocompletion ---------------------------------------------
+
+ // Registers a listener for the specified user name input element. The
+ // listener will receive notifications for blur and when autocomplete
+ // should be triggered.
+ // The WebFrame becomes the owner of the passed listener.
+ virtual void registerPasswordListener(
+ WebInputElement,
+ WebPasswordAutocompleteListener*) = 0;
// Utility -------------------------------------------------------------
diff --git a/webkit/api/public/WebFrameClient.h b/webkit/api/public/WebFrameClient.h
index ae64cdb..297eb62 100644
--- a/webkit/api/public/WebFrameClient.h
+++ b/webkit/api/public/WebFrameClient.h
@@ -39,7 +39,7 @@
namespace WebKit {
class WebDataSource;
-class WebForm;
+class WebFormElement;
class WebFrame;
class WebMediaPlayer;
class WebMediaPlayerClient;
@@ -117,7 +117,7 @@ public:
// Navigational notifications ------------------------------------------
// A form submission is about to occur.
- virtual void willSubmitForm(WebFrame*, const WebForm&) { }
+ virtual void willSubmitForm(WebFrame*, const WebFormElement&) { }
// A client-side redirect will occur. This may correspond to a <META
// refresh> or some script activity.
diff --git a/webkit/api/public/WebInputElement.h b/webkit/api/public/WebInputElement.h
new file mode 100644
index 0000000..5d86a39
--- /dev/null
+++ b/webkit/api/public/WebInputElement.h
@@ -0,0 +1,68 @@
+/*
+ * Copyright (C) 2009 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef WebInputElement_h
+#define WebInputElement_h
+
+#include "WebElement.h"
+
+#if WEBKIT_IMPLEMENTATION
+namespace WebCore { class HTMLInputElement; }
+namespace WTF { template <typename T> class PassRefPtr; }
+#endif
+
+namespace WebKit {
+
+ // Provides readonly access to some properties of a DOM input element node.
+ class WebInputElement : public WebElement {
+ public:
+ WebInputElement() : WebElement() { }
+ WebInputElement(const WebInputElement& n) : WebElement(n) { }
+
+ WebInputElement& operator=(const WebInputElement& n) { WebElement::assign(n); return *this; }
+ WEBKIT_API void assign(const WebInputElement& n) { WebElement::assign(n); }
+
+#if WEBKIT_IMPLEMENTATION
+ WebInputElement(const WTF::PassRefPtr<WebCore::HTMLInputElement>&);
+ WebInputElement& operator=(const WTF::PassRefPtr<WebCore::HTMLInputElement>&);
+ operator WTF::PassRefPtr<WebCore::HTMLInputElement>() const;
+#endif
+
+ void setActivatedSubmit(bool);
+ void setValue(const WebString& value);
+ WebString value();
+ void setAutofilled(bool);
+ void dispatchFormControlChangeEvent();
+ void setSelectionRange(size_t, size_t);
+ };
+
+} // namespace WebKit
+
+#endif
diff --git a/webkit/api/public/WebNode.h b/webkit/api/public/WebNode.h
index 49c06a0..4c48915 100644
--- a/webkit/api/public/WebNode.h
+++ b/webkit/api/public/WebNode.h
@@ -34,19 +34,18 @@
#include "WebCommon.h"
#include "WebString.h"
-#if WEBKIT_IMPLEMENTATION
namespace WebCore { class Node; }
+#if WEBKIT_IMPLEMENTATION
namespace WTF { template <typename T> class PassRefPtr; }
#endif
namespace WebKit {
-
-class WebNodePrivate;
+class WebFrame;
// Provides readonly access to some properties of a DOM node.
class WebNode {
public:
- ~WebNode() { reset(); }
+ virtual ~WebNode() { reset(); }
WebNode() : m_private(0) { }
WebNode(const WebNode& n) : m_private(0) { assign(n); }
@@ -61,18 +60,37 @@ public:
bool isNull() const { return !m_private; }
- WEBKIT_API WebNode parentNode() const;
- WEBKIT_API WebString nodeName() const;
-
#if WEBKIT_IMPLEMENTATION
WebNode(const WTF::PassRefPtr<WebCore::Node>&);
WebNode& operator=(const WTF::PassRefPtr<WebCore::Node>&);
operator WTF::PassRefPtr<WebCore::Node>() const;
#endif
-private:
+ WEBKIT_API WebNode parentNode() const;
+ WEBKIT_API WebString nodeName() const;
+ WebFrame* frame();
+
+ template<typename T> T toElement()
+ {
+ T res;
+ res.m_private = m_private;
+ return res;
+ }
+
+protected:
+ typedef WebCore::Node WebNodePrivate;
void assign(WebNodePrivate*);
WebNodePrivate* m_private;
+
+ template<typename T> T* unwrap()
+ {
+ return static_cast<T*>(m_private);
+ }
+
+ template<typename T> const T* constUnwrap() const
+ {
+ return static_cast<const T*>(m_private);
+ }
};
} // namespace WebKit
diff --git a/webkit/api/src/PasswordAutocompleteListener.h b/webkit/api/public/WebPasswordAutocompleteListener.h
index 0451f8f..db6589d 100644
--- a/webkit/api/src/PasswordAutocompleteListener.h
+++ b/webkit/api/public/WebPasswordAutocompleteListener.h
@@ -28,24 +28,26 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef PasswordAutocompleteListener_h
-#define PasswordAutocompleteListener_h
+#ifndef WebPasswordAutocompleteListener_h
+#define WebPasswordAutocompleteListener_h
namespace WebKit {
+class WebString;
-class PasswordAutocompleteListener {
+class WebPasswordAutocompleteListener {
public:
- virtual ~PasswordAutocompleteListener() {}
+ virtual ~WebPasswordAutocompleteListener() {}
virtual void didBlurInputElement(
- const WebCore::String& userInput) = 0;
+ const WebString& userInput) = 0;
virtual void performInlineAutocomplete(
- const WebCore::String& userInput,
+ const WebString& userInput,
bool backSpaceOrDeletePressed,
bool showSuggestions) = 0;
};
} // namespace WebKit
+
#endif
diff --git a/webkit/api/public/WebPasswordFormData.h b/webkit/api/public/WebPasswordFormData.h
index 551a48a..e1804d1 100644
--- a/webkit/api/public/WebPasswordFormData.h
+++ b/webkit/api/public/WebPasswordFormData.h
@@ -31,7 +31,7 @@
#ifndef WebPasswordFormData_h
#define WebPasswordFormData_h
-#include "WebForm.h"
+#include "WebFormElement.h"
#include "WebString.h"
#include "WebURL.h"
@@ -40,7 +40,7 @@ namespace WebKit {
struct WebPasswordFormData {
// If the provided form is suitable for password completion, isValid() will
// return true;
- WebPasswordFormData(const WebForm&);
+ WebPasswordFormData(const WebFormElement&);
// If creation failed, return false.
bool isValid() const { return action.isValid(); }
diff --git a/webkit/api/public/WebSearchableFormData.h b/webkit/api/public/WebSearchableFormData.h
index d8f3a23..e453387 100644
--- a/webkit/api/public/WebSearchableFormData.h
+++ b/webkit/api/public/WebSearchableFormData.h
@@ -35,7 +35,7 @@
#include "WebURL.h"
namespace WebKit {
-class WebForm;
+class WebFormElement;
// SearchableFormData encapsulates a URL and encoding of an INPUT field that
// corresponds to a searchable form request.
@@ -43,7 +43,7 @@ class WebSearchableFormData {
public:
// If the provided form is suitable for automated searching, isValid()
// will return false.
- WebSearchableFormData(const WebForm&);
+ WebSearchableFormData(const WebFormElement&);
bool isValid() { return m_url.isValid(); }
diff --git a/webkit/api/src/EditorClientImpl.cpp b/webkit/api/src/EditorClientImpl.cpp
index 27396d6..bf67573 100644
--- a/webkit/api/src/EditorClientImpl.cpp
+++ b/webkit/api/src/EditorClientImpl.cpp
@@ -42,11 +42,11 @@
#include "RenderObject.h"
#include "DOMUtilitiesPrivate.h"
-#include "PasswordAutocompleteListener.h"
#include "WebEditingAction.h"
#include "WebFrameImpl.h"
#include "WebKit.h"
#include "WebNode.h"
+#include "WebPasswordAutocompleteListener.h"
#include "WebRange.h"
#include "WebTextAffinity.h"
#include "WebViewClient.h"
@@ -661,7 +661,7 @@ void EditorClientImpl::textFieldDidEndEditing(Element* element)
if (!webframe)
return;
- PasswordAutocompleteListener* listener = webframe->getPasswordListener(inputElement);
+ WebPasswordAutocompleteListener* listener = webframe->getPasswordListener(inputElement);
if (!listener)
return;
@@ -751,7 +751,7 @@ void EditorClientImpl::doAutofill(Timer<EditorClientImpl>* timer)
WebFrameImpl* webframe = WebFrameImpl::fromFrame(inputElement->document()->frame());
if (!webframe)
return;
- PasswordAutocompleteListener* listener = webframe->getPasswordListener(inputElement);
+ WebPasswordAutocompleteListener* listener = webframe->getPasswordListener(inputElement);
if (listener) {
if (args->autofillFormOnly)
return;
@@ -783,7 +783,7 @@ void EditorClientImpl::onAutofillSuggestionAccepted(HTMLInputElement* textField)
if (!webframe)
return;
- PasswordAutocompleteListener* listener = webframe->getPasswordListener(textField);
+ WebPasswordAutocompleteListener* listener = webframe->getPasswordListener(textField);
// Password listeners need to autocomplete other fields that depend on the
// input element with autofill suggestions.
if (listener)
diff --git a/webkit/api/src/FrameLoaderClientImpl.cpp b/webkit/api/src/FrameLoaderClientImpl.cpp
index 5e00d63..359abb7 100644
--- a/webkit/api/src/FrameLoaderClientImpl.cpp
+++ b/webkit/api/src/FrameLoaderClientImpl.cpp
@@ -48,7 +48,7 @@
#include "PlatformString.h"
#include "PluginData.h"
#include "StringExtras.h"
-#include "WebForm.h"
+#include "WebFormElement.h"
#include "WebFrameClient.h"
#include "WebFrameImpl.h"
#include "WebKit.h"
@@ -908,7 +908,7 @@ void FrameLoaderClientImpl::dispatchWillSubmitForm(FramePolicyFunction function,
PassRefPtr<FormState> formState)
{
if (m_webFrame->client())
- m_webFrame->client()->willSubmitForm(m_webFrame, WebForm(formState->form()));
+ m_webFrame->client()->willSubmitForm(m_webFrame, WebFormElement(formState->form()));
(m_webFrame->frame()->loader()->policyChecker()->*function)(PolicyUse);
}
diff --git a/webkit/api/src/WebElement.cpp b/webkit/api/src/WebElement.cpp
new file mode 100644
index 0000000..3f13ee1
--- /dev/null
+++ b/webkit/api/src/WebElement.cpp
@@ -0,0 +1,58 @@
+/*
+ * Copyright (C) 2009 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "WebElement.h"
+
+#include "Element.h"
+#include <wtf/PassRefPtr.h>
+
+using namespace WebCore;
+
+namespace WebKit {
+
+WebElement::WebElement(const WTF::PassRefPtr<WebCore::Element>& elem)
+ : WebNode(elem.releaseRef())
+{
+}
+
+WebElement& WebElement::operator=(const WTF::PassRefPtr<WebCore::Element>& elem)
+{
+ WebNode::assign(elem.releaseRef());
+ return *this;
+}
+
+WebElement::operator WTF::PassRefPtr<Element>() const
+{
+ return PassRefPtr<Element>(static_cast<Element*>(m_private));
+}
+
+} // namespace WebKit
+
diff --git a/webkit/api/src/WebForm.cpp b/webkit/api/src/WebFormElement.cpp
index 8b1c6b5..fecd05c 100644
--- a/webkit/api/src/WebForm.cpp
+++ b/webkit/api/src/WebFormElement.cpp
@@ -29,9 +29,11 @@
*/
#include "config.h"
-#include "WebForm.h"
+#include "WebFormElement.h"
#include "HTMLFormElement.h"
+#include "WebString.h"
+#include "WebURL.h"
#include <wtf/PassRefPtr.h>
using namespace WebCore;
@@ -41,47 +43,43 @@ namespace WebKit {
class WebFormPrivate : public HTMLFormElement {
};
-void WebForm::reset()
+WebFormElement::WebFormElement(const WTF::PassRefPtr<HTMLFormElement>& e)
+ : WebElement(e.releaseRef())
{
- assign(0);
}
-void WebForm::assign(const WebForm& other)
+WebFormElement& WebFormElement::operator=(const WTF::PassRefPtr<HTMLFormElement>& e)
{
- WebFormPrivate* p = const_cast<WebFormPrivate*>(other.m_private);
- if (p)
- p->ref();
- assign(p);
+ WebNode::assign(e.releaseRef());
+ return *this;
}
-bool WebForm::isAutoCompleteEnabled() const
+WebFormElement::operator WTF::PassRefPtr<WebCore::HTMLFormElement>() const
{
- ASSERT(!isNull());
- return m_private->autoComplete();
+ return PassRefPtr<HTMLFormElement>(static_cast<HTMLFormElement*>(m_private));
}
-WebForm::WebForm(const WTF::PassRefPtr<WebCore::HTMLFormElement>& element)
- : m_private(static_cast<WebFormPrivate*>(element.releaseRef()))
+bool WebFormElement::autoComplete() const
{
+ return constUnwrap<HTMLFormElement>()->autoComplete();
}
-WebForm& WebForm::operator=(const WTF::PassRefPtr<WebCore::HTMLFormElement>& element)
+WebString WebFormElement::action()
{
- assign(static_cast<WebFormPrivate*>(element.releaseRef()));
- return *this;
+ return unwrap<HTMLFormElement>()->action();
}
-WebForm::operator WTF::PassRefPtr<WebCore::HTMLFormElement>() const
+void WebFormElement::submit()
{
- return PassRefPtr<HTMLFormElement>(const_cast<WebFormPrivate*>(m_private));
+ unwrap<HTMLFormElement>()->submit();
}
-void WebForm::assign(WebFormPrivate* p)
+void WebFormElement::getNamedElements(const WebString& name,
+ WebVector<WebNode>& result)
{
- // p is already ref'd for us by the caller
- if (m_private)
- m_private->deref();
- m_private = p;
+ Vector<RefPtr<Node> > temp_vector;
+ unwrap<HTMLFormElement>()->getNamedElements(name, temp_vector);
+ result.assign(temp_vector);
}
} // namespace WebKit
diff --git a/webkit/api/src/WebFrameImpl.cpp b/webkit/api/src/WebFrameImpl.cpp
index 8b5b52b..3ef8631 100644
--- a/webkit/api/src/WebFrameImpl.cpp
+++ b/webkit/api/src/WebFrameImpl.cpp
@@ -103,7 +103,6 @@
#include "InspectorController.h"
#include "markup.h"
#include "Page.h"
-#include "PasswordAutocompleteListener.h"
#include "PlatformContextSkia.h"
#include "PrintContext.h"
#include "RenderFrame.h"
@@ -127,9 +126,11 @@
#include "WebConsoleMessage.h"
#include "WebDataSourceImpl.h"
#include "WebFindOptions.h"
-#include "WebForm.h"
+#include "WebFormElement.h"
#include "WebFrameClient.h"
#include "WebHistoryItem.h"
+#include "WebInputElement.h"
+#include "WebPasswordAutocompleteListener.h"
#include "WebRange.h"
#include "WebRect.h"
#include "WebScriptSource.h"
@@ -507,7 +508,7 @@ WebFrame* WebFrameImpl::findChildByExpression(const WebString& xpath) const
return fromFrame(frameElement->contentFrame());
}
-void WebFrameImpl::forms(WebVector<WebForm>& results) const
+void WebFrameImpl::forms(WebVector<WebFormElement>& results) const
{
if (!m_frame)
return;
@@ -515,7 +516,7 @@ void WebFrameImpl::forms(WebVector<WebForm>& results) const
RefPtr<HTMLCollection> forms = m_frame->document()->forms();
size_t formCount = forms->length();
- WebVector<WebForm> temp(formCount);
+ WebVector<WebFormElement> temp(formCount);
for (size_t i = 0; i < formCount; ++i) {
Node* node = forms->item(i);
// Strange but true, sometimes item can be 0.
@@ -1688,15 +1689,15 @@ void WebFrameImpl::setAllowsScrolling(bool flag)
}
void WebFrameImpl::registerPasswordListener(
- PassRefPtr<HTMLInputElement> inputElement,
- PasswordAutocompleteListener* listener)
+ WebInputElement inputElement,
+ WebPasswordAutocompleteListener* listener)
{
- RefPtr<HTMLInputElement> element = inputElement;
+ RefPtr<HTMLInputElement> element = inputElement.operator PassRefPtr<HTMLInputElement>();
ASSERT(m_passwordListeners.find(element) == m_passwordListeners.end());
m_passwordListeners.set(element, listener);
}
-PasswordAutocompleteListener* WebFrameImpl::getPasswordListener(
+WebPasswordAutocompleteListener* WebFrameImpl::getPasswordListener(
HTMLInputElement* inputElement)
{
return m_passwordListeners.get(RefPtr<HTMLInputElement>(inputElement));
diff --git a/webkit/api/src/WebFrameImpl.h b/webkit/api/src/WebFrameImpl.h
index 8a3772c..f6098a7 100644
--- a/webkit/api/src/WebFrameImpl.h
+++ b/webkit/api/src/WebFrameImpl.h
@@ -50,9 +50,10 @@ struct WindowFeatures;
namespace WebKit {
class ChromePrintContext;
-class PasswordAutocompleteListener;
class WebDataSourceImpl;
+class WebInputElement;
class WebFrameClient;
+class WebPasswordAutocompleteListener;
class WebView;
class WebViewImpl;
@@ -80,7 +81,7 @@ public:
virtual WebFrame* traversePrevious(bool wrap) const;
virtual WebFrame* findChildByName(const WebString&) const;
virtual WebFrame* findChildByExpression(const WebString&) const;
- virtual void forms(WebVector<WebForm>&) const;
+ virtual void forms(WebVector<WebFormElement>&) const;
virtual WebSecurityOrigin securityOrigin() const;
virtual void grantUniversalAccess();
virtual NPObject* windowObject() const;
@@ -149,6 +150,9 @@ public:
virtual void cancelPendingScopingEffort();
virtual void increaseMatchCount(int count, int identifier);
virtual void resetMatchCount();
+ virtual void registerPasswordListener(
+ WebInputElement, WebPasswordAutocompleteListener*);
+
virtual WebURL completeURL(const WebString& url) const;
virtual WebString contentAsText(size_t maxChars) const;
virtual WebString contentAsMarkup() const;
@@ -202,19 +206,11 @@ public:
// Otherwise, disallow scrolling.
void setAllowsScrolling(bool);
- // Registers a listener for the specified user name input element. The
- // listener will receive notifications for blur and when autocomplete should
- // be triggered.
- // The WebFrameImpl becomes the owner of the passed listener.
- void registerPasswordListener(
- PassRefPtr<WebCore::HTMLInputElement>,
- PasswordAutocompleteListener*);
-
// Returns the password autocomplete listener associated with the passed
// user name input element, or NULL if none available.
// Note that the returned listener is owner by the WebFrameImpl and should not
// be kept around as it is deleted when the page goes away.
- PasswordAutocompleteListener* getPasswordListener(WebCore::HTMLInputElement*);
+ WebPasswordAutocompleteListener* getPasswordListener(WebCore::HTMLInputElement*);
WebFrameClient* client() const { return m_clientHandle->client(); }
void dropClient() { m_clientHandle->dropClient(); }
@@ -367,7 +363,7 @@ private:
// The input fields that are interested in edit events and their associated
// listeners.
typedef HashMap<RefPtr<WebCore::HTMLInputElement>,
- PasswordAutocompleteListener*> PasswordListenerMap;
+ WebPasswordAutocompleteListener*> PasswordListenerMap;
PasswordListenerMap m_passwordListeners;
};
diff --git a/webkit/api/src/WebInputElement.cpp b/webkit/api/src/WebInputElement.cpp
new file mode 100644
index 0000000..947e4cc0
--- /dev/null
+++ b/webkit/api/src/WebInputElement.cpp
@@ -0,0 +1,89 @@
+/*
+ * Copyright (C) 2009 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "WebInputElement.h"
+
+#include "HTMLInputElement.h"
+#include "WebString.h"
+#include <wtf/PassRefPtr.h>
+
+using namespace WebCore;
+
+namespace WebKit {
+
+WebInputElement::WebInputElement(const WTF::PassRefPtr<HTMLInputElement>& elem)
+ : WebElement(elem.releaseRef())
+{
+}
+
+WebInputElement& WebInputElement::operator=(const WTF::PassRefPtr<HTMLInputElement>& elem)
+{
+ WebNode::assign(elem.releaseRef());
+ return *this;
+}
+
+WebInputElement::operator WTF::PassRefPtr<HTMLInputElement>() const
+{
+ return PassRefPtr<HTMLInputElement>(static_cast<HTMLInputElement*>(m_private));
+}
+
+void WebInputElement::setActivatedSubmit(bool activated)
+{
+ unwrap<HTMLInputElement>()->setActivatedSubmit(activated);
+}
+
+
+void WebInputElement::setValue(const WebString& value)
+{
+ unwrap<HTMLInputElement>()->setValue(value);
+}
+
+WebString WebInputElement::value()
+{
+ return unwrap<HTMLInputElement>()->value();
+}
+
+
+void WebInputElement::setAutofilled(bool autoFilled)
+{
+ unwrap<HTMLInputElement>()->setAutofilled(autoFilled);
+}
+
+void WebInputElement::dispatchFormControlChangeEvent()
+{
+ unwrap<HTMLInputElement>()->dispatchFormControlChangeEvent();
+} // namespace WebKit
+
+void WebInputElement::setSelectionRange(size_t start, size_t end)
+{
+ unwrap<HTMLInputElement>()->setSelectionRange(start, end);
+}
+} // namespace WebKit
diff --git a/webkit/api/src/WebNode.cpp b/webkit/api/src/WebNode.cpp
index 44a930d..0d0695a 100644
--- a/webkit/api/src/WebNode.cpp
+++ b/webkit/api/src/WebNode.cpp
@@ -31,7 +31,13 @@
#include "config.h"
#include "WebNode.h"
+#include "Document.h"
+#include "Frame.h"
#include "Node.h"
+
+#include "FrameLoaderClientImpl.h"
+#include "WebFrameImpl.h"
+#include "WebString.h"
#include <wtf/PassRefPtr.h>
using namespace WebCore;
@@ -88,4 +94,12 @@ void WebNode::assign(WebNodePrivate* p)
m_private = p;
}
+WebFrame* WebNode::frame()
+{
+ FrameLoaderClientImpl* frame_loader_client =
+ static_cast<FrameLoaderClientImpl*>(m_private->document()->
+ frame()->loader()->client());
+ return static_cast<WebFrame*>(frame_loader_client->webFrame());
+}
+
} // namespace WebKit
diff --git a/webkit/api/src/WebPasswordFormData.cpp b/webkit/api/src/WebPasswordFormData.cpp
index 7a25be0..64b1754 100644
--- a/webkit/api/src/WebPasswordFormData.cpp
+++ b/webkit/api/src/WebPasswordFormData.cpp
@@ -147,7 +147,7 @@ void assemblePasswordFormResult(const KURL& fullOrigin,
} // namespace
-WebPasswordFormData::WebPasswordFormData(const WebForm& webForm)
+WebPasswordFormData::WebPasswordFormData(const WebFormElement& webForm)
{
RefPtr<HTMLFormElement> form = webForm.operator PassRefPtr<HTMLFormElement>();
diff --git a/webkit/api/src/WebSearchableFormData.cpp b/webkit/api/src/WebSearchableFormData.cpp
index 923fd0a..f0d9c2b 100644
--- a/webkit/api/src/WebSearchableFormData.cpp
+++ b/webkit/api/src/WebSearchableFormData.cpp
@@ -43,7 +43,7 @@
#include "HTMLOptionsCollection.h"
#include "HTMLSelectElement.h"
#include "TextEncoding.h"
-#include "WebForm.h"
+#include "WebFormElement.h"
using namespace WebCore;
@@ -217,7 +217,7 @@ bool HasSuitableTextElement(const HTMLFormElement* form, Vector<char>* encodedSt
namespace WebKit {
-WebSearchableFormData::WebSearchableFormData(const WebForm& form)
+WebSearchableFormData::WebSearchableFormData(const WebFormElement& form)
{
RefPtr<HTMLFormElement> formElement = form.operator PassRefPtr<HTMLFormElement>();
const Frame* frame = formElement->document()->frame();
diff --git a/webkit/glue/dom_operations.cc b/webkit/glue/dom_operations.cc
index 2b523d6..3f091b1 100644
--- a/webkit/glue/dom_operations.cc
+++ b/webkit/glue/dom_operations.cc
@@ -31,20 +31,24 @@ MSVC_POP_WARNING();
#undef LOG
#include "base/string_util.h"
+#include "webkit/api/public/WebVector.h"
+#include "webkit/api/public/WebView.h"
// TODO(yaar) Eventually should not depend on api/src.
#include "webkit/api/src/DOMUtilitiesPrivate.h"
#include "webkit/api/src/WebFrameImpl.h"
-#include "webkit/api/src/WebViewImpl.h"
#include "webkit/glue/dom_operations.h"
#include "webkit/glue/dom_operations_private.h"
#include "webkit/glue/form_data.h"
#include "webkit/glue/glue_util.h"
-#include "webkit/glue/password_autocomplete_listener_impl.h"
+#include "webkit/glue/webpasswordautocompletelistener_impl.h"
using WebCore::String;
using WebKit::FrameLoaderClientImpl;
+using WebKit::WebFormElement;
using WebKit::WebFrame;
using WebKit::WebFrameImpl;
+using WebKit::WebNode;
+using WebKit::WebVector;
using WebKit::WebView;
namespace {
@@ -173,8 +177,8 @@ namespace webkit_glue {
// Map element name to a list of pointers to corresponding elements to simplify
// form filling.
-typedef std::map<string16, RefPtr<WebCore::HTMLInputElement> >
- FormElementRefMap;
+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
@@ -182,9 +186,9 @@ typedef std::map<string16, RefPtr<WebCore::HTMLInputElement> >
// to fill the form, the FindFormElements function stores the pointers
// in a FormElements* result, referenced to ensure they are safe to use.
struct FormElements {
- RefPtr<WebCore::HTMLFormElement> form_element;
- FormElementRefMap input_elements;
- FormElements() : form_element(NULL) {
+ WebFormElement form_element;
+ FormInputElementMap input_elements;
+ FormElements() {
}
};
@@ -192,7 +196,7 @@ typedef std::vector<FormElements*> FormElementsList;
// Internal implementation of FillForm API.
static bool FillFormImpl(FormElements* fe, const FormData& data, bool submit) {
- if (!fe->form_element->autoComplete())
+ if (!fe->form_element.autoComplete())
return false;
std::map<string16, string16> data_map;
@@ -201,22 +205,22 @@ static bool FillFormImpl(FormElements* fe, const FormData& data, bool submit) {
}
bool submit_found = false;
- for (FormElementRefMap::iterator it = fe->input_elements.begin();
+ for (FormInputElementMap::iterator it = fe->input_elements.begin();
it != fe->input_elements.end(); ++it) {
if (it->first == data.submit) {
- it->second->setActivatedSubmit(true);
+ it->second.setActivatedSubmit(true);
submit_found = true;
continue;
}
- if (!it->second->value().isEmpty()) // Don't overwrite pre-filled values.
+ if (!it->second.value().isEmpty()) // Don't overwrite pre-filled values.
continue;
- it->second->setValue(String16ToString(data_map[it->first]));
- it->second->setAutofilled(true);
- it->second->dispatchFormControlChangeEvent();
+ it->second.setValue(data_map[it->first]);
+ it->second.setAutofilled(true);
+ it->second.dispatchFormControlChangeEvent();
}
if (submit && submit_found) {
- fe->form_element->submit();
+ fe->form_element.submit();
return true;
}
return false;
@@ -224,15 +228,15 @@ static bool FillFormImpl(FormElements* fe, const FormData& data, bool submit) {
// Helper to search the given form element for the specified input elements
// in |data|, and add results to |result|.
-static bool FindFormInputElements(WebCore::HTMLFormElement* fe,
+static bool FindFormInputElements(WebFormElement& fe,
const FormData& data,
FormElements* result) {
- Vector<RefPtr<WebCore::Node> > temp_elements;
// 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.elements.size(); j++, temp_elements.clear()) {
- fe->getNamedElements(String16ToString(data.elements[j]), temp_elements);
+ for (size_t j = 0; j < data.elements.size(); j++) {
+ WebVector<WebNode> temp_elements;
+ fe.getNamedElements(data.elements[j], 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
@@ -247,8 +251,7 @@ static bool FindFormInputElements(WebCore::HTMLFormElement* fe,
// matching elements it can get at them through the FormElement*.
// Note: This assignment adds a reference to the InputElement.
result->input_elements[data.elements[j]] =
- WebKit::toHTMLInputElement(temp_elements[0].get());
- DCHECK(result->input_elements[data.elements[j]].get());
+ temp_elements[0].toElement<WebInputElement>();
}
return true;
}
@@ -285,11 +288,12 @@ static void FindFormElements(WebView* view,
PassRefPtr<WebCore::HTMLCollection> forms = doc->forms();
for (size_t i = 0; i < forms->length(); ++i) {
- WebCore::HTMLFormElement* fe =
- static_cast<WebCore::HTMLFormElement*>(forms->item(i));
-
+ // FIXME: docs->forms should return an array of WebFormElements
+ WebFormElement fe = HTMLFormElementToWebFormElement(
+ static_cast<WebCore::HTMLFormElement*>(forms->item(i)));
// Action URL must match.
- GURL full_action(KURLToGURL(loader->completeURL(fe->action())));
+ GURL full_action(
+ KURLToGURL(loader->completeURL(WebStringToString(fe.action()))));
if (data.action != full_action.ReplaceComponents(rep))
continue;
@@ -339,23 +343,19 @@ void FillPasswordForm(WebView* view,
// Attach autocomplete listener to enable selecting alternate logins.
// First, get pointers to username element.
- WebCore::HTMLInputElement* username_element =
- form_elements->input_elements[data.basic_data.elements[0]].get();
+ WebInputElement username_element =
+ form_elements->input_elements[data.basic_data.elements[0]];
// Get pointer to password element. (We currently only support single
// password forms).
- WebCore::HTMLInputElement* password_element =
- form_elements->input_elements[data.basic_data.elements[1]].get();
-
- FrameLoaderClientImpl* frame_loader_client =
- static_cast<FrameLoaderClientImpl*>(username_element->document()->
- frame()->loader()->client());
- WebFrameImpl* webframe_impl = frame_loader_client->webFrame();
- webframe_impl->registerPasswordListener(
+ WebInputElement password_element =
+ form_elements->input_elements[data.basic_data.elements[1]];
+
+ username_element.frame()->registerPasswordListener(
username_element,
- new PasswordAutocompleteListenerImpl(
- new HTMLInputDelegate(username_element),
- new HTMLInputDelegate(password_element),
+ new WebPasswordAutocompleteListenerImpl(
+ new WebInputElementDelegate(username_element),
+ new WebInputElementDelegate(password_element),
data));
}
}
diff --git a/webkit/glue/form_field_values.cc b/webkit/glue/form_field_values.cc
index 5e2e32f..9beaf18 100644
--- a/webkit/glue/form_field_values.cc
+++ b/webkit/glue/form_field_values.cc
@@ -15,18 +15,18 @@
#include "base/logging.h"
#include "base/string16.h"
#include "base/string_util.h"
-#include "webkit/api/public/WebForm.h"
+#include "webkit/api/public/WebFormElement.h"
#include "webkit/glue/form_field_values.h"
// Can include from api/src because this file will eventually be there too.
#include "webkit/api/src/DOMUtilitiesPrivate.h"
#include "webkit/glue/glue_util.h"
-using WebKit::WebForm;
+using WebKit::WebFormElement;
namespace webkit_glue {
-FormFieldValues* FormFieldValues::Create(const WebForm& webform) {
- RefPtr<WebCore::HTMLFormElement> form = WebFormToHTMLFormElement(webform);
+FormFieldValues* FormFieldValues::Create(const WebFormElement& webform) {
+ RefPtr<WebCore::HTMLFormElement> form = WebFormElementToHTMLFormElement(webform);
DCHECK(form);
WebCore::Document* document = form->document();
@@ -50,8 +50,9 @@ FormFieldValues* FormFieldValues::Create(const WebForm& webform) {
return result;
}
-void FormFieldValues::ExtractFormFieldValues(const WebKit::WebForm& webform) {
- RefPtr<WebCore::HTMLFormElement> form = WebFormToHTMLFormElement(webform);
+void FormFieldValues::ExtractFormFieldValues(
+ const WebKit::WebFormElement& webform) {
+ RefPtr<WebCore::HTMLFormElement> form = WebFormElementToHTMLFormElement(webform);
const WTF::Vector<WebCore::HTMLFormControlElement*>& form_elements =
form->formElements;
diff --git a/webkit/glue/form_field_values.h b/webkit/glue/form_field_values.h
index bd45499..d49ff5b 100644
--- a/webkit/glue/form_field_values.h
+++ b/webkit/glue/form_field_values.h
@@ -12,7 +12,7 @@
#include "webkit/glue/form_field.h"
namespace WebKit {
-class WebForm;
+class WebFormElement;
}
namespace webkit_glue {
@@ -21,7 +21,7 @@ namespace webkit_glue {
// values entered in the fields.
class FormFieldValues {
public:
- static FormFieldValues* Create(const WebKit::WebForm& webform);
+ static FormFieldValues* Create(const WebKit::WebFormElement&);
// The name of the form.
string16 form_name;
@@ -39,7 +39,7 @@ class FormFieldValues {
std::vector<FormField> elements;
private:
- void ExtractFormFieldValues(const WebKit::WebForm& webform);
+ void ExtractFormFieldValues(const WebKit::WebFormElement&);
};
} // namespace webkit_glue
diff --git a/webkit/glue/glue_util.cc b/webkit/glue/glue_util.cc
index cfe2fef..fe78982 100644
--- a/webkit/glue/glue_util.cc
+++ b/webkit/glue/glue_util.cc
@@ -39,7 +39,7 @@
#include "webkit/api/public/WebAccessibilityObject.h"
#include "webkit/api/public/WebCursorInfo.h"
#include "webkit/api/public/WebDragData.h"
-#include "webkit/api/public/WebForm.h"
+#include "webkit/api/public/WebFormElement.h"
#include "webkit/api/public/WebHistoryItem.h"
#include "webkit/api/public/WebNode.h"
#include "webkit/api/public/WebPoint.h"
@@ -259,13 +259,13 @@ PassRefPtr<WebCore::ChromiumDataObject> WebDragDataToChromiumDataObject(
// WebForm conversions ---------------------------------------------------------
-WebKit::WebForm HTMLFormElementToWebForm(
+WebKit::WebFormElement HTMLFormElementToWebFormElement(
const WTF::PassRefPtr<WebCore::HTMLFormElement>& form) {
return form;
}
-WTF::PassRefPtr<WebCore::HTMLFormElement> WebFormToHTMLFormElement(
- const WebKit::WebForm& form) {
+WTF::PassRefPtr<WebCore::HTMLFormElement> WebFormElementToHTMLFormElement(
+ const WebKit::WebFormElement& form) {
return form;
}
diff --git a/webkit/glue/glue_util.h b/webkit/glue/glue_util.h
index e5cc376..213ee4b 100644
--- a/webkit/glue/glue_util.h
+++ b/webkit/glue/glue_util.h
@@ -36,7 +36,7 @@ class WebAccessibilityObject;
class WebCString;
class WebData;
class WebDragData;
-class WebForm;
+class WebFormElement;
class WebHistoryItem;
class WebNode;
class WebRange;
@@ -139,10 +139,10 @@ WTF::PassRefPtr<WebCore::ChromiumDataObject> WebDragDataToChromiumDataObject(
const WebKit::WebDragData&);
// WebForm <-> HTMLFormElement
-WebKit::WebForm HTMLFormElementToWebForm(
+WebKit::WebFormElement HTMLFormElementToWebFormElement(
const WTF::PassRefPtr<WebCore::HTMLFormElement>&);
-WTF::PassRefPtr<WebCore::HTMLFormElement> WebFormToHTMLFormElement(
- const WebKit::WebForm&);
+WTF::PassRefPtr<WebCore::HTMLFormElement> WebFormElementToHTMLFormElement(
+ const WebKit::WebFormElement&);
// WebHistoryItem <-> HistoryItem
WebKit::WebHistoryItem HistoryItemToWebHistoryItem(
diff --git a/webkit/glue/password_form_dom_manager.cc b/webkit/glue/password_form_dom_manager.cc
index a87e4d4..0ce1c36 100644
--- a/webkit/glue/password_form_dom_manager.cc
+++ b/webkit/glue/password_form_dom_manager.cc
@@ -8,12 +8,13 @@
#include "webkit/glue/glue_util.h"
#include "webkit/glue/password_form_dom_manager.h"
-using WebKit::WebForm;
+using WebKit::WebFormElement;
using WebKit::WebPasswordFormData;
namespace webkit_glue {
-PasswordForm* PasswordFormDomManager::CreatePasswordForm(const WebForm& webform)
+PasswordForm* PasswordFormDomManager::CreatePasswordForm(
+ const WebFormElement& webform)
{
WebPasswordFormData web_password_form(webform);
if (web_password_form.isValid())
diff --git a/webkit/glue/password_form_dom_manager.h b/webkit/glue/password_form_dom_manager.h
index 772e0a3..8704573 100644
--- a/webkit/glue/password_form_dom_manager.h
+++ b/webkit/glue/password_form_dom_manager.h
@@ -41,7 +41,7 @@ class PasswordFormDomManager {
// custom metadata to DOM nodes, so we have to do this every time an event
// happens with a given form and compare against previously Create'd forms
// to identify..which sucks.
- static PasswordForm* CreatePasswordForm(const WebKit::WebForm& form);
+ static PasswordForm* CreatePasswordForm(const WebKit::WebFormElement& form);
// Create a FillData structure in preparation for autofilling a form,
// from basic_data identifying which form to fill, and a collection of
diff --git a/webkit/glue/password_autocomplete_listener_impl.cc b/webkit/glue/webpasswordautocompletelistener_impl.cc
index b955f53..b7133ad 100644
--- a/webkit/glue/password_autocomplete_listener_impl.cc
+++ b/webkit/glue/webpasswordautocompletelistener_impl.cc
@@ -5,77 +5,71 @@
// This file provides the implementaiton of the password manager's autocomplete
// component.
-#include "config.h"
-
-#include "HTMLInputElement.h"
-#undef LOG
-
#include "base/string_util.h"
+
+#include "webkit/api/public/WebFrame.h"
#include "webkit/api/public/WebNode.h"
#include "webkit/api/public/WebVector.h"
-#include "webkit/api/src/WebFrameImpl.h"
-#include "webkit/api/src/WebViewImpl.h"
+#include "webkit/api/public/WebView.h"
#include "webkit/glue/glue_util.h"
-#include "webkit/glue/password_autocomplete_listener_impl.h"
+#include "webkit/glue/webpasswordautocompletelistener_impl.h"
-using WebKit::WebFrameImpl;
-using WebKit::WebViewImpl;
+using namespace WebKit;
namespace webkit_glue {
-HTMLInputDelegate::HTMLInputDelegate(WebCore::HTMLInputElement* element)
+WebInputElementDelegate::WebInputElementDelegate() {
+}
+
+WebInputElementDelegate::WebInputElementDelegate(WebInputElement& element)
: element_(element) {
}
-HTMLInputDelegate::~HTMLInputDelegate() {
+WebInputElementDelegate::~WebInputElementDelegate() {
}
-void HTMLInputDelegate::SetValue(const string16& value) {
- element_->setValue(String16ToString(value));
+void WebInputElementDelegate::SetValue(const string16& value) {
+ element_.setValue(value);
}
-void HTMLInputDelegate::SetSelectionRange(size_t start, size_t end) {
- element_->setSelectionRange(start, end);
+void WebInputElementDelegate::SetSelectionRange(size_t start, size_t end) {
+ element_.setSelectionRange(start, end);
}
-void HTMLInputDelegate::OnFinishedAutocompleting() {
+void WebInputElementDelegate::OnFinishedAutocompleting() {
// This sets the input element to an autofilled state which will result in it
// having a yellow background.
- element_->setAutofilled(true);
+ element_.setAutofilled(true);
// Notify any changeEvent listeners.
- element_->dispatchFormControlChangeEvent();
+ element_.dispatchFormControlChangeEvent();
}
-void HTMLInputDelegate::RefreshAutofillPopup(
+void WebInputElementDelegate::RefreshAutofillPopup(
const std::vector<string16>& suggestions,
int default_suggestion_index) {
- WebFrameImpl* webframe =
- WebFrameImpl::fromFrame(element_->document()->frame());
- WebViewImpl* webview = webframe->viewImpl();
- if (!webview)
- return;
-
- webview->applyAutofillSuggestions(
- webkit_glue::NodeToWebNode(element_), suggestions, 0);
+ WebView* webview = element_.frame()->view();
+ if (webview)
+ webview->applyAutofillSuggestions(element_, suggestions, 0);
}
-PasswordAutocompleteListenerImpl::PasswordAutocompleteListenerImpl(
- HTMLInputDelegate* username_delegate,
- HTMLInputDelegate* password_delegate,
+
+WebPasswordAutocompleteListenerImpl::WebPasswordAutocompleteListenerImpl(
+ WebInputElementDelegate* username_delegate,
+ WebInputElementDelegate* password_delegate,
const PasswordFormDomManager::FillData& data)
: password_delegate_(password_delegate),
username_delegate_(username_delegate),
data_(data) {
}
-void PasswordAutocompleteListenerImpl::didBlurInputElement(
- const WebCore::String& user_input) {
+void WebPasswordAutocompleteListenerImpl::didBlurInputElement(
+ const WebString& user_input) {
// If this listener exists, its because the password manager had more than
// one match for the password form, which implies it had at least one
// [preferred] username/password pair.
- ASSERT(data_.basic_data.values.size() == 2);
+// DCHECK(data_.basic_data.values.size() == 2);
- string16 user_input16 = webkit_glue::StringToString16(user_input);
+ string16 user_input16 = user_input;
// Set the password field to match the current username.
if (data_.basic_data.values[0] == user_input16) {
@@ -89,8 +83,8 @@ void PasswordAutocompleteListenerImpl::didBlurInputElement(
password_delegate_->OnFinishedAutocompleting();
}
-void PasswordAutocompleteListenerImpl::performInlineAutocomplete(
- const WebCore::String& user_input,
+void WebPasswordAutocompleteListenerImpl::performInlineAutocomplete(
+ const WebString& user_input,
bool backspace_or_delete_pressed,
bool show_suggestions) {
// If wait_for_username is true, we only autofill the password when
@@ -99,7 +93,7 @@ void PasswordAutocompleteListenerImpl::performInlineAutocomplete(
if (data_.wait_for_username)
return;
- string16 user_input16 = webkit_glue::StringToString16(user_input);
+ string16 user_input16 = user_input;
if (show_suggestions) {
std::vector<string16> suggestions;
@@ -133,9 +127,9 @@ void PasswordAutocompleteListenerImpl::performInlineAutocomplete(
}
}
-bool PasswordAutocompleteListenerImpl::TryToMatch(const string16& input,
- const string16& username,
- const string16& password) {
+bool WebPasswordAutocompleteListenerImpl::TryToMatch(const string16& input,
+ const string16& username,
+ const string16& password) {
if (!StartsWith(username, input, false))
return false;
@@ -148,7 +142,7 @@ bool PasswordAutocompleteListenerImpl::TryToMatch(const string16& input,
return true;
}
-void PasswordAutocompleteListenerImpl::GetSuggestions(
+void WebPasswordAutocompleteListenerImpl::GetSuggestions(
const string16& input, std::vector<string16>* suggestions) {
if (StartsWith(data_.basic_data.values[0], input, false))
suggestions->push_back(data_.basic_data.values[0]);
diff --git a/webkit/glue/password_autocomplete_listener_impl.h b/webkit/glue/webpasswordautocompletelistener_impl.h
index cc56a95..7020bf1 100644
--- a/webkit/glue/password_autocomplete_listener_impl.h
+++ b/webkit/glue/webpasswordautocompletelistener_impl.h
@@ -5,26 +5,28 @@
// A concrete definition of the DOM autocomplete framework defined by
// autocomplete_input_listener.h, for the password manager.
-#ifndef WEBKIT_GLUE_PASSWORD_AUTOCOMPLETE_LISTENER_H_
-#define WEBKIT_GLUE_PASSWORD_AUTOCOMPLETE_LISTENER_H_
+#ifndef WEBKIT_GLUE_PASSWORDAUTOCOMPLETELISTENER_IMPL_H_
+#define WEBKIT_GLUE_PASSWORDAUTOCOMPLETELISTENER_IMPL_H_
#include "base/basictypes.h"
#include "base/scoped_ptr.h"
-#include "webkit/api/src/PasswordAutocompleteListener.h"
+#include "webkit/api/public/WebInputElement.h"
+#include "webkit/api/public/WebPasswordAutocompleteListener.h"
#include "webkit/glue/password_form_dom_manager.h"
-namespace WebCore {
-class HTMLInputElement;
-}
+using WebKit::WebInputElement;
+using WebKit::WebString;
namespace webkit_glue {
-// A proxy interface to a WebCore::HTMLInputElement for inline autocomplete.
-// The delegate does not own the WebCore element; it only interfaces it.
-class HTMLInputDelegate {
+
+// A proxy interface to a WebInputElement for inline autocomplete. The proxy
+// is overridden by webpasswordautocompletelistener_unittest.
+class WebInputElementDelegate {
public:
- explicit HTMLInputDelegate(WebCore::HTMLInputElement* element);
- virtual ~HTMLInputDelegate();
+ WebInputElementDelegate();
+ WebInputElementDelegate(WebInputElement& element);
+ virtual ~WebInputElementDelegate();
// These are virtual to support unit testing.
virtual void SetValue(const string16& value);
@@ -35,27 +37,25 @@ class HTMLInputDelegate {
int default_suggestion_index);
private:
- // The underlying DOM element we're wrapping. We reference the underlying
- // HTMLInputElement for its lifetime to ensure it does not get freed by
- // WebCore while in use by the delegate instance.
- RefPtr<WebCore::HTMLInputElement> element_;
+ // The underlying DOM element we're wrapping.
+ WebInputElement element_;
- DISALLOW_COPY_AND_ASSIGN(HTMLInputDelegate);
+ DISALLOW_COPY_AND_ASSIGN(WebInputElementDelegate);
};
-class PasswordAutocompleteListenerImpl :
- public WebKit::PasswordAutocompleteListener {
+class WebPasswordAutocompleteListenerImpl :
+ public WebKit::WebPasswordAutocompleteListener {
public:
- PasswordAutocompleteListenerImpl(
- HTMLInputDelegate* username_delegate,
- HTMLInputDelegate* password_delegate,
+ WebPasswordAutocompleteListenerImpl(
+ WebInputElementDelegate* username_element,
+ WebInputElementDelegate* password_element,
const PasswordFormDomManager::FillData& data);
- ~PasswordAutocompleteListenerImpl() {
+ ~WebPasswordAutocompleteListenerImpl() {
}
// WebKit::PasswordAutocompleteListener methods:
- virtual void didBlurInputElement(const WebCore::String& user_input);
- virtual void performInlineAutocomplete(const WebCore::String& user_input,
+ virtual void didBlurInputElement(const WebString& user_input);
+ virtual void performInlineAutocomplete(const WebString& user_input,
bool backspace_or_delete_pressed,
bool show_suggestions);
@@ -72,13 +72,13 @@ class PasswordAutocompleteListenerImpl :
std::vector<string16>* suggestions);
// Access to password field to autocomplete on blur/username updates.
- scoped_ptr<HTMLInputDelegate> password_delegate_;
- scoped_ptr<HTMLInputDelegate> username_delegate_;
+ scoped_ptr<WebInputElementDelegate> password_delegate_;
+ scoped_ptr<WebInputElementDelegate> username_delegate_;
// Contains the extra logins for matching on delta/blur.
PasswordFormDomManager::FillData data_;
- DISALLOW_COPY_AND_ASSIGN(PasswordAutocompleteListenerImpl);
+ DISALLOW_COPY_AND_ASSIGN(WebPasswordAutocompleteListenerImpl);
};
} // webkit_glue
diff --git a/webkit/glue/password_autocomplete_listener_unittest.cc b/webkit/glue/webpasswordautocompletelistener_unittest.cc
index c422345..86863565 100644
--- a/webkit/glue/password_autocomplete_listener_unittest.cc
+++ b/webkit/glue/webpasswordautocompletelistener_unittest.cc
@@ -7,42 +7,25 @@
// higher level dom autocomplete framework).
#include <string>
-#include "config.h"
-
-#include "base/compiler_specific.h"
-
-MSVC_PUSH_WARNING_LEVEL(0);
-#include "HTMLInputElement.h"
-#include "HTMLFormElement.h"
-#include "Document.h"
-#include "Frame.h"
-#include "Editor.h"
-#include "EventNames.h"
-#include "Event.h"
-#include "EventListener.h"
-#include "PlatformString.h"
-MSVC_POP_WARNING();
-
-#undef LOG
#include "base/string_util.h"
#include "webkit/glue/glue_util.h"
-#include "webkit/glue/password_autocomplete_listener_impl.h"
+#include "webkit/glue/webpasswordautocompletelistener_impl.h"
#include "testing/gtest/include/gtest/gtest.h"
-using WebCore::String;
-using webkit_glue::PasswordAutocompleteListenerImpl;
+using WebKit::WebString;
+using webkit_glue::WebPasswordAutocompleteListenerImpl;
using webkit_glue::PasswordFormDomManager;
-using webkit_glue::HTMLInputDelegate;
+using webkit_glue::WebInputElementDelegate;
-class TestHTMLInputDelegate : public HTMLInputDelegate {
+class TestWebInputElementDelegate : public WebInputElementDelegate {
public:
- TestHTMLInputDelegate() : HTMLInputDelegate(NULL),
- did_call_on_finish_(false),
- did_set_value_(false),
- did_set_selection_(false),
- selection_start_(0),
- selection_end_(0) {
+ TestWebInputElementDelegate() : WebInputElementDelegate(),
+ did_call_on_finish_(false),
+ did_set_value_(false),
+ did_set_selection_(false),
+ selection_start_(0),
+ selection_end_(0) {
}
// Override those methods we implicitly invoke in the tests.
@@ -124,42 +107,46 @@ class PasswordManagerAutocompleteTests : public testing::Test {
};
TEST_F(PasswordManagerAutocompleteTests, OnBlur) {
- TestHTMLInputDelegate* username_delegate = new TestHTMLInputDelegate();
- TestHTMLInputDelegate* password_delegate = new TestHTMLInputDelegate();
+ TestWebInputElementDelegate* username_delegate =
+ new TestWebInputElementDelegate();
+ TestWebInputElementDelegate* password_delegate =
+ new TestWebInputElementDelegate();
- scoped_ptr<PasswordAutocompleteListenerImpl> listener(
- new PasswordAutocompleteListenerImpl(username_delegate,
- password_delegate,
- data_));
+ scoped_ptr<WebPasswordAutocompleteListenerImpl> listener(
+ new WebPasswordAutocompleteListenerImpl(username_delegate,
+ password_delegate,
+ data_));
// Clear the password field.
password_delegate->SetValue(string16());
// Simulate a blur event on the username field and expect a password autofill.
- listener->didBlurInputElement(webkit_glue::String16ToString(username1_));
+ listener->didBlurInputElement(username1_);
EXPECT_EQ(password1_, password_delegate->value());
// Now the user goes back and changes the username to something we don't
// have saved. The password should remain unchanged.
- listener->didBlurInputElement(String("blahblahblah"));
+ listener->didBlurInputElement(ASCIIToUTF16("blahblahblah"));
EXPECT_EQ(password1_, password_delegate->value());
// Now they type in the additional login username.
- listener->didBlurInputElement(webkit_glue::String16ToString(username2_));
+ listener->didBlurInputElement(username2_);
EXPECT_EQ(password2_, password_delegate->value());
}
TEST_F(PasswordManagerAutocompleteTests, OnInlineAutocompleteNeeded) {
- TestHTMLInputDelegate* username_delegate = new TestHTMLInputDelegate();
- TestHTMLInputDelegate* password_delegate = new TestHTMLInputDelegate();
+ TestWebInputElementDelegate* username_delegate =
+ new TestWebInputElementDelegate();
+ TestWebInputElementDelegate* password_delegate =
+ new TestWebInputElementDelegate();
- scoped_ptr<PasswordAutocompleteListenerImpl> listener(
- new PasswordAutocompleteListenerImpl(username_delegate,
- password_delegate,
- data_));
+ scoped_ptr<WebPasswordAutocompleteListenerImpl> listener(
+ new WebPasswordAutocompleteListenerImpl(username_delegate,
+ password_delegate,
+ data_));
password_delegate->SetValue(string16());
// Simulate the user typing in the first letter of 'alice', a stored username.
- listener->performInlineAutocomplete(String("a"), false, false);
+ listener->performInlineAutocomplete(ASCIIToUTF16("a"), false, false);
// Both the username and password delegates should reflect selection
// of the stored login.
EXPECT_EQ(username1_, username_delegate->value());
@@ -172,7 +159,7 @@ TEST_F(PasswordManagerAutocompleteTests, OnInlineAutocompleteNeeded) {
EXPECT_TRUE(password_delegate->did_call_on_finish());
// Now the user types the next letter of the same username, 'l'.
- listener->performInlineAutocomplete(String("al"), false, false);
+ listener->performInlineAutocomplete(ASCIIToUTF16("al"), false, false);
// Now the fields should have the same value, but the selection should have a
// different start value.
EXPECT_EQ(username1_, username_delegate->value());
@@ -192,7 +179,7 @@ TEST_F(PasswordManagerAutocompleteTests, OnInlineAutocompleteNeeded) {
// was invoked during performInlineAutocomplete.
username_delegate->ResetTestState();
password_delegate->ResetTestState();
- listener->performInlineAutocomplete(String("alf"), false, false);
+ listener->performInlineAutocomplete(ASCIIToUTF16("alf"), false, false);
EXPECT_FALSE(username_delegate->did_set_selection());
EXPECT_FALSE(username_delegate->did_set_value());
EXPECT_FALSE(username_delegate->did_call_on_finish());
@@ -200,7 +187,7 @@ TEST_F(PasswordManagerAutocompleteTests, OnInlineAutocompleteNeeded) {
EXPECT_FALSE(password_delegate->did_call_on_finish());
// Ok, so now the user removes all the text and enters the letter 'b'.
- listener->performInlineAutocomplete(String("b"), false, false);
+ listener->performInlineAutocomplete(ASCIIToUTF16("b"), false, false);
// The username and password fields should match the 'bob' entry.
EXPECT_EQ(username2_, username_delegate->value());
EXPECT_EQ(password2_, password_delegate->value());
@@ -209,43 +196,45 @@ TEST_F(PasswordManagerAutocompleteTests, OnInlineAutocompleteNeeded) {
}
TEST_F(PasswordManagerAutocompleteTests, TestWaitUsername) {
- TestHTMLInputDelegate* username_delegate = new TestHTMLInputDelegate();
- TestHTMLInputDelegate* password_delegate = new TestHTMLInputDelegate();
+ TestWebInputElementDelegate* username_delegate =
+ new TestWebInputElementDelegate();
+ TestWebInputElementDelegate* password_delegate =
+ new TestWebInputElementDelegate();
// If we had an action authority mismatch (for example), we don't want to
// automatically autofill anything without some user interaction first.
// We require an explicit blur on the username field, and that a valid
// matching username is in the field, before we autofill passwords.
data_.wait_for_username = true;
- scoped_ptr<PasswordAutocompleteListenerImpl> listener(
- new PasswordAutocompleteListenerImpl(username_delegate,
- password_delegate,
- data_));
+ scoped_ptr<WebPasswordAutocompleteListenerImpl> listener(
+ new WebPasswordAutocompleteListenerImpl(username_delegate,
+ password_delegate,
+ data_));
string16 empty;
// In all cases, username_delegate should remain empty because we should
// never modify it when wait_for_username is true; only the user can by
// typing into (in real life) the HTMLInputElement.
password_delegate->SetValue(string16());
- listener->performInlineAutocomplete(String("a"), false, false);
+ listener->performInlineAutocomplete(ASCIIToUTF16("a"), false, false);
EXPECT_EQ(empty, username_delegate->value());
EXPECT_EQ(empty, password_delegate->value());
- listener->performInlineAutocomplete(String("al"), false, false);
+ listener->performInlineAutocomplete(ASCIIToUTF16("al"), false, false);
EXPECT_EQ(empty, username_delegate->value());
EXPECT_EQ(empty, password_delegate->value());
- listener->performInlineAutocomplete(String("alice"), false, false);
+ listener->performInlineAutocomplete(ASCIIToUTF16("alice"), false, false);
EXPECT_EQ(empty, username_delegate->value());
EXPECT_EQ(empty, password_delegate->value());
- listener->didBlurInputElement(String("a"));
+ listener->didBlurInputElement(ASCIIToUTF16("a"));
EXPECT_EQ(empty, username_delegate->value());
EXPECT_EQ(empty, password_delegate->value());
- listener->didBlurInputElement(String("ali"));
+ listener->didBlurInputElement(ASCIIToUTF16("ali"));
EXPECT_EQ(empty, username_delegate->value());
EXPECT_EQ(empty, password_delegate->value());
// Blur with 'alice' should allow password autofill.
- listener->didBlurInputElement(String("alice"));
+ listener->didBlurInputElement(ASCIIToUTF16("alice"));
EXPECT_EQ(empty, username_delegate->value());
EXPECT_EQ(password1_, password_delegate->value());
}
diff --git a/webkit/tools/test_shell/test_shell.gyp b/webkit/tools/test_shell/test_shell.gyp
index b96f25b..de99a6f 100644
--- a/webkit/tools/test_shell/test_shell.gyp
+++ b/webkit/tools/test_shell/test_shell.gyp
@@ -389,7 +389,6 @@
'../../glue/mimetype_unittest.cc',
'../../glue/mock_resource_loader_bridge.h',
'../../glue/multipart_response_delegate_unittest.cc',
- '../../glue/password_autocomplete_listener_unittest.cc',
'../../glue/plugins/plugin_lib_unittest.cc',
'../../glue/regular_expression_unittest.cc',
'../../glue/resource_fetcher_unittest.cc',
@@ -397,6 +396,7 @@
'../../glue/webcursor_unittest.cc',
'../../glue/webview_unittest.cc',
'../../glue/webframe_unittest.cc',
+ '../../glue/webpasswordautocompletelistener_unittest.cc',
'../../glue/webplugin_impl_unittest.cc',
'../webcore_unit_tests/BMPImageDecoder_unittest.cpp',
'../webcore_unit_tests/GKURL_unittest.cpp',
diff --git a/webkit/tools/test_shell/test_webview_delegate.cc b/webkit/tools/test_shell/test_webview_delegate.cc
index a05551b..2dadda1 100644
--- a/webkit/tools/test_shell/test_webview_delegate.cc
+++ b/webkit/tools/test_shell/test_webview_delegate.cc
@@ -74,7 +74,7 @@ using WebKit::WebDataSource;
using WebKit::WebDragData;
using WebKit::WebDragOperationsMask;
using WebKit::WebEditingAction;
-using WebKit::WebForm;
+using WebKit::WebFormElement;
using WebKit::WebFrame;
using WebKit::WebHistoryItem;
using WebKit::WebMediaPlayer;
diff --git a/webkit/webkit.gyp b/webkit/webkit.gyp
index 1fa755b..e7259c2 100644
--- a/webkit/webkit.gyp
+++ b/webkit/webkit.gyp
@@ -319,8 +319,6 @@
'glue/multipart_response_delegate.h',
'glue/npruntime_util.cc',
'glue/npruntime_util.h',
- 'glue/password_autocomplete_listener_impl.cc',
- 'glue/password_autocomplete_listener_impl.h',
'glue/password_form.h',
'glue/password_form_dom_manager.cc',
'glue/password_form_dom_manager.h',
@@ -359,6 +357,8 @@
'glue/webmenuitem.h',
'glue/webmenurunner_mac.h',
'glue/webmenurunner_mac.mm',
+ 'glue/webpasswordautocompletelistener_impl.cc',
+ 'glue/webpasswordautocompletelistener_impl.h',
'glue/webplugin.h',
'glue/webplugin_delegate.h',
'glue/webplugin_impl.cc',