summaryrefslogtreecommitdiffstats
path: root/webkit
diff options
context:
space:
mode:
Diffstat (limited to 'webkit')
-rw-r--r--webkit/api/public/WebView.h15
-rw-r--r--webkit/api/public/WebViewClient.h15
-rw-r--r--webkit/glue/autofill_form.cc14
-rw-r--r--webkit/glue/autofill_form.h8
-rw-r--r--webkit/glue/editor_client_impl.cc19
-rw-r--r--webkit/glue/password_autocomplete_listener.cc52
-rw-r--r--webkit/glue/password_autocomplete_listener.h18
-rw-r--r--webkit/glue/password_autocomplete_listener_unittest.cc63
-rw-r--r--webkit/glue/webview.h9
-rw-r--r--webkit/glue/webview_delegate.h15
-rw-r--r--webkit/glue/webview_impl.cc69
-rw-r--r--webkit/glue/webview_impl.h10
-rw-r--r--webkit/tools/test_shell/test_webview_delegate.h7
13 files changed, 168 insertions, 146 deletions
diff --git a/webkit/api/public/WebView.h b/webkit/api/public/WebView.h
index e7994a2..a886424 100644
--- a/webkit/api/public/WebView.h
+++ b/webkit/api/public/WebView.h
@@ -39,11 +39,13 @@ namespace WebKit {
class WebDragData;
class WebFrame;
class WebFrameClient;
+ class WebNode;
class WebSettings;
class WebString;
class WebViewClient;
struct WebMediaPlayerAction;
struct WebPoint;
+ template <typename T> class WebVector;
class WebView : public WebWidget {
public:
@@ -207,6 +209,19 @@ namespace WebKit {
// Returns the accessibility object for this view.
virtual WebAccessibilityObject accessibilityObject() = 0;
+
+ // Autofill ------------------------------------------------------------
+
+ // Notifies the WebView that autofill suggestions are available for a node.
+ virtual void applyAutofillSuggestions(
+ const WebNode&,
+ const WebVector<WebString>& suggestions,
+ int defaultSuggestionIndex) = 0;
+
+ // Hides the autofill popup if any are showing.
+ virtual void hideAutofillPopup() = 0;
+
+
// FIXME what about:
// GetDelegate
// AutofillSuggestionsForNode
diff --git a/webkit/api/public/WebViewClient.h b/webkit/api/public/WebViewClient.h
index e613cac..725d785 100644
--- a/webkit/api/public/WebViewClient.h
+++ b/webkit/api/public/WebViewClient.h
@@ -252,6 +252,21 @@ namespace WebKit {
virtual void didUpdateInspectorSettings() = 0;
+ // Autofill ------------------------------------------------------------
+
+ // Queries the browser for suggestions to be shown for the form text
+ // field named |name|. |value| is the text entered by the user so
+ // far and the WebNode corresponds to the input field.
+ virtual void queryAutofillSuggestions(const WebNode&,
+ const WebString& name,
+ const WebString& value) = 0;
+
+ // Instructs the browser to remove the autofill entry specified from
+ // its DB.
+ virtual void removeAutofillSuggestions(const WebString& name,
+ const WebString& value) = 0;
+
+
// FIXME need to something for:
// OnPasswordFormsSeen
// OnAutofillFormSubmitted
diff --git a/webkit/glue/autofill_form.cc b/webkit/glue/autofill_form.cc
index 976d494..5c1a77b 100644
--- a/webkit/glue/autofill_form.cc
+++ b/webkit/glue/autofill_form.cc
@@ -57,12 +57,12 @@ AutofillForm* AutofillForm::Create(const WebForm& webform) {
continue;
// For each TEXT input field, store the name and value
- std::wstring value = StringToStdWString(input_element->value());
+ string16 value = StringToString16(input_element->value());
TrimWhitespace(value, TRIM_LEADING, &value);
if (value.length() == 0)
continue;
- std::wstring name = GetNameForInputElement(input_element);
+ string16 name = GetNameForInputElement(input_element);
if (name.length() == 0)
continue; // If we have no name, there is nothing to store.
@@ -73,20 +73,20 @@ AutofillForm* AutofillForm::Create(const WebForm& webform) {
}
// static
-std::wstring AutofillForm::GetNameForInputElement(WebCore::HTMLInputElement*
+string16 AutofillForm::GetNameForInputElement(WebCore::HTMLInputElement*
element) {
- std::wstring name = StringToStdWString(element->name());
- std::wstring trimmed_name;
+ string16 name = StringToString16(element->name());
+ string16 trimmed_name;
TrimWhitespace(name, TRIM_LEADING, &trimmed_name);
if (trimmed_name.length() > 0)
return trimmed_name;
- name = StringToStdWString(element->getAttribute(WebCore::HTMLNames::idAttr));
+ name = StringToString16(element->getAttribute(WebCore::HTMLNames::idAttr));
TrimWhitespace(name, TRIM_LEADING, &trimmed_name);
if (trimmed_name.length() > 0)
return trimmed_name;
- return std::wstring();
+ return string16();
}
} // namespace webkit_glue
diff --git a/webkit/glue/autofill_form.h b/webkit/glue/autofill_form.h
index 4cf1b20..487c556 100644
--- a/webkit/glue/autofill_form.h
+++ b/webkit/glue/autofill_form.h
@@ -25,12 +25,12 @@ class AutofillForm {
// Struct for storing name/value pairs.
struct Element {
Element() {}
- Element(const std::wstring& in_name, const std::wstring& in_value) {
+ Element(const string16& in_name, const string16& in_value) {
name = in_name;
value = in_value;
}
- std::wstring name;
- std::wstring value;
+ string16 name;
+ string16 value;
};
static AutofillForm* Create(const WebKit::WebForm& form);
@@ -38,7 +38,7 @@ class AutofillForm {
// Returns the name that should be used for the specified |element| when
// storing autofill data. This is either the field name or its id, an empty
// string if it has no name and no id.
- static std::wstring GetNameForInputElement(WebCore::HTMLInputElement*
+ static string16 GetNameForInputElement(WebCore::HTMLInputElement*
element);
// A vector of all the input fields in the form.
diff --git a/webkit/glue/editor_client_impl.cc b/webkit/glue/editor_client_impl.cc
index 7f57528..6ea16db 100644
--- a/webkit/glue/editor_client_impl.cc
+++ b/webkit/glue/editor_client_impl.cc
@@ -671,8 +671,8 @@ void EditorClientImpl::textFieldDidEndEditing(WebCore::Element* element) {
if (!listener)
return;
- std::wstring value =
- webkit_glue::StringToStdWString(input_element->value());
+ string16 value =
+ webkit_glue::StringToString16(input_element->value());
listener->OnBlur(input_element, value);
}
@@ -706,7 +706,7 @@ bool EditorClientImpl::Autofill(WebCore::HTMLInputElement* input_element,
return false;
}
- std::wstring name = AutofillForm::GetNameForInputElement(input_element);
+ string16 name = AutofillForm::GetNameForInputElement(input_element);
if (name.empty()) // If the field has no name, then we won't have values.
return false;
@@ -736,7 +736,7 @@ void EditorClientImpl::DoAutofill(WebCore::Timer<EditorClientImpl>* timer) {
OwnPtr<AutofillArgs> args(autofill_args_.release());
WebCore::HTMLInputElement* input_element = args->input_element.get();
- std::wstring value = webkit_glue::StringToStdWString(input_element->value());
+ string16 value = webkit_glue::StringToString16(input_element->value());
// Enforce autofill_on_empty_value and caret_at_end.
bool is_caret_at_end = args->require_caret_at_end ?
@@ -766,12 +766,13 @@ void EditorClientImpl::DoAutofill(WebCore::Timer<EditorClientImpl>* timer) {
}
// Then trigger form autofill.
- std::wstring name = AutofillForm::GetNameForInputElement(input_element);
+ string16 name = AutofillForm::GetNameForInputElement(input_element);
ASSERT(static_cast<int>(name.length()) > 0);
- if (webview_->delegate())
- webview_->delegate()->QueryFormFieldAutofill(name, value,
- reinterpret_cast<int64>(input_element));
+ if (webview_->client()) {
+ webview_->client()->queryAutofillSuggestions(
+ webkit_glue::NodeToWebNode(input_element), name, value);
+ }
}
void EditorClientImpl::CancelPendingAutofill() {
@@ -785,7 +786,7 @@ void EditorClientImpl::OnAutofillSuggestionAccepted(
WebFrameImpl::FromFrame(text_field->document()->frame());
webkit_glue::PasswordAutocompleteListener* listener =
webframe->GetPasswordListener(text_field);
- std::wstring value = webkit_glue::StringToStdWString(text_field->value());
+ string16 value = webkit_glue::StringToString16(text_field->value());
// Password listeners need to autocomplete other fields that depend on the
// input element with autofill suggestions.
if (listener)
diff --git a/webkit/glue/password_autocomplete_listener.cc b/webkit/glue/password_autocomplete_listener.cc
index ac0b16d..5acf579 100644
--- a/webkit/glue/password_autocomplete_listener.cc
+++ b/webkit/glue/password_autocomplete_listener.cc
@@ -12,6 +12,8 @@
#include "base/logging.h"
#include "base/string_util.h"
+#include "webkit/api/public/WebNode.h"
+#include "webkit/api/public/WebVector.h"
#include "webkit/glue/glue_util.h"
#include "webkit/glue/password_autocomplete_listener.h"
#include "webkit/glue/webframe_impl.h"
@@ -32,8 +34,8 @@ HTMLInputDelegate::~HTMLInputDelegate() {
element_->deref();
}
-void HTMLInputDelegate::SetValue(const std::wstring& value) {
- element_->setValue(StdWStringToString(value));
+void HTMLInputDelegate::SetValue(const string16& value) {
+ element_->setValue(String16ToString(value));
}
void HTMLInputDelegate::SetSelectionRange(size_t start, size_t end) {
@@ -49,7 +51,7 @@ void HTMLInputDelegate::OnFinishedAutocompleting() {
}
void HTMLInputDelegate::RefreshAutofillPopup(
- const std::vector<std::wstring>& suggestions,
+ const std::vector<string16>& suggestions,
int default_suggestion_index) {
WebFrameImpl* webframe =
WebFrameImpl::FromFrame(element_->document()->frame());
@@ -57,8 +59,8 @@ void HTMLInputDelegate::RefreshAutofillPopup(
if (!webview)
return;
- int64 node_id = reinterpret_cast<int64>(element_);
- webview->AutofillSuggestionsForNode(node_id, suggestions, 0);
+ webview->applyAutofillSuggestions(
+ webkit_glue::NodeToWebNode(element_), suggestions, 0);
}
PasswordAutocompleteListener::PasswordAutocompleteListener(
@@ -71,27 +73,28 @@ PasswordAutocompleteListener::PasswordAutocompleteListener(
}
void PasswordAutocompleteListener::OnBlur(WebCore::HTMLInputElement* element,
- const std::wstring& user_input) {
+ const string16& 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.
DCHECK(data_.basic_data.values.size() == 2);
// Set the password field to match the current username.
- if (data_.basic_data.values[0] == user_input) {
+ if (WideToUTF16Hack(data_.basic_data.values[0]) == user_input) {
// Preferred username/login is selected.
- password_delegate_->SetValue(data_.basic_data.values[1]);
- } else if (data_.additional_logins.find(user_input) !=
+ password_delegate_->SetValue(WideToUTF16Hack(data_.basic_data.values[1]));
+ } else if (data_.additional_logins.find(UTF16ToWideHack(user_input)) !=
data_.additional_logins.end()) {
// One of the extra username/logins is selected.
- password_delegate_->SetValue(data_.additional_logins[user_input]);
+ password_delegate_->SetValue(
+ WideToUTF16Hack(data_.additional_logins[UTF16ToWideHack(user_input)]));
}
password_delegate_->OnFinishedAutocompleting();
}
void PasswordAutocompleteListener::OnInlineAutocompleteNeeded(
WebCore::HTMLInputElement* element,
- const std::wstring& user_input,
+ const string16& user_input,
bool backspace_or_delete,
bool with_suggestion_popup) {
// If wait_for_username is true, we only autofill the password when
@@ -101,7 +104,7 @@ void PasswordAutocompleteListener::OnInlineAutocompleteNeeded(
return;
if (with_suggestion_popup) {
- std::vector<std::wstring> suggestions;
+ std::vector<string16> suggestions;
GetSuggestions(user_input, &suggestions);
username_delegate_->RefreshAutofillPopup(suggestions, 0);
}
@@ -117,8 +120,8 @@ void PasswordAutocompleteListener::OnInlineAutocompleteNeeded(
// conversions (see SetValue) on each successful call to
// OnInlineAutocompleteNeeded.
if (TryToMatch(user_input,
- data_.basic_data.values[0],
- data_.basic_data.values[1])) {
+ WideToUTF16Hack(data_.basic_data.values[0]),
+ WideToUTF16Hack(data_.basic_data.values[1]))) {
return;
}
@@ -127,14 +130,16 @@ void PasswordAutocompleteListener::OnInlineAutocompleteNeeded(
data_.additional_logins.begin();
it != data_.additional_logins.end();
++it) {
- if (TryToMatch(user_input, it->first, it->second))
+ if (TryToMatch(user_input,
+ WideToUTF16Hack(it->first),
+ WideToUTF16Hack(it->second)))
return;
}
}
-bool PasswordAutocompleteListener::TryToMatch(const std::wstring& input,
- const std::wstring& username,
- const std::wstring& password) {
+bool PasswordAutocompleteListener::TryToMatch(const string16& input,
+ const string16& username,
+ const string16& password) {
if (!StartsWith(username, input, false))
return false;
@@ -148,16 +153,17 @@ bool PasswordAutocompleteListener::TryToMatch(const std::wstring& input,
}
void PasswordAutocompleteListener::GetSuggestions(
- const std::wstring& input, std::vector<std::wstring>* suggestions) {
- if (StartsWith(data_.basic_data.values[0], input, false))
- suggestions->push_back(data_.basic_data.values[0]);
+ const string16& input, std::vector<string16>* suggestions) {
+ std::wstring wide_input = UTF16ToWideHack(input);
+ if (StartsWith(data_.basic_data.values[0], wide_input, false))
+ suggestions->push_back(WideToUTF16Hack(data_.basic_data.values[0]));
for (PasswordFormDomManager::LoginCollection::iterator it =
data_.additional_logins.begin();
it != data_.additional_logins.end();
++it) {
- if (StartsWith(it->first, input, false))
- suggestions->push_back(it->first);
+ if (StartsWith(it->first, wide_input, false))
+ suggestions->push_back(WideToUTF16Hack(it->first));
}
}
diff --git a/webkit/glue/password_autocomplete_listener.h b/webkit/glue/password_autocomplete_listener.h
index a5fbce1..d0dc487 100644
--- a/webkit/glue/password_autocomplete_listener.h
+++ b/webkit/glue/password_autocomplete_listener.h
@@ -25,11 +25,11 @@ class HTMLInputDelegate {
explicit HTMLInputDelegate(WebCore::HTMLInputElement* element);
virtual ~HTMLInputDelegate();
- virtual void SetValue(const std::wstring& value);
+ virtual void SetValue(const string16& value);
virtual void SetSelectionRange(size_t start, size_t end);
virtual void OnFinishedAutocompleting();
virtual void RefreshAutofillPopup(
- const std::vector<std::wstring>& suggestions,
+ const std::vector<string16>& suggestions,
int default_suggestion_index);
private:
@@ -51,9 +51,9 @@ class PasswordAutocompleteListener {
}
virtual void OnBlur(WebCore::HTMLInputElement* element,
- const std::wstring& user_input);
+ const string16& user_input);
virtual void OnInlineAutocompleteNeeded(WebCore::HTMLInputElement* element,
- const std::wstring& user_input,
+ const string16& user_input,
bool backspace_or_delete,
bool with_suggestion_popup);
@@ -61,13 +61,13 @@ class PasswordAutocompleteListener {
// Check if the input string resembles a potential matching login
// (username/password) and if so, match them up by autocompleting the edit
// delegates.
- bool TryToMatch(const std::wstring& input,
- const std::wstring& username,
- const std::wstring& password);
+ bool TryToMatch(const string16& input,
+ const string16& username,
+ const string16& password);
// Scan |data_| for prefix matches of |input| and add each to |suggestions|.
- void GetSuggestions(const std::wstring& input,
- std::vector<std::wstring>* suggestions);
+ void GetSuggestions(const string16& input,
+ std::vector<string16>* suggestions);
// Access to password field to autocomplete on blur/username updates.
scoped_ptr<HTMLInputDelegate> password_delegate_;
diff --git a/webkit/glue/password_autocomplete_listener_unittest.cc b/webkit/glue/password_autocomplete_listener_unittest.cc
index 3a12047..7c05243 100644
--- a/webkit/glue/password_autocomplete_listener_unittest.cc
+++ b/webkit/glue/password_autocomplete_listener_unittest.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
+// Copyright (c) 2006-2009 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.
//
@@ -24,6 +24,7 @@ MSVC_POP_WARNING();
#undef LOG
+#include "base/string_util.h"
#include "webkit/glue/password_autocomplete_listener.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -42,7 +43,7 @@ class TestHTMLInputDelegate : public HTMLInputDelegate {
}
// Override those methods we implicitly invoke in the tests.
- virtual void SetValue(const std::wstring& value) {
+ virtual void SetValue(const string16& value) {
value_ = value;
did_set_value_ = true;
}
@@ -64,7 +65,7 @@ class TestHTMLInputDelegate : public HTMLInputDelegate {
did_set_selection_ = false;
}
- std::wstring value() const {
+ string16 value() const {
return value_;
}
@@ -92,7 +93,7 @@ class TestHTMLInputDelegate : public HTMLInputDelegate {
bool did_call_on_finish_;
bool did_set_value_;
bool did_set_selection_;
- std::wstring value_;
+ string16 value_;
size_t selection_start_;
size_t selection_end_;
};
@@ -102,20 +103,21 @@ class PasswordManagerAutocompleteTests : public testing::Test {
public:
virtual void SetUp() {
// Add a preferred login and an additional login to the FillData.
- username1_ = L"alice";
- password1_ = L"password";
- username2_ = L"bob";
- password2_ = L"bobsyouruncle";
- data_.basic_data.values.push_back(username1_);
- data_.basic_data.values.push_back(password1_);
- data_.additional_logins[username2_] = password2_;
+ username1_ = ASCIIToUTF16("alice");
+ password1_ = ASCIIToUTF16("password");
+ username2_ = ASCIIToUTF16("bob");
+ password2_ = ASCIIToUTF16("bobsyouruncle");
+ data_.basic_data.values.push_back(UTF16ToWideHack(username1_));
+ data_.basic_data.values.push_back(UTF16ToWideHack(password1_));
+ data_.additional_logins[UTF16ToWideHack(username2_)] =
+ UTF16ToWideHack(password2_);
testing::Test::SetUp();
}
- std::wstring username1_;
- std::wstring password1_;
- std::wstring username2_;
- std::wstring password2_;
+ string16 username1_;
+ string16 password1_;
+ string16 username2_;
+ string16 password2_;
PasswordFormDomManager::FillData data_;
};
@@ -128,14 +130,14 @@ TEST_F(PasswordManagerAutocompleteTests, OnBlur) {
data_));
// Clear the password field.
- password_delegate->SetValue(std::wstring());
+ password_delegate->SetValue(string16());
// Simulate a blur event on the username field and expect a password autofill.
listener->OnBlur(NULL, 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->OnBlur(NULL, L"blahblahblah");
+ listener->OnBlur(NULL, ASCIIToUTF16("blahblahblah"));
EXPECT_EQ(password1_, password_delegate->value());
// Now they type in the additional login username.
@@ -151,9 +153,9 @@ TEST_F(PasswordManagerAutocompleteTests, OnInlineAutocompleteNeeded) {
new PasswordAutocompleteListener(username_delegate, password_delegate,
data_));
- password_delegate->SetValue(std::wstring());
+ password_delegate->SetValue(string16());
// Simulate the user typing in the first letter of 'alice', a stored username.
- listener->OnInlineAutocompleteNeeded(NULL, L"a", false, false);
+ listener->OnInlineAutocompleteNeeded(NULL, ASCIIToUTF16("a"), false, false);
// Both the username and password delegates should reflect selection
// of the stored login.
EXPECT_EQ(username1_, username_delegate->value());
@@ -166,7 +168,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->OnInlineAutocompleteNeeded(NULL, L"al", false, false);
+ listener->OnInlineAutocompleteNeeded(NULL, 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());
@@ -186,7 +188,7 @@ TEST_F(PasswordManagerAutocompleteTests, OnInlineAutocompleteNeeded) {
// was invoked during OnInlineAutocompleteNeeded.
username_delegate->ResetTestState();
password_delegate->ResetTestState();
- listener->OnInlineAutocompleteNeeded(NULL, L"alf", false, false);
+ listener->OnInlineAutocompleteNeeded(NULL, 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());
@@ -194,7 +196,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->OnInlineAutocompleteNeeded(NULL, L"b", false, false);
+ listener->OnInlineAutocompleteNeeded(NULL, 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());
@@ -215,30 +217,31 @@ TEST_F(PasswordManagerAutocompleteTests, TestWaitUsername) {
new PasswordAutocompleteListener(username_delegate, password_delegate,
data_));
- std::wstring empty;
+ 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(std::wstring());
- listener->OnInlineAutocompleteNeeded(NULL, L"a", false, false);
+ password_delegate->SetValue(string16());
+ listener->OnInlineAutocompleteNeeded(NULL, ASCIIToUTF16("a"), false, false);
EXPECT_EQ(empty, username_delegate->value());
EXPECT_EQ(empty, password_delegate->value());
- listener->OnInlineAutocompleteNeeded(NULL, L"al", false, false);
+ listener->OnInlineAutocompleteNeeded(NULL, ASCIIToUTF16("al"), false, false);
EXPECT_EQ(empty, username_delegate->value());
EXPECT_EQ(empty, password_delegate->value());
- listener->OnInlineAutocompleteNeeded(NULL, L"alice", false, false);
+ listener->OnInlineAutocompleteNeeded(NULL, ASCIIToUTF16("alice"), false,
+ false);
EXPECT_EQ(empty, username_delegate->value());
EXPECT_EQ(empty, password_delegate->value());
- listener->OnBlur(NULL, L"a");
+ listener->OnBlur(NULL, ASCIIToUTF16("a"));
EXPECT_EQ(empty, username_delegate->value());
EXPECT_EQ(empty, password_delegate->value());
- listener->OnBlur(NULL, L"ali");
+ listener->OnBlur(NULL, ASCIIToUTF16("ali"));
EXPECT_EQ(empty, username_delegate->value());
EXPECT_EQ(empty, password_delegate->value());
// Blur with 'alice' should allow password autofill.
- listener->OnBlur(NULL, L"alice");
+ listener->OnBlur(NULL, ASCIIToUTF16("alice"));
EXPECT_EQ(empty, username_delegate->value());
EXPECT_EQ(password1_, password_delegate->value());
}
diff --git a/webkit/glue/webview.h b/webkit/glue/webview.h
index 7e8f569..036e5a3 100644
--- a/webkit/glue/webview.h
+++ b/webkit/glue/webview.h
@@ -63,15 +63,6 @@ class WebView : public WebKit::WebView {
// links.
static void ResetVisitedLinkState();
- // Notifies the webview that autofill suggestions are available for a node.
- virtual void AutofillSuggestionsForNode(
- int64 node_id,
- const std::vector<std::wstring>& suggestions,
- int default_suggestion_index) = 0;
-
- // Hides the autofill popup if any are showing.
- virtual void HideAutofillPopup() = 0;
-
// Returns development tools agent instance belonging to this view.
virtual WebDevToolsAgent* GetWebDevToolsAgent() = 0;
diff --git a/webkit/glue/webview_delegate.h b/webkit/glue/webview_delegate.h
index 2263519..ca558f9 100644
--- a/webkit/glue/webview_delegate.h
+++ b/webkit/glue/webview_delegate.h
@@ -62,21 +62,6 @@ class WebViewDelegate : public WebKit::WebViewClient {
return true;
}
- // ChromeClient ------------------------------------------------------------
-
- // Queries the browser for suggestions to be shown for the form text field
- // named |field_name|. |text| is the text entered by the user so far and
- // |node_id| is the id of the node of the input field.
- virtual void QueryFormFieldAutofill(const std::wstring& field_name,
- const std::wstring& text,
- int64 node_id) {
- }
-
- // Instructs the browser to remove the autofill entry specified from it DB.
- virtual void RemoveStoredAutofillEntry(const std::wstring& name,
- const std::wstring& value) {
- }
-
// DevTools ----------------------------------------------------------------
virtual WebDevToolsAgentDelegate* GetWebDevToolsAgentDelegate() {
diff --git a/webkit/glue/webview_impl.cc b/webkit/glue/webview_impl.cc
index 7508e67..c276505 100644
--- a/webkit/glue/webview_impl.cc
+++ b/webkit/glue/webview_impl.cc
@@ -69,6 +69,7 @@ MSVC_POP_WARNING();
#include "webkit/api/public/WebPoint.h"
#include "webkit/api/public/WebRect.h"
#include "webkit/api/public/WebString.h"
+#include "webkit/api/public/WebVector.h"
#include "webkit/api/src/WebInputEventConversion.h"
#include "webkit/api/src/WebSettingsImpl.h"
#include "webkit/glue/dom_operations.h"
@@ -111,6 +112,7 @@ using WebKit::WebMediaPlayerAction;
using WebKit::WebMouseEvent;
using WebKit::WebMouseWheelEvent;
using WebKit::WebNavigationPolicy;
+using WebKit::WebNode;
using WebKit::WebPoint;
using WebKit::WebRect;
using WebKit::WebSettings;
@@ -122,8 +124,8 @@ using WebKit::WebTextDirectionDefault;
using WebKit::WebTextDirectionLeftToRight;
using WebKit::WebTextDirectionRightToLeft;
using WebKit::WebURL;
+using WebKit::WebVector;
-using webkit_glue::ImageResourceFetcher;
using webkit_glue::AccessibilityObjectToWebAccessibilityObject;
// Change the text zoom level by kTextSizeMultiplierRatio each time the user
@@ -165,7 +167,7 @@ class AutocompletePopupMenuClient : public WebCore::PopupMenuClient {
}
void Init(WebCore::HTMLInputElement* text_field,
- const std::vector<std::wstring>& suggestions,
+ const WebVector<WebString>& suggestions,
int default_suggestion_index) {
DCHECK(default_suggestion_index < static_cast<int>(suggestions.size()));
text_field_ = text_field;
@@ -284,12 +286,10 @@ class AutocompletePopupMenuClient : public WebCore::PopupMenuClient {
}
// AutocompletePopupMenuClient specific methods:
- void SetSuggestions(const std::vector<std::wstring>& suggestions) {
+ void SetSuggestions(const WebVector<WebString>& suggestions) {
suggestions_.clear();
- for (std::vector<std::wstring>::const_iterator iter = suggestions.begin();
- iter != suggestions.end(); ++iter) {
- suggestions_.push_back(webkit_glue::StdWStringToString(*iter));
- }
+ for (size_t i = 0; i < suggestions.size(); ++i)
+ suggestions_.append(webkit_glue::WebStringToString(suggestions[i]));
// Try to preserve selection if possible.
if (selected_index_ >= static_cast<int>(suggestions.size()))
selected_index_ = -1;
@@ -297,7 +297,7 @@ class AutocompletePopupMenuClient : public WebCore::PopupMenuClient {
void RemoveItemAtIndex(int index) {
DCHECK(index >= 0 && index < static_cast<int>(suggestions_.size()));
- suggestions_.erase(suggestions_.begin() + index);
+ suggestions_.remove(index);
}
WebCore::HTMLInputElement* text_field() const {
@@ -317,7 +317,7 @@ class AutocompletePopupMenuClient : public WebCore::PopupMenuClient {
private:
RefPtr<WebCore::HTMLInputElement> text_field_;
- std::vector<WebCore::String> suggestions_;
+ Vector<WebCore::String> suggestions_;
int selected_index_;
WebViewImpl* webview_;
scoped_ptr<PopupMenuStyle> style_;
@@ -679,10 +679,11 @@ bool WebViewImpl::AutocompleteHandleKeyEvent(const WebKeyboardEvent& event) {
int selected_index = autocomplete_popup_->selectedIndex();
WebCore::HTMLInputElement* input_element =
static_cast<WebCore::HTMLInputElement*>(element);
- std::wstring name = webkit_glue::StringToStdWString(input_element->name());
- std::wstring value = webkit_glue::StringToStdWString(
- autocomplete_popup_client_->itemText(selected_index ));
- delegate()->RemoveStoredAutofillEntry(name, value);
+ const WebString& name = webkit_glue::StringToWebString(
+ input_element->name());
+ const WebString& value = webkit_glue::StringToWebString(
+ autocomplete_popup_client_->itemText(selected_index));
+ client()->removeAutofillSuggestions(name, value);
// Update the entries in the currently showing popup to reflect the
// deletion.
autocomplete_popup_client_->RemoveItemAtIndex(selected_index);
@@ -1673,22 +1674,11 @@ WebAccessibilityObject WebViewImpl::accessibilityObject() {
document->axObjectCache()->getOrCreate(document->renderer()));
}
-// WebView --------------------------------------------------------------------
-
-bool WebViewImpl::setDropEffect(bool accept) {
- if (drag_target_dispatch_) {
- drop_effect_ = accept ? DROP_EFFECT_COPY : DROP_EFFECT_NONE;
- return true;
- } else {
- return false;
- }
-}
-
-void WebViewImpl::AutofillSuggestionsForNode(
- int64 node_id,
- const std::vector<std::wstring>& suggestions,
- int default_suggestion_index) {
- if (!page_.get() || suggestions.empty()) {
+void WebViewImpl::applyAutofillSuggestions(
+ const WebNode& node,
+ const WebVector<WebString>& suggestions,
+ int default_suggestion_index) {
+ if (!page_.get() || suggestions.isEmpty()) {
HideAutoCompletePopup();
return;
}
@@ -1708,7 +1698,7 @@ void WebViewImpl::AutofillSuggestionsForNode(
// TODO(jcampan): also check the carret is at the end and that the text has
// not changed.
if (!focused_node.get() ||
- reinterpret_cast<int64>(focused_node.get()) != node_id) {
+ focused_node != webkit_glue::WebNodeToNode(node)) {
HideAutoCompletePopup();
return;
}
@@ -1745,6 +1735,21 @@ void WebViewImpl::AutofillSuggestionsForNode(
}
}
+void WebViewImpl::hideAutofillPopup() {
+ HideAutoCompletePopup();
+}
+
+// WebView --------------------------------------------------------------------
+
+bool WebViewImpl::setDropEffect(bool accept) {
+ if (drag_target_dispatch_) {
+ drop_effect_ = accept ? DROP_EFFECT_COPY : DROP_EFFECT_NONE;
+ return true;
+ } else {
+ return false;
+ }
+}
+
WebDevToolsAgent* WebViewImpl::GetWebDevToolsAgent() {
return GetWebDevToolsAgentImpl();
}
@@ -1876,10 +1881,6 @@ WebKit::NotificationPresenterImpl* WebViewImpl::GetNotificationPresenter() {
}
#endif
-void WebViewImpl::HideAutofillPopup() {
- HideAutoCompletePopup();
-}
-
void WebViewImpl::RefreshAutofillPopup() {
DCHECK(autocomplete_popup_showing_);
diff --git a/webkit/glue/webview_impl.h b/webkit/glue/webview_impl.h
index d1d3b9d..eeb1d89 100644
--- a/webkit/glue/webview_impl.h
+++ b/webkit/glue/webview_impl.h
@@ -138,13 +138,13 @@ class WebViewImpl : public WebView, public base::RefCounted<WebViewImpl> {
virtual WebKit::WebString inspectorSettings() const;
virtual void setInspectorSettings(const WebKit::WebString& settings);
virtual WebKit::WebAccessibilityObject accessibilityObject();
+ virtual void applyAutofillSuggestions(
+ const WebKit::WebNode&,
+ const WebKit::WebVector<WebKit::WebString>& suggestions,
+ int defaultSuggestionIndex);
+ virtual void hideAutofillPopup();
// WebView methods:
- virtual void AutofillSuggestionsForNode(
- int64 node_id,
- const std::vector<std::wstring>& suggestions,
- int default_suggestion_index);
- virtual void HideAutofillPopup();
virtual void SetIgnoreInputEvents(bool new_value);
virtual WebDevToolsAgent* GetWebDevToolsAgent();
WebDevToolsAgentImpl* GetWebDevToolsAgentImpl();
diff --git a/webkit/tools/test_shell/test_webview_delegate.h b/webkit/tools/test_shell/test_webview_delegate.h
index 3724ff4..120c59f 100644
--- a/webkit/tools/test_shell/test_webview_delegate.h
+++ b/webkit/tools/test_shell/test_webview_delegate.h
@@ -139,9 +139,14 @@ class TestWebViewDelegate : public WebViewDelegate,
virtual int historyBackListCount();
virtual int historyForwardListCount();
virtual void didAddHistoryItem() {}
- virtual void didUpdateInspectorSettings() {}
virtual void focusAccessibilityObject(
const WebKit::WebAccessibilityObject& object);
+ virtual void didUpdateInspectorSettings() {}
+ virtual void queryAutofillSuggestions(
+ const WebKit::WebNode&, const WebKit::WebString& name,
+ const WebKit::WebString& value) {}
+ virtual void removeAutofillSuggestions(
+ const WebKit::WebString& name, const WebKit::WebString& value) {}
// WebKit::WebWidgetClient
virtual void didInvalidateRect(const WebKit::WebRect& rect);