summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/browser/autofill_manager.cc22
-rw-r--r--chrome/browser/autofill_manager.h12
-rw-r--r--chrome/browser/renderer_host/render_view_host.cc18
-rw-r--r--chrome/browser/renderer_host/render_view_host.h12
-rw-r--r--chrome/browser/renderer_host/render_view_host_delegate.h10
-rw-r--r--chrome/browser/webdata/web_data_service.cc22
-rw-r--r--chrome/browser/webdata/web_data_service.h14
-rw-r--r--chrome/browser/webdata/web_database.cc33
-rw-r--r--chrome/browser/webdata/web_database.h8
-rw-r--r--chrome/browser/webdata/web_database_unittest.cc72
-rw-r--r--chrome/common/render_messages_internal.h10
-rw-r--r--chrome/renderer/print_web_view_helper.h10
-rw-r--r--chrome/renderer/render_view.cc51
-rw-r--r--chrome/renderer/render_view.h21
-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
27 files changed, 335 insertions, 294 deletions
diff --git a/chrome/browser/autofill_manager.cc b/chrome/browser/autofill_manager.cc
index ee274df..6c5c6c7 100644
--- a/chrome/browser/autofill_manager.cc
+++ b/chrome/browser/autofill_manager.cc
@@ -23,7 +23,7 @@ void AutofillManager::RegisterUserPrefs(PrefService* prefs) {
AutofillManager::AutofillManager(TabContents* tab_contents)
: tab_contents_(tab_contents),
pending_query_handle_(0),
- request_id_(0) {
+ query_id_(0) {
form_autofill_enabled_.Init(prefs::kFormAutofillEnabled,
profile()->GetPrefs(), NULL);
}
@@ -55,9 +55,9 @@ void AutofillManager::AutofillFormSubmitted(
StoreFormEntriesInWebDatabase(form);
}
-bool AutofillManager::GetAutofillSuggestions(int request_id,
- const std::wstring& name,
- const std::wstring& prefix) {
+bool AutofillManager::GetAutofillSuggestions(int query_id,
+ const string16& name,
+ const string16& prefix) {
if (!*form_autofill_enabled_)
return false;
@@ -70,15 +70,15 @@ bool AutofillManager::GetAutofillSuggestions(int request_id,
CancelPendingQuery();
- request_id_ = request_id;
+ query_id_ = query_id;
pending_query_handle_ = web_data_service->GetFormValuesForElementName(
name, prefix, kMaxAutofillMenuItems, this);
return true;
}
-void AutofillManager::RemoveAutofillEntry(const std::wstring& name,
- const std::wstring& value) {
+void AutofillManager::RemoveAutofillEntry(const string16& name,
+ const string16& value) {
WebDataService* web_data_service =
profile()->GetWebDataService(Profile::EXPLICIT_ACCESS);
if (!web_data_service) {
@@ -120,12 +120,12 @@ void AutofillManager::SendSuggestions(const WDTypedResult* result) {
return;
if (result) {
DCHECK(result->GetType() == AUTOFILL_VALUE_RESULT);
- const WDResult<std::vector<std::wstring> >* autofill_result =
- static_cast<const WDResult<std::vector<std::wstring> >*>(result);
+ const WDResult<std::vector<string16> >* autofill_result =
+ static_cast<const WDResult<std::vector<string16> >*>(result);
host->AutofillSuggestionsReturned(
- request_id_, autofill_result->GetValue(), -1);
+ query_id_, autofill_result->GetValue(), -1);
} else {
host->AutofillSuggestionsReturned(
- request_id_, std::vector<std::wstring>(), -1);
+ query_id_, std::vector<string16>(), -1);
}
}
diff --git a/chrome/browser/autofill_manager.h b/chrome/browser/autofill_manager.h
index acea4d7..66d21e2 100644
--- a/chrome/browser/autofill_manager.h
+++ b/chrome/browser/autofill_manager.h
@@ -30,11 +30,11 @@ class AutofillManager : public RenderViewHostDelegate::Autofill,
// RenderViewHostDelegate::Autofill implementation.
virtual void AutofillFormSubmitted(const webkit_glue::AutofillForm& form);
- virtual bool GetAutofillSuggestions(int request_id,
- const std::wstring& name,
- const std::wstring& prefix);
- virtual void RemoveAutofillEntry(const std::wstring& name,
- const std::wstring& value);
+ virtual bool GetAutofillSuggestions(int query_id,
+ const string16& name,
+ const string16& prefix);
+ virtual void RemoveAutofillEntry(const string16& name,
+ const string16& value);
// WebDataServiceConsumer implementation.
virtual void OnWebDataServiceRequestDone(WebDataService::Handle h,
@@ -55,7 +55,7 @@ class AutofillManager : public RenderViewHostDelegate::Autofill,
// is queried on another thread, we record the query handle until we
// get called back.
WebDataService::Handle pending_query_handle_;
- int request_id_;
+ int query_id_;
DISALLOW_COPY_AND_ASSIGN(AutofillManager);
};
diff --git a/chrome/browser/renderer_host/render_view_host.cc b/chrome/browser/renderer_host/render_view_host.cc
index ceea01b..5ebe328 100644
--- a/chrome/browser/renderer_host/render_view_host.cc
+++ b/chrome/browser/renderer_host/render_view_host.cc
@@ -1541,22 +1541,22 @@ void RenderViewHost::OnMsgShouldCloseACK(bool proceed) {
}
}
-void RenderViewHost::OnQueryFormFieldAutofill(int request_id,
- const std::wstring& field_name,
- const std::wstring& user_text) {
+void RenderViewHost::OnQueryFormFieldAutofill(int query_id,
+ const string16& field_name,
+ const string16& user_text) {
RenderViewHostDelegate::Autofill* autofill_delegate =
delegate_->GetAutofillDelegate();
bool ok = false;
if (autofill_delegate) {
ok = autofill_delegate->GetAutofillSuggestions(
- request_id, field_name, user_text);
+ query_id, field_name, user_text);
}
if (!ok)
- AutofillSuggestionsReturned(request_id, std::vector<std::wstring>(), 0);
+ AutofillSuggestionsReturned(query_id, std::vector<string16>(), -1);
}
-void RenderViewHost::OnRemoveAutofillEntry(const std::wstring& field_name,
- const std::wstring& value) {
+void RenderViewHost::OnRemoveAutofillEntry(const string16& field_name,
+ const string16& value) {
RenderViewHostDelegate::Autofill* autofill_delegate =
delegate_->GetAutofillDelegate();
if (autofill_delegate)
@@ -1564,10 +1564,10 @@ void RenderViewHost::OnRemoveAutofillEntry(const std::wstring& field_name,
}
void RenderViewHost::AutofillSuggestionsReturned(
- int request_id, const std::vector<std::wstring>& suggestions,
+ int query_id, const std::vector<string16>& suggestions,
int default_suggestion_index) {
Send(new ViewMsg_QueryFormFieldAutofill_ACK(
- routing_id(), request_id, suggestions, -1));
+ routing_id(), query_id, suggestions, -1));
// Default index -1 means no default suggestion.
}
diff --git a/chrome/browser/renderer_host/render_view_host.h b/chrome/browser/renderer_host/render_view_host.h
index 218bedc..acb1833 100644
--- a/chrome/browser/renderer_host/render_view_host.h
+++ b/chrome/browser/renderer_host/render_view_host.h
@@ -394,8 +394,8 @@ class RenderViewHost : public RenderWidgetHost,
void PopupNotificationVisibilityChanged(bool visible);
// Called by the AutofillManager when the list of suggestions is ready.
- void AutofillSuggestionsReturned(int request_id,
- const std::vector<std::wstring>& suggestions,
+ void AutofillSuggestionsReturned(int query_id,
+ const std::vector<string16>& suggestions,
int default_suggestion_index);
// Notifies the Renderer that a move or resize of its containing window has
@@ -571,10 +571,10 @@ class RenderViewHost : public RenderWidgetHost,
const webkit_glue::WebApplicationInfo& info);
void OnMsgShouldCloseACK(bool proceed);
void OnQueryFormFieldAutofill(int request_id,
- const std::wstring& field_name,
- const std::wstring& user_text);
- void OnRemoveAutofillEntry(const std::wstring& field_name,
- const std::wstring& value);
+ const string16& field_name,
+ const string16& user_text);
+ void OnRemoveAutofillEntry(const string16& field_name,
+ const string16& value);
void OnShowDesktopNotification(const GURL& source_origin,
const GURL& url, int notification_id);
diff --git a/chrome/browser/renderer_host/render_view_host_delegate.h b/chrome/browser/renderer_host/render_view_host_delegate.h
index c8da418..cb1d008 100644
--- a/chrome/browser/renderer_host/render_view_host_delegate.h
+++ b/chrome/browser/renderer_host/render_view_host_delegate.h
@@ -353,14 +353,14 @@ class RenderViewHostDelegate {
// retrieves the calling RenderViewHost and then passes the vector of
// suggestions to RenderViewHost::AutofillSuggestionsReturned.
// Return true to indicate that AutofillSuggestionsReturned will be called.
- virtual bool GetAutofillSuggestions(int request_id,
- const std::wstring& field_name,
- const std::wstring& user_text) = 0;
+ virtual bool GetAutofillSuggestions(int query_id,
+ const string16& field_name,
+ const string16& user_text) = 0;
// Called when the user has indicated that she wants to remove the specified
// autofill suggestion from the database.
- virtual void RemoveAutofillEntry(const std::wstring& field_name,
- const std::wstring& value) = 0;
+ virtual void RemoveAutofillEntry(const string16& field_name,
+ const string16& value) = 0;
};
// ---------------------------------------------------------------------------
diff --git a/chrome/browser/webdata/web_data_service.cc b/chrome/browser/webdata/web_data_service.cc
index d7f3682..cec4e99 100644
--- a/chrome/browser/webdata/web_data_service.cc
+++ b/chrome/browser/webdata/web_data_service.cc
@@ -126,7 +126,7 @@ void WebDataService::AddAutofillFormElements(
}
WebDataService::Handle WebDataService::GetFormValuesForElementName(
- const std::wstring& name, const std::wstring& prefix, int limit,
+ const string16& name, const string16& prefix, int limit,
WebDataServiceConsumer* consumer) {
WebDataRequest* request =
new WebDataRequest(this, GetNextRequestHandle(), consumer);
@@ -142,12 +142,12 @@ WebDataService::Handle WebDataService::GetFormValuesForElementName(
}
void WebDataService::RemoveFormValueForElementName(
- const std::wstring& name, const std::wstring& value) {
- GenericRequest2<std::wstring, std::wstring>* request =
- new GenericRequest2<std::wstring, std::wstring>(this,
- GetNextRequestHandle(),
- NULL,
- name, value);
+ const string16& name, const string16& value) {
+ GenericRequest2<string16, string16>* request =
+ new GenericRequest2<string16, string16>(this,
+ GetNextRequestHandle(),
+ NULL,
+ name, value);
RegisterRequest(request);
ScheduleTask(
NewRunnableMethod(this,
@@ -582,12 +582,12 @@ void WebDataService::AddAutofillFormElementsImpl(
}
void WebDataService::GetFormValuesForElementNameImpl(WebDataRequest* request,
- const std::wstring& name, const std::wstring& prefix, int limit) {
+ const string16& name, const string16& prefix, int limit) {
if (db_ && !request->IsCancelled()) {
- std::vector<std::wstring> values;
+ std::vector<string16> values;
db_->GetFormValuesForElementName(name, prefix, &values, limit);
request->SetResult(
- new WDResult<std::vector<std::wstring> >(AUTOFILL_VALUE_RESULT,
+ new WDResult<std::vector<string16> >(AUTOFILL_VALUE_RESULT,
values));
}
request->RequestComplete();
@@ -604,7 +604,7 @@ void WebDataService::RemoveFormElementsAddedBetweenImpl(
}
void WebDataService::RemoveFormValueForElementNameImpl(
- GenericRequest2<std::wstring, std::wstring>* request) {
+ GenericRequest2<string16, string16>* request) {
if (db_ && !request->IsCancelled()) {
if (db_->RemoveFormElement(request->GetArgument1(),
request->GetArgument2()))
diff --git a/chrome/browser/webdata/web_data_service.h b/chrome/browser/webdata/web_data_service.h
index f15911b..03b7766 100644
--- a/chrome/browser/webdata/web_data_service.h
+++ b/chrome/browser/webdata/web_data_service.h
@@ -57,7 +57,7 @@ typedef enum {
PASSWORD_IE7_RESULT, // WDResult<IE7PasswordInfo>
#endif
WEB_APP_IMAGES, // WDResult<WDAppImagesResult>
- AUTOFILL_VALUE_RESULT, // WDResult<std::vector<std::wstring>>
+ AUTOFILL_VALUE_RESULT, // WDResult<std::vector<string16>>
} WDResultType;
// Result from GetWebAppImages.
@@ -382,16 +382,16 @@ class WebDataService : public base::RefCountedThreadSafe<WebDataService> {
// form input fields named |name|. The method OnWebDataServiceRequestDone of
// |consumer| gets called back when the request is finished, with the vector
// included in the argument |result|.
- Handle GetFormValuesForElementName(const std::wstring& name,
- const std::wstring& prefix,
+ Handle GetFormValuesForElementName(const string16& name,
+ const string16& prefix,
int limit,
WebDataServiceConsumer* consumer);
// Removes form elements recorded for autofill from the database.
void RemoveFormElementsAddedBetween(const base::Time& delete_begin,
const base::Time& delete_end);
- void RemoveFormValueForElementName(const std::wstring& name,
- const std::wstring& value);
+ void RemoveFormValueForElementName(const string16& name,
+ const string16& value);
protected:
friend class TemplateURLModelTest;
@@ -468,11 +468,11 @@ class WebDataService : public base::RefCountedThreadSafe<WebDataService> {
GenericRequest<std::vector<webkit_glue::AutofillForm::Element> >*
request);
void GetFormValuesForElementNameImpl(WebDataRequest* request,
- const std::wstring& name, const std::wstring& prefix, int limit);
+ const string16& name, const string16& prefix, int limit);
void RemoveFormElementsAddedBetweenImpl(
GenericRequest2<base::Time, base::Time>* request);
void RemoveFormValueForElementNameImpl(
- GenericRequest2<std::wstring, std::wstring>* request);
+ GenericRequest2<string16, string16>* request);
//////////////////////////////////////////////////////////////////////////////
//
diff --git a/chrome/browser/webdata/web_database.cc b/chrome/browser/webdata/web_database.cc
index 98bc76c..a1ba12d 100644
--- a/chrome/browser/webdata/web_database.cc
+++ b/chrome/browser/webdata/web_database.cc
@@ -850,8 +850,8 @@ bool WebDatabase::GetIDAndCountOfFormElement(
return false;
}
- s.BindString(0, WideToUTF8(element.name));
- s.BindString(1, WideToUTF8(element.value));
+ s.BindString(0, UTF16ToUTF8(element.name));
+ s.BindString(1, UTF16ToUTF8(element.value));
*count = 0;
@@ -889,10 +889,9 @@ bool WebDatabase::InsertFormElement(const AutofillForm::Element& element,
return false;
}
- s.BindString(0, WideToUTF8(element.name));
- s.BindString(1, WideToUTF8(element.value));
- s.BindString(2, UTF16ToUTF8(
- l10n_util::ToLower(WideToUTF16Hack(element.value))));
+ s.BindString(0, UTF16ToUTF8(element.name));
+ s.BindString(1, UTF16ToUTF8(element.value));
+ s.BindString(2, UTF16ToUTF8(l10n_util::ToLower(element.value)));
if (!s.Run()) {
NOTREACHED();
@@ -956,9 +955,9 @@ bool WebDatabase::AddAutofillFormElement(const AutofillForm::Element& element) {
InsertPairIDAndDate(pair_id, Time::Now());
}
-bool WebDatabase::GetFormValuesForElementName(const std::wstring& name,
- const std::wstring& prefix,
- std::vector<std::wstring>* values,
+bool WebDatabase::GetFormValuesForElementName(const string16& name,
+ const string16& prefix,
+ std::vector<string16>* values,
int limit) {
DCHECK(values);
sql::Statement s;
@@ -974,10 +973,10 @@ bool WebDatabase::GetFormValuesForElementName(const std::wstring& name,
return false;
}
- s.BindString(0, WideToUTF8(name));
+ s.BindString(0, UTF16ToUTF8(name));
s.BindInt(1, limit);
} else {
- string16 prefix_lower = l10n_util::ToLower(WideToUTF16Hack(prefix));
+ string16 prefix_lower = l10n_util::ToLower(prefix);
string16 next_prefix = prefix_lower;
next_prefix[next_prefix.length() - 1]++;
@@ -993,7 +992,7 @@ bool WebDatabase::GetFormValuesForElementName(const std::wstring& name,
return false;
}
- s.BindString(0, WideToUTF8(name));
+ s.BindString(0, UTF16ToUTF8(name));
s.BindString(1, UTF16ToUTF8(prefix_lower));
s.BindString(2, UTF16ToUTF8(next_prefix));
s.BindInt(3, limit);
@@ -1001,7 +1000,7 @@ bool WebDatabase::GetFormValuesForElementName(const std::wstring& name,
values->clear();
while (s.Step())
- values->push_back(UTF8ToWide(s.ColumnString(0)));
+ values->push_back(UTF8ToUTF16(s.ColumnString(0)));
return s.Succeeded();
}
@@ -1067,8 +1066,8 @@ bool WebDatabase::RemoveFormElementForTimeRange(int64 pair_id,
return result;
}
-bool WebDatabase::RemoveFormElement(const std::wstring& name,
- const std::wstring& value) {
+bool WebDatabase::RemoveFormElement(const string16& name,
+ const string16& value) {
// Find the id for that pair.
sql::Statement s(db_.GetUniqueStatement(
"SELECT pair_id FROM autofill WHERE name = ? AND value= ?"));
@@ -1076,8 +1075,8 @@ bool WebDatabase::RemoveFormElement(const std::wstring& name,
NOTREACHED() << "Statement 1 prepare failed";
return false;
}
- s.BindString(0, WideToUTF8(name));
- s.BindString(1, WideToUTF8(value));
+ s.BindString(0, UTF16ToUTF8(name));
+ s.BindString(1, UTF16ToUTF8(value));
if (s.Step())
return RemoveFormElementForID(s.ColumnInt64(0));
diff --git a/chrome/browser/webdata/web_database.h b/chrome/browser/webdata/web_database.h
index acc8fbf..1326c18 100644
--- a/chrome/browser/webdata/web_database.h
+++ b/chrome/browser/webdata/web_database.h
@@ -142,9 +142,9 @@ class WebDatabase {
// Retrieves a vector of all values which have been recorded in the autofill
// table as the value in a form element with name |name| and which start with
// |prefix|. The comparison of the prefix is case insensitive.
- bool GetFormValuesForElementName(const std::wstring& name,
- const std::wstring& prefix,
- std::vector<std::wstring>* values,
+ bool GetFormValuesForElementName(const string16& name,
+ const string16& prefix,
+ std::vector<string16>* values,
int limit);
// Removes rows from autofill_dates if they were created on or after
@@ -191,7 +191,7 @@ class WebDatabase {
bool RemoveFormElementForID(int64 pair_id);
// Removes row from the autofill tables for the given |name| |value| pair.
- bool RemoveFormElement(const std::wstring& name, const std::wstring& value);
+ bool RemoveFormElement(const string16& name, const string16& value);
//////////////////////////////////////////////////////////////////////////////
//
diff --git a/chrome/browser/webdata/web_database_unittest.cc b/chrome/browser/webdata/web_database_unittest.cc
index 68d56d8..fcfee84 100644
--- a/chrome/browser/webdata/web_database_unittest.cc
+++ b/chrome/browser/webdata/web_database_unittest.cc
@@ -392,19 +392,22 @@ TEST_F(WebDatabaseTest, Autofill) {
// Simulate the submission of a handful of entries in a field called "Name",
// some more often than others.
EXPECT_TRUE(db.AddAutofillFormElement(
- AutofillForm::Element(L"Name", L"Superman")));
- std::vector<std::wstring> v;
+ AutofillForm::Element(ASCIIToUTF16("Name"), ASCIIToUTF16("Superman"))));
+ std::vector<string16> v;
for (int i = 0; i < 5; i++) {
EXPECT_TRUE(db.AddAutofillFormElement(
- AutofillForm::Element(L"Name", L"Clark Kent")));
+ AutofillForm::Element(ASCIIToUTF16("Name"),
+ ASCIIToUTF16("Clark Kent"))));
}
for (int i = 0; i < 3; i++) {
EXPECT_TRUE(db.AddAutofillFormElement(
- AutofillForm::Element(L"Name", L"Clark Sutter")));
+ AutofillForm::Element(ASCIIToUTF16("Name"),
+ ASCIIToUTF16("Clark Sutter"))));
}
for (int i = 0; i < 2; i++) {
EXPECT_TRUE(db.AddAutofillFormElement(
- AutofillForm::Element(L"Favorite Color", L"Green")));
+ AutofillForm::Element(ASCIIToUTF16("Favorite Color"),
+ ASCIIToUTF16("Green"))));
}
int count = 0;
@@ -413,47 +416,54 @@ TEST_F(WebDatabaseTest, Autofill) {
// We have added the name Clark Kent 5 times, so count should be 5 and pair_id
// should be somthing non-zero.
EXPECT_TRUE(db.GetIDAndCountOfFormElement(
- AutofillForm::Element(L"Name", L"Clark Kent"), &pair_id, &count));
+ AutofillForm::Element(ASCIIToUTF16("Name"), ASCIIToUTF16("Clark Kent")),
+ &pair_id, &count));
EXPECT_EQ(5, count);
EXPECT_NE(0, pair_id);
// Storing in the data base should be case sensitive, so there should be no
// database entry for clark kent lowercase.
EXPECT_TRUE(db.GetIDAndCountOfFormElement(
- AutofillForm::Element(L"Name", L"clark kent"), &pair_id, &count));
+ AutofillForm::Element(ASCIIToUTF16("Name"), ASCIIToUTF16("clark kent")),
+ &pair_id, &count));
EXPECT_EQ(0, count);
EXPECT_TRUE(db.GetIDAndCountOfFormElement(
- AutofillForm::Element(L"Favorite Color", L"Green"), &pair_id, &count));
+ AutofillForm::Element(ASCIIToUTF16("Favorite Color"),
+ ASCIIToUTF16("Green")),
+ &pair_id, &count));
EXPECT_EQ(2, count);
// This is meant to get a list of suggestions for Name. The empty prefix
// in the second argument means it should return all suggestions for a name
// no matter what they start with. The order that the names occur in the list
// should be decreasing order by count.
- EXPECT_TRUE(db.GetFormValuesForElementName(L"Name", std::wstring(), &v, 6));
+ EXPECT_TRUE(db.GetFormValuesForElementName(
+ ASCIIToUTF16("Name"), string16(), &v, 6));
EXPECT_EQ(3U, v.size());
if (v.size() == 3) {
- EXPECT_EQ(L"Clark Kent", v[0]);
- EXPECT_EQ(L"Clark Sutter", v[1]);
- EXPECT_EQ(L"Superman", v[2]);
+ EXPECT_EQ(ASCIIToUTF16("Clark Kent"), v[0]);
+ EXPECT_EQ(ASCIIToUTF16("Clark Sutter"), v[1]);
+ EXPECT_EQ(ASCIIToUTF16("Superman"), v[2]);
}
// If we query again limiting the list size to 1, we should only get the most
// frequent entry.
- EXPECT_TRUE(db.GetFormValuesForElementName(L"Name", L"", &v, 1));
+ EXPECT_TRUE(db.GetFormValuesForElementName(
+ ASCIIToUTF16("Name"), string16(), &v, 1));
EXPECT_EQ(1U, v.size());
if (v.size() == 1) {
- EXPECT_EQ(L"Clark Kent", v[0]);
+ EXPECT_EQ(ASCIIToUTF16("Clark Kent"), v[0]);
}
// Querying for suggestions given a prefix is case-insensitive, so the prefix
// "cLa" shoud get suggestions for both Clarks.
- EXPECT_TRUE(db.GetFormValuesForElementName(L"Name", L"cLa", &v, 6));
+ EXPECT_TRUE(db.GetFormValuesForElementName(
+ ASCIIToUTF16("Name"), ASCIIToUTF16("cLa"), &v, 6));
EXPECT_EQ(2U, v.size());
if (v.size() == 2) {
- EXPECT_EQ(L"Clark Kent", v[0]);
- EXPECT_EQ(L"Clark Sutter", v[1]);
+ EXPECT_EQ(ASCIIToUTF16("Clark Kent"), v[0]);
+ EXPECT_EQ(ASCIIToUTF16("Clark Sutter"), v[1]);
}
// Removing all elements since the beginning of this function should remove
@@ -461,33 +471,37 @@ TEST_F(WebDatabaseTest, Autofill) {
EXPECT_TRUE(db.RemoveFormElementsAddedBetween(t1, Time()));
EXPECT_TRUE(db.GetIDAndCountOfFormElement(
- AutofillForm::Element(L"Name", L"Clark Kent"), &pair_id, &count));
+ AutofillForm::Element(ASCIIToUTF16("Name"), ASCIIToUTF16("Clark Kent")),
+ &pair_id, &count));
EXPECT_EQ(0, count);
- EXPECT_TRUE(db.GetFormValuesForElementName(L"Name", L"", &v, 6));
+ EXPECT_TRUE(
+ db.GetFormValuesForElementName(ASCIIToUTF16("Name"), string16(), &v, 6));
EXPECT_EQ(0U, v.size());
// Now add some values with empty strings.
- const std::wstring kValue = L" toto ";
- EXPECT_TRUE(db.AddAutofillFormElement(AutofillForm::Element(L"blank", L"")));
- EXPECT_TRUE(db.AddAutofillFormElement(AutofillForm::Element(L"blank",
- L" ")));
- EXPECT_TRUE(db.AddAutofillFormElement(AutofillForm::Element(L"blank",
- L" ")));
- EXPECT_TRUE(db.AddAutofillFormElement(AutofillForm::Element(L"blank",
- kValue)));
+ const string16 kValue = ASCIIToUTF16(" toto ");
+ EXPECT_TRUE(db.AddAutofillFormElement(
+ AutofillForm::Element(ASCIIToUTF16("blank"), string16())));
+ EXPECT_TRUE(db.AddAutofillFormElement(
+ AutofillForm::Element(ASCIIToUTF16("blank"), ASCIIToUTF16(" "))));
+ EXPECT_TRUE(db.AddAutofillFormElement(
+ AutofillForm::Element(ASCIIToUTF16("blank"), ASCIIToUTF16(" "))));
+ EXPECT_TRUE(db.AddAutofillFormElement(
+ AutofillForm::Element(ASCIIToUTF16("blank"), kValue)));
// They should be stored normally as the DB layer does not check for empty
// values.
v.clear();
- EXPECT_TRUE(db.GetFormValuesForElementName(L"blank", L"", &v, 10));
+ EXPECT_TRUE(db.GetFormValuesForElementName(
+ ASCIIToUTF16("blank"), string16(), &v, 10));
EXPECT_EQ(4U, v.size());
// Now we'll check that ClearAutofillEmptyValueElements() works as expected.
db.ClearAutofillEmptyValueElements();
v.clear();
- EXPECT_TRUE(db.GetFormValuesForElementName(L"blank", L"", &v, 10));
+ EXPECT_TRUE(db.GetFormValuesForElementName(ASCIIToUTF16("blank"), string16(), &v, 10));
ASSERT_EQ(1U, v.size());
EXPECT_EQ(kValue, v[0]);
diff --git a/chrome/common/render_messages_internal.h b/chrome/common/render_messages_internal.h
index fd2ab49..7408ab8 100644
--- a/chrome/common/render_messages_internal.h
+++ b/chrome/common/render_messages_internal.h
@@ -593,7 +593,7 @@ IPC_BEGIN_MESSAGES(View)
// suggestions.
IPC_MESSAGE_ROUTED3(ViewMsg_QueryFormFieldAutofill_ACK,
int /* id of the request message */,
- std::vector<std::wstring> /* suggestions */,
+ std::vector<string16> /* suggestions */,
int /* index of default suggestion */)
// Sent by the Browser process to alert a window about whether a blocked
@@ -1604,14 +1604,14 @@ IPC_BEGIN_MESSAGES(ViewHost)
// Queries the browser for suggestion for autofill in a form input field.
IPC_MESSAGE_ROUTED3(ViewHostMsg_QueryFormFieldAutofill,
int /* id of this message */,
- std::wstring /* field name */,
- std::wstring /* user entered text */)
+ string16 /* field name */,
+ string16 /* user entered text */)
// Instructs the browser to remove the specified autofill-entry from the
// database.
IPC_MESSAGE_ROUTED2(ViewHostMsg_RemoveAutofillEntry,
- std::wstring /* field name */,
- std::wstring /* value */)
+ string16 /* field name */,
+ string16 /* value */)
// Get the list of proxies to use for |url|, as a semicolon delimited list
// of "<TYPE> <HOST>:<PORT>" | "DIRECT". See also
diff --git a/chrome/renderer/print_web_view_helper.h b/chrome/renderer/print_web_view_helper.h
index fee75f8..80b309f 100644
--- a/chrome/renderer/print_web_view_helper.h
+++ b/chrome/renderer/print_web_view_helper.h
@@ -205,13 +205,19 @@ class PrintWebViewHelper : public WebViewDelegate {
virtual int historyBackListCount() { return 0; }
virtual int historyForwardListCount() { return 0; }
virtual void didAddHistoryItem() {}
- virtual void didUpdateInspectorSettings() {}
virtual void focusAccessibilityObject(
const WebKit::WebAccessibilityObject& object) {}
+ virtual void didUpdateInspectorSettings() {}
+ virtual void queryAutofillSuggestions(
+ const WebKit::WebNode& node, const WebKit::WebString& name,
+ const WebKit::WebString& value) {}
+ virtual void removeAutofillSuggestions(
+ const WebKit::WebString& name, const WebKit::WebString& value) {}
// WebKit::WebWidgetClient
virtual void didInvalidateRect(const WebKit::WebRect&) {}
- virtual void didScrollRect(int dx, int dy, const WebKit::WebRect& clipRect) {}
+ virtual void didScrollRect(
+ int dx, int dy, const WebKit::WebRect& clipRect) {}
virtual void didFocus() {}
virtual void didBlur() {}
virtual void didChangeCursor(const WebKit::WebCursorInfo&) {}
diff --git a/chrome/renderer/render_view.cc b/chrome/renderer/render_view.cc
index 5691a84..734605a 100644
--- a/chrome/renderer/render_view.cc
+++ b/chrome/renderer/render_view.cc
@@ -223,8 +223,7 @@ RenderView::RenderView(RenderThreadBase* render_thread,
history_forward_list_count_(0),
has_unload_listener_(false),
decrement_shared_popup_at_destruction_(false),
- form_field_autofill_request_id_(0),
- form_field_autofill_node_id_(0),
+ autofill_query_id_(0),
popup_notification_visible_(false),
spelling_panel_visible_(false),
delay_seconds_for_form_state_sync_(kDefaultDelaySecondsForFormStateSync),
@@ -1233,30 +1232,15 @@ void RenderView::AddGURLSearchProvider(const GURL& osd_url, bool autodetected) {
autodetected));
}
-void RenderView::QueryFormFieldAutofill(const std::wstring& field_name,
- const std::wstring& text,
- int64 node_id) {
- static int message_id_counter = 0;
- form_field_autofill_request_id_ = message_id_counter++;
- form_field_autofill_node_id_ = node_id;
- Send(new ViewHostMsg_QueryFormFieldAutofill(
- routing_id_, form_field_autofill_request_id_, field_name, text));
-}
-
-void RenderView::RemoveStoredAutofillEntry(const std::wstring& name,
- const std::wstring& value) {
- Send(new ViewHostMsg_RemoveAutofillEntry(routing_id_, name, value));
-}
-
void RenderView::OnQueryFormFieldAutofillAck(
- int request_id,
- const std::vector<std::wstring>& suggestions,
+ int query_id,
+ const std::vector<string16>& suggestions,
int default_suggestion_index) {
- if (!webview() || request_id != form_field_autofill_request_id_)
- return;
-
- webview()->AutofillSuggestionsForNode(
- form_field_autofill_node_id_, suggestions, default_suggestion_index);
+ if (webview() && query_id == autofill_query_id_ && !suggestions.empty()) {
+ webview()->applyAutofillSuggestions(
+ autofill_query_node_, suggestions, default_suggestion_index);
+ }
+ autofill_query_node_.reset();
}
void RenderView::OnPopupNotificationVisibilityChanged(bool visible) {
@@ -1716,6 +1700,21 @@ void RenderView::didUpdateInspectorSettings() {
routing_id_, webview()->inspectorSettings().utf8()));
}
+void RenderView::queryAutofillSuggestions(const WebNode& node,
+ const WebString& name,
+ const WebString& value) {
+ static int query_counter = 0;
+ autofill_query_id_ = query_counter++;
+ autofill_query_node_ = node;
+ Send(new ViewHostMsg_QueryFormFieldAutofill(
+ routing_id_, autofill_query_id_, name, value));
+}
+
+void RenderView::removeAutofillSuggestions(const WebString& name,
+ const WebString& value) {
+ Send(new ViewHostMsg_RemoveAutofillEntry(routing_id_, name, value));
+}
+
// WebKit::WebWidgetClient ----------------------------------------------------
// We are supposed to get a single call to Show for a newly created RenderView
@@ -3286,13 +3285,13 @@ void RenderView::AltErrorPageFinished(WebFrame* frame,
void RenderView::OnMoveOrResizeStarted() {
if (webview())
- webview()->HideAutofillPopup();
+ webview()->hideAutofillPopup();
}
void RenderView::OnResize(const gfx::Size& new_size,
const gfx::Rect& resizer_rect) {
if (webview())
- webview()->HideAutofillPopup();
+ webview()->hideAutofillPopup();
RenderWidget::OnResize(new_size, resizer_rect);
}
diff --git a/chrome/renderer/render_view.h b/chrome/renderer/render_view.h
index 16b4fe0..f100778 100644
--- a/chrome/renderer/render_view.h
+++ b/chrome/renderer/render_view.h
@@ -38,6 +38,7 @@
#include "webkit/api/public/WebConsoleMessage.h"
#include "webkit/api/public/WebContextMenuData.h"
#include "webkit/api/public/WebFrameClient.h"
+#include "webkit/api/public/WebNode.h"
#include "webkit/api/public/WebTextDirection.h"
#include "webkit/glue/dom_serializer_delegate.h"
#include "webkit/glue/form_data.h"
@@ -164,11 +165,6 @@ class RenderView : public RenderWidget,
virtual void OnMessageReceived(const IPC::Message& msg);
// WebViewDelegate
- virtual void QueryFormFieldAutofill(const std::wstring& field_name,
- const std::wstring& text,
- int64 node_id);
- virtual void RemoveStoredAutofillEntry(const std::wstring& field_name,
- const std::wstring& text);
virtual void LoadNavigationErrorPage(
WebKit::WebFrame* frame,
const WebKit::WebURLRequest& failed_request,
@@ -258,9 +254,14 @@ class RenderView : public RenderWidget,
virtual int historyBackListCount();
virtual int historyForwardListCount();
virtual void didAddHistoryItem();
- virtual void didUpdateInspectorSettings();
virtual void focusAccessibilityObject(
const WebKit::WebAccessibilityObject& acc_obj);
+ virtual void didUpdateInspectorSettings();
+ virtual void queryAutofillSuggestions(
+ const WebKit::WebNode& node, const WebKit::WebString& name,
+ const WebKit::WebString& value);
+ virtual void removeAutofillSuggestions(
+ const WebKit::WebString& name, const WebKit::WebString& value);
virtual WebKit::WebNotificationPresenter* GetNotificationPresenter() {
return notification_provider_.get();
@@ -636,8 +637,8 @@ class RenderView : public RenderWidget,
// Notification that we have received autofill suggestion.
void OnQueryFormFieldAutofillAck(
- int request_id,
- const std::vector<std::wstring>& suggestions,
+ int query_id,
+ const std::vector<string16>& suggestions,
int default_suggestions_index);
// Message that the popup notification has been shown or hidden.
@@ -871,11 +872,11 @@ class RenderView : public RenderWidget,
// The id of the last request sent for form field autofill. Used to ignore
// out of date responses.
- int form_field_autofill_request_id_;
+ int autofill_query_id_;
// The id of the node corresponding to the last request sent for form field
// autofill.
- int64 form_field_autofill_node_id_;
+ WebKit::WebNode autofill_query_node_;
// We need to prevent windows from closing themselves with a window.close()
// call while a blocked popup notification is being displayed. We cannot
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);