summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authordarin@chromium.org <darin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-10-16 03:53:39 +0000
committerdarin@chromium.org <darin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-10-16 03:53:39 +0000
commitacca2a1fc734142de039f65405ef259737d7a8fc (patch)
tree6275718b90618e1445cb824e615aeca7c21e6956 /chrome
parent923bd8b63206d79cdfb0e5eba5b49e5a6f7eee7d (diff)
downloadchromium_src-acca2a1fc734142de039f65405ef259737d7a8fc.zip
chromium_src-acca2a1fc734142de039f65405ef259737d7a8fc.tar.gz
chromium_src-acca2a1fc734142de039f65405ef259737d7a8fc.tar.bz2
Move autofill related WebView{Delegate} methods into the WebKit API.
This CL also changes a bunch of autofill related wstring values to string16. R=jcampan BUG=24595 TEST=none Review URL: http://codereview.chromium.org/279001 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@29244 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-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
14 files changed, 167 insertions, 148 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