summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjhawkins@chromium.org <jhawkins@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-02-18 01:29:24 +0000
committerjhawkins@chromium.org <jhawkins@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-02-18 01:29:24 +0000
commit95056b58863ba1fc6716ef796bb847cca8919188 (patch)
tree5440761639aa7031810c7be5a817857ac596d02f
parentf5c895f2e6660df9756fec85584bf85b598186f5 (diff)
downloadchromium_src-95056b58863ba1fc6716ef796bb847cca8919188.zip
chromium_src-95056b58863ba1fc6716ef796bb847cca8919188.tar.gz
chromium_src-95056b58863ba1fc6716ef796bb847cca8919188.tar.bz2
Send suggestions from the AutoFillManager to the AutoFillSuggestionsPopup in WebKit.
BUG=18201 TEST=none Review URL: http://codereview.chromium.org/627005 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@39310 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/autofill/autofill_manager.cc74
-rw-r--r--chrome/browser/autofill/autofill_manager.h3
-rw-r--r--chrome/browser/renderer_host/render_view_host.cc39
-rw-r--r--chrome/browser/renderer_host/render_view_host.h11
-rw-r--r--chrome/browser/renderer_host/render_view_host_delegate.h10
-rw-r--r--chrome/common/render_messages.h67
-rw-r--r--chrome/common/render_messages_internal.h38
-rw-r--r--chrome/renderer/render_view.cc31
-rw-r--r--chrome/renderer/render_view.h12
-rw-r--r--webkit/glue/form_field.cc9
-rw-r--r--webkit/glue/form_field.h10
11 files changed, 249 insertions, 55 deletions
diff --git a/chrome/browser/autofill/autofill_manager.cc b/chrome/browser/autofill/autofill_manager.cc
index bf0857d..33f7dcb0 100644
--- a/chrome/browser/autofill/autofill_manager.cc
+++ b/chrome/browser/autofill/autofill_manager.cc
@@ -11,10 +11,12 @@
#include "chrome/browser/autofill/autofill_infobar_delegate.h"
#include "chrome/browser/autofill/form_structure.h"
#include "chrome/browser/profile.h"
+#include "chrome/browser/renderer_host/render_view_host.h"
#include "chrome/browser/tab_contents/tab_contents.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/pref_names.h"
#include "chrome/common/pref_service.h"
+#include "webkit/glue/form_field.h"
#include "webkit/glue/form_field_values.h"
AutoFillManager::AutoFillManager(TabContents* tab_contents)
@@ -73,6 +75,78 @@ void AutoFillManager::FormsSeen(
}
}
+bool AutoFillManager::GetAutoFillSuggestions(
+ int query_id, const webkit_glue::FormField& field) {
+ // TODO(jhawkins): Use the autofill preference.
+ if (!CommandLine::ForCurrentProcess()->HasSwitch(
+ switches::kEnableNewAutoFill))
+ return false;
+
+ RenderViewHost* host = tab_contents_->render_view_host();
+ if (!host)
+ return false;
+
+ const std::vector<AutoFillProfile*>& profiles = personal_data_->profiles();
+ if (profiles.empty())
+ return false;
+
+ AutoFillFieldType type = UNKNOWN_TYPE;
+ for (std::vector<FormStructure*>::iterator form = form_structures_.begin();
+ form != form_structures_.end(); ++form) {
+ for (std::vector<AutoFillField*>::const_iterator iter = (*form)->begin();
+ iter != (*form)->end(); ++iter) {
+ // The field list is terminated with a NULL AutoFillField, so don't try to
+ // dereference it.
+ if (!*iter)
+ break;
+
+ AutoFillField* form_field = *iter;
+ if (*form_field != field)
+ continue;
+
+ if (form_field->possible_types().find(NAME_FIRST) !=
+ form_field->possible_types().end() ||
+ form_field->heuristic_type() == NAME_FIRST) {
+ type = NAME_FIRST;
+ break;
+ }
+
+ if (form_field->possible_types().find(NAME_FULL) !=
+ form_field->possible_types().end() ||
+ form_field->heuristic_type() == NAME_FULL) {
+ type = NAME_FULL;
+ break;
+ }
+ }
+ }
+
+ if (type == UNKNOWN_TYPE)
+ return false;
+
+ std::vector<string16> names;
+ std::vector<string16> labels;
+ for (std::vector<AutoFillProfile*>::const_iterator iter = profiles.begin();
+ iter != profiles.end(); ++iter) {
+ string16 name = (*iter)->GetFieldText(AutoFillType(type));
+ string16 label = (*iter)->Label();
+
+ // TODO(jhawkins): What if name.length() == 0?
+ if (StartsWith(name, field.value(), false)) {
+ names.push_back(name);
+ labels.push_back(label);
+ }
+ }
+
+ // No suggestions.
+ if (names.empty())
+ return false;
+
+ // TODO(jhawkins): If the default profile is in this list, set it as the
+ // default suggestion index.
+ host->AutoFillSuggestionsReturned(query_id, names, labels, -1);
+ return true;
+}
+
void AutoFillManager::OnAutoFillDialogApply(
std::vector<AutoFillProfile>* profiles,
std::vector<CreditCard>* credit_cards) {
diff --git a/chrome/browser/autofill/autofill_manager.h b/chrome/browser/autofill/autofill_manager.h
index ea7ae691..818e85a 100644
--- a/chrome/browser/autofill/autofill_manager.h
+++ b/chrome/browser/autofill/autofill_manager.h
@@ -14,6 +14,7 @@
#include "chrome/browser/renderer_host/render_view_host_delegate.h"
namespace webkit_glue {
+class FormField;
class FormFieldValues;
}
@@ -41,6 +42,8 @@ class AutoFillManager : public RenderViewHostDelegate::AutoFill,
const webkit_glue::FormFieldValues& form);
virtual void FormsSeen(
const std::vector<webkit_glue::FormFieldValues>& forms);
+ virtual bool GetAutoFillSuggestions(int query_id,
+ const webkit_glue::FormField& field);
// AutoFillDialogObserver implementation:
virtual void OnAutoFillDialogApply(
diff --git a/chrome/browser/renderer_host/render_view_host.cc b/chrome/browser/renderer_host/render_view_host.cc
index 2c1bdf2..055a15d 100644
--- a/chrome/browser/renderer_host/render_view_host.cc
+++ b/chrome/browser/renderer_host/render_view_host.cc
@@ -42,6 +42,7 @@
#include "net/base/net_util.h"
#include "third_party/skia/include/core/SkBitmap.h"
#include "third_party/WebKit/WebKit/chromium/public/WebFindOptions.h"
+#include "webkit/glue/form_field.h"
#include "webkit/glue/form_field_values.h"
#if defined(OS_WIN)
@@ -1558,18 +1559,27 @@ void RenderViewHost::OnMsgShouldCloseACK(bool proceed) {
}
}
-void RenderViewHost::OnQueryFormFieldAutofill(int query_id,
- const string16& field_name,
- const string16& user_text) {
+void RenderViewHost::OnQueryFormFieldAutofill(
+ int query_id, const webkit_glue::FormField& field) {
+ RenderViewHostDelegate::AutoFill* autofill_delegate =
+ delegate_->GetAutoFillDelegate();
+ // If the AutoFill delegate has results to return, we don't need any results
+ // from the FormFieldHistory delegate.
+ if (autofill_delegate &&
+ autofill_delegate->GetAutoFillSuggestions(query_id, field)) {
+ return;
+ }
+
RenderViewHostDelegate::FormFieldHistory* formfield_history_delegate =
delegate_->GetFormFieldHistoryDelegate();
- bool ok = false;
- if (formfield_history_delegate) {
- ok = formfield_history_delegate->GetFormFieldHistorySuggestions(
- query_id, field_name, user_text);
+ if (formfield_history_delegate &&
+ formfield_history_delegate->GetFormFieldHistorySuggestions(
+ query_id, field.name(), field.value())) {
+ return;
}
- if (!ok)
- AutocompleteSuggestionsReturned(query_id, std::vector<string16>(), -1);
+
+ // No suggestions provided, so send an empty vector as the results.
+ AutocompleteSuggestionsReturned(query_id, std::vector<string16>(), -1);
}
void RenderViewHost::OnRemoveAutofillEntry(const string16& field_name,
@@ -1580,10 +1590,19 @@ void RenderViewHost::OnRemoveAutofillEntry(const string16& field_name,
formfield_history_delegate->RemoveFormFieldHistoryEntry(field_name, value);
}
+void RenderViewHost::AutoFillSuggestionsReturned(
+ int query_id,
+ const std::vector<string16>& names,
+ const std::vector<string16>& labels,
+ int default_suggestion_index) {
+ Send(new ViewMsg_AutoFillSuggestionsReturned(
+ routing_id(), query_id, names, labels, default_suggestion_index));
+}
+
void RenderViewHost::AutocompleteSuggestionsReturned(
int query_id, const std::vector<string16>& suggestions,
int default_suggestion_index) {
- Send(new ViewMsg_QueryFormFieldAutofill_ACK(
+ Send(new ViewMsg_AutocompleteSuggestionsReturned(
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 5e952d9..52453a2 100644
--- a/chrome/browser/renderer_host/render_view_host.h
+++ b/chrome/browser/renderer_host/render_view_host.h
@@ -41,6 +41,7 @@ class Point;
}
namespace webkit_glue {
+class FormField;
class FormFieldValues;
struct WebApplicationInfo;
}
@@ -385,6 +386,13 @@ class RenderViewHost : public RenderWidgetHost {
// notification.
void PopupNotificationVisibilityChanged(bool visible);
+ // Called by the AutoFillManager when the list of suggestions is ready.
+ void AutoFillSuggestionsReturned(
+ int query_id,
+ const std::vector<string16>& names,
+ const std::vector<string16>& labels,
+ int default_suggestion_index);
+
// Called by the FormFieldHistoryManager when the list of suggestions is
// ready.
void AutocompleteSuggestionsReturned(
@@ -578,8 +586,7 @@ class RenderViewHost : public RenderWidgetHost {
const webkit_glue::WebApplicationInfo& info);
void OnMsgShouldCloseACK(bool proceed);
void OnQueryFormFieldAutofill(int request_id,
- const string16& field_name,
- const string16& user_text);
+ const webkit_glue::FormField& field);
void OnRemoveAutofillEntry(const string16& field_name,
const string16& value);
diff --git a/chrome/browser/renderer_host/render_view_host_delegate.h b/chrome/browser/renderer_host/render_view_host_delegate.h
index 3dd7b9a..b05c04c 100644
--- a/chrome/browser/renderer_host/render_view_host_delegate.h
+++ b/chrome/browser/renderer_host/render_view_host_delegate.h
@@ -51,6 +51,7 @@ class Message;
}
namespace webkit_glue {
+class FormField;
class FormFieldValues;
struct PasswordForm;
struct WebApplicationInfo;
@@ -366,7 +367,7 @@ class RenderViewHostDelegate {
// Called to retrieve a list of suggestions from the web database given
// the name of the field |field_name| and what the user has already typed
- // in the field |user_text|. Appeals to the database thead to perform the
+ // in the field |user_text|. Appeals to the database thread to perform the
// query. When the database thread is finished, the FormFieldHistory manager
// retrieves the calling RenderViewHost and then passes the vector of
// suggestions to RenderViewHost::AutocompleteSuggestionsReturned.
@@ -395,6 +396,13 @@ class RenderViewHostDelegate {
// frame.
virtual void FormsSeen(
const std::vector<webkit_glue::FormFieldValues>& forms) = 0;
+
+ // Called to retrieve a list of AutoFill suggestions from the web database
+ // given the name of the field and what the user has already typed in the
+ // field. Returns true to indicate that
+ // RenderViewHost::AutoFillSuggestionsReturned has been called.
+ virtual bool GetAutoFillSuggestions(
+ int query_id, const webkit_glue::FormField& field) = 0;
};
// ---------------------------------------------------------------------------
diff --git a/chrome/common/render_messages.h b/chrome/common/render_messages.h
index 533c92d..c163e82 100644
--- a/chrome/common/render_messages.h
+++ b/chrome/common/render_messages.h
@@ -903,6 +903,43 @@ struct ParamTraits<webkit_glue::PasswordForm> {
}
};
+// Traits for FormField_Params structure to pack/unpack.
+template <>
+struct ParamTraits<webkit_glue::FormField> {
+ typedef webkit_glue::FormField param_type;
+ static void Write(Message* m, const param_type& p) {
+ WriteParam(m, p.label());
+ WriteParam(m, p.name());
+ WriteParam(m, p.value());
+ WriteParam(m, p.form_control_type());
+ WriteParam(m, static_cast<int>(p.input_type()));
+ }
+ static bool Read(const Message* m, void** iter, param_type* p) {
+ string16 label, name, value, form_control_type;
+ int type;
+ bool result = ReadParam(m, iter, &label);
+ result = result && ReadParam(m, iter, &name);
+ result = result && ReadParam(m, iter, &value);
+ result = result && ReadParam(m, iter, &form_control_type);
+ result = result && ReadParam(m, iter, &type);
+ if (!result)
+ return false;
+
+ WebKit::WebInputElement::InputType input_type =
+ static_cast<WebKit::WebInputElement::InputType>(type);
+
+ p->set_label(label);
+ p->set_name(name);
+ p->set_value(value);
+ p->set_form_control_type(form_control_type);
+ p->set_input_type(input_type);
+ return true;
+ }
+ static void Log(const param_type& p, std::wstring* l) {
+ l->append(L"<FormField>");
+ }
+};
+
// Traits for FormFieldValues_Params structure to pack/unpack.
template <>
struct ParamTraits<webkit_glue::FormFieldValues> {
@@ -914,13 +951,8 @@ struct ParamTraits<webkit_glue::FormFieldValues> {
WriteParam(m, p.target_url);
WriteParam(m, p.elements.size());
std::vector<webkit_glue::FormField>::const_iterator itr;
- for (itr = p.elements.begin(); itr != p.elements.end(); itr++) {
- WriteParam(m, itr->label());
- WriteParam(m, itr->name());
- WriteParam(m, itr->value());
- WriteParam(m, itr->form_control_type());
- WriteParam(m, static_cast<int>(itr->input_type()));
- }
+ for (itr = p.elements.begin(); itr != p.elements.end(); itr++)
+ WriteParam(m, *itr);
}
static bool Read(const Message* m, void** iter, param_type* p) {
bool result = true;
@@ -935,22 +967,13 @@ struct ParamTraits<webkit_glue::FormFieldValues> {
return false;
for (size_t i = 0; i < elements_size; i++) {
- string16 label, name, value, form_control_type;
- int type;
- result = result && ReadParam(m, iter, &label);
- result = result && ReadParam(m, iter, &name);
- result = result && ReadParam(m, iter, &value);
- result = result && ReadParam(m, iter, &form_control_type);
- result = result && ReadParam(m, iter, &type);
- if (result) {
- WebKit::WebInputElement::InputType input_type =
- static_cast<WebKit::WebInputElement::InputType>(type);
- p->elements.push_back(
- webkit_glue::FormField(label, name, value,
- form_control_type, input_type));
- }
+ webkit_glue::FormField field;
+ if (!ReadParam(m, iter, &field))
+ return false;
+
+ p->elements.push_back(field);
}
- return result;
+ return true;
}
static void Log(const param_type& p, std::wstring* l) {
l->append(L"<FormFieldValues>");
diff --git a/chrome/common/render_messages_internal.h b/chrome/common/render_messages_internal.h
index 68a209a..eeba87e 100644
--- a/chrome/common/render_messages_internal.h
+++ b/chrome/common/render_messages_internal.h
@@ -6,6 +6,10 @@
// header guard.
// See ipc_message_macros.h for explanation of the macros and passes.
+#include <map>
+#include <string>
+#include <vector>
+
#include "build/build_config.h"
#include "base/file_path.h"
@@ -23,6 +27,7 @@
#include "ipc/ipc_message_macros.h"
#include "third_party/skia/include/core/SkBitmap.h"
#include "webkit/glue/dom_operations.h"
+#include "webkit/glue/form_field.h"
#include "webkit/glue/webcursor.h"
#if defined(OS_POSIX)
@@ -607,9 +612,17 @@ IPC_BEGIN_MESSAGES(View)
std::vector<int> /* host_ids */,
appcache::EventID)
- // Reply to the ViewHostMsg_QueryFormFieldAutofill message with the autofill
- // suggestions.
- IPC_MESSAGE_ROUTED3(ViewMsg_QueryFormFieldAutofill_ACK,
+ // Reply to the ViewHostMsg_QueryFormFieldAutofill message with the
+ // autofill suggestions.
+ IPC_MESSAGE_ROUTED4(ViewMsg_AutoFillSuggestionsReturned,
+ int /* id of the request message */,
+ std::vector<string16> /* names */,
+ std::vector<string16> /* labels */,
+ int /* index of default suggestion */)
+
+ // Reply to the ViewHostMsg_QueryFormFieldAutofill message with the
+ // autocomplete suggestions.
+ IPC_MESSAGE_ROUTED3(ViewMsg_AutocompleteSuggestionsReturned,
int /* id of the request message */,
std::vector<string16> /* suggestions */,
int /* index of default suggestion */)
@@ -644,11 +657,11 @@ IPC_BEGIN_MESSAGES(View)
base::SyncSocket::Handle /* socket handle */,
uint32 /* length */)
#else
-IPC_MESSAGE_ROUTED4(ViewMsg_NotifyLowLatencyAudioStreamCreated,
- int /* stream id */,
- base::SharedMemoryHandle /* handle */,
- base::FileDescriptor /* socket handle */,
- uint32 /* length */)
+ IPC_MESSAGE_ROUTED4(ViewMsg_NotifyLowLatencyAudioStreamCreated,
+ int /* stream id */,
+ base::SharedMemoryHandle /* handle */,
+ base::FileDescriptor /* socket handle */,
+ uint32 /* length */)
#endif
// Notification message sent from AudioRendererHost to renderer for state
@@ -1638,8 +1651,8 @@ IPC_BEGIN_MESSAGES(ViewHost)
#endif
#if defined(OS_MACOSX)
- // Asks the browser to create a block of shared memory for the renderer to pass
- // NativeMetafile data to the browser.
+ // Asks the browser to create a block of shared memory for the renderer to
+ // pass NativeMetafile data to the browser.
IPC_SYNC_MESSAGE_ROUTED1_1(ViewHostMsg_AllocatePDFTransport,
uint32 /* buffer size */,
base::SharedMemoryHandle /* browser handle */)
@@ -1717,10 +1730,9 @@ IPC_BEGIN_MESSAGES(ViewHost)
gfx::Rect /* Out: Window location */)
// Queries the browser for suggestion for autofill in a form input field.
- IPC_MESSAGE_ROUTED3(ViewHostMsg_QueryFormFieldAutofill,
+ IPC_MESSAGE_ROUTED2(ViewHostMsg_QueryFormFieldAutofill,
int /* id of this message */,
- string16 /* field name */,
- string16 /* user entered text */)
+ webkit_glue::FormField /* the form field */)
// Instructs the browser to remove the specified autofill-entry from the
// database.
diff --git a/chrome/renderer/render_view.cc b/chrome/renderer/render_view.cc
index ac6af64..7a5fad2 100644
--- a/chrome/renderer/render_view.cc
+++ b/chrome/renderer/render_view.cc
@@ -79,6 +79,7 @@
#include "third_party/WebKit/WebKit/chromium/public/WebFormElement.h"
#include "third_party/WebKit/WebKit/chromium/public/WebFrame.h"
#include "third_party/WebKit/WebKit/chromium/public/WebHistoryItem.h"
+#include "third_party/WebKit/WebKit/chromium/public/WebInputElement.h"
#include "third_party/WebKit/WebKit/chromium/public/WebNode.h"
#include "third_party/WebKit/WebKit/chromium/public/WebNodeList.h"
#include "third_party/WebKit/WebKit/chromium/public/WebPageSerializer.h"
@@ -98,8 +99,10 @@
#include "third_party/WebKit/WebKit/chromium/public/WebVector.h"
#include "webkit/appcache/web_application_cache_host_impl.h"
#include "webkit/default_plugin/default_plugin_shared.h"
-#include "webkit/glue/glue_serialize.h"
#include "webkit/glue/dom_operations.h"
+#include "webkit/glue/form_field.h"
+#include "webkit/glue/form_field_values.h"
+#include "webkit/glue/glue_serialize.h"
#include "webkit/glue/image_decoder.h"
#include "webkit/glue/media/buffered_data_source.h"
#include "webkit/glue/media/simple_data_source.h"
@@ -123,6 +126,7 @@ using appcache::WebApplicationCacheHostImpl;
using base::Time;
using base::TimeDelta;
using webkit_glue::AltErrorPageResourceFetcher;
+using webkit_glue::FormField;
using webkit_glue::FormFieldValues;
using webkit_glue::ImageResourceFetcher;
using webkit_glue::PasswordForm;
@@ -145,6 +149,7 @@ using WebKit::WebFindOptions;
using WebKit::WebFormElement;
using WebKit::WebFrame;
using WebKit::WebHistoryItem;
+using WebKit::WebInputElement;
using WebKit::WebMediaPlayer;
using WebKit::WebMediaPlayerAction;
using WebKit::WebMediaPlayerClient;
@@ -558,8 +563,10 @@ void RenderView::OnMessageReceived(const IPC::Message& message) {
OnMessageFromExternalHost)
IPC_MESSAGE_HANDLER(ViewMsg_DisassociateFromPopupCount,
OnDisassociateFromPopupCount)
- IPC_MESSAGE_HANDLER(ViewMsg_QueryFormFieldAutofill_ACK,
- OnQueryFormFieldAutofillAck)
+ IPC_MESSAGE_HANDLER(ViewMsg_AutoFillSuggestionsReturned,
+ OnAutoFillSuggestionsReturned)
+ IPC_MESSAGE_HANDLER(ViewMsg_AutocompleteSuggestionsReturned,
+ OnAutocompleteSuggestionsReturned)
IPC_MESSAGE_HANDLER(ViewMsg_PopupNotificationVisibilityChanged,
OnPopupNotificationVisibilityChanged)
IPC_MESSAGE_HANDLER(ViewMsg_MoveOrResizeStarted, OnMoveOrResizeStarted)
@@ -1406,7 +1413,19 @@ void RenderView::AddGURLSearchProvider(const GURL& osd_url, bool autodetected) {
autodetected));
}
-void RenderView::OnQueryFormFieldAutofillAck(
+void RenderView::OnAutoFillSuggestionsReturned(
+ int query_id,
+ const std::vector<string16>& names,
+ const std::vector<string16>& labels,
+ int default_suggestion_index) {
+ if (webview() && query_id == autofill_query_id_) {
+ webview()->applyAutoFillSuggestions(
+ autofill_query_node_, names, labels, default_suggestion_index);
+ }
+ autofill_query_node_.reset();
+}
+
+void RenderView::OnAutocompleteSuggestionsReturned(
int query_id,
const std::vector<string16>& suggestions,
int default_suggestion_index) {
@@ -1916,8 +1935,10 @@ void RenderView::queryAutofillSuggestions(const WebNode& node,
static int query_counter = 0;
autofill_query_id_ = query_counter++;
autofill_query_node_ = node;
+ const WebKit::WebInputElement input_element =
+ node.toConstElement<WebInputElement>();
Send(new ViewHostMsg_QueryFormFieldAutofill(
- routing_id_, autofill_query_id_, name, value));
+ routing_id_, autofill_query_id_, FormField(input_element)));
}
void RenderView::removeAutofillSuggestions(const WebString& name,
diff --git a/chrome/renderer/render_view.h b/chrome/renderer/render_view.h
index 690a6b3..f9ab206 100644
--- a/chrome/renderer/render_view.h
+++ b/chrome/renderer/render_view.h
@@ -697,8 +697,16 @@ class RenderView : public RenderWidget,
// Notification about ui theme changes.
void OnThemeChanged();
- // Notification that we have received autofill suggestion.
- void OnQueryFormFieldAutofillAck(
+ // Notification that we have received AutoFill suggestions. |names| and
+ // |labels| correspond with each other and should be the same size.
+ void OnAutoFillSuggestionsReturned(
+ int query_id,
+ const std::vector<string16>& names,
+ const std::vector<string16>& labels,
+ int default_suggestions_index);
+
+ // Notification that we have received Autocomplete suggestions.
+ void OnAutocompleteSuggestionsReturned(
int query_id,
const std::vector<string16>& suggestions,
int default_suggestions_index);
diff --git a/webkit/glue/form_field.cc b/webkit/glue/form_field.cc
index 4d95cb8..56f057f 100644
--- a/webkit/glue/form_field.cc
+++ b/webkit/glue/form_field.cc
@@ -39,4 +39,13 @@ FormField::FormField(const string16& label,
input_type_(input_type) {
}
+bool FormField::operator!=(const FormField& field) {
+ // A FormField stores a value, but the value is not part of the identity of
+ // the field, so we don't want to compare the values.
+ return (label_ != field.label_ ||
+ name_ != field.name_ ||
+ form_control_type_ != field.form_control_type_ ||
+ input_type_ != field.input_type_);
+}
+
} // namespace webkit_glue
diff --git a/webkit/glue/form_field.h b/webkit/glue/form_field.h
index dfaf9ce..88e3ed9 100644
--- a/webkit/glue/form_field.h
+++ b/webkit/glue/form_field.h
@@ -27,7 +27,17 @@ class FormField {
string16 form_control_type() const { return form_control_type_; }
WebKit::WebInputElement::InputType input_type() const { return input_type_; }
+ void set_label(const string16& label) { label_ = label; }
+ void set_name(const string16& name) { name_ = name; }
void set_value(const string16& value) { value_ = value; }
+ void set_form_control_type(const string16& form_control_type) {
+ form_control_type_ = form_control_type;
+ }
+ void set_input_type(WebKit::WebInputElement::InputType input_type) {
+ input_type_ = input_type;
+ }
+
+ bool operator!=(const FormField& field);
private:
string16 label_;