Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(176)

Unified Diff: webkit/glue/webview_impl.cc

Issue 42258: Add way to remove entries from autocomplete (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « webkit/glue/webview_impl.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webkit/glue/webview_impl.cc
===================================================================
--- webkit/glue/webview_impl.cc (revision 11686)
+++ webkit/glue/webview_impl.cc (working copy)
@@ -264,6 +264,11 @@
selected_index_ = -1;
}
+ void RemoveItemAtIndex(int index) {
+ DCHECK(index >= 0 && index < static_cast<int>(suggestions_.size()));
+ suggestions_.erase(suggestions_.begin() + index);
+ }
+
WebCore::HTMLInputElement* text_field() const {
return text_field_.get();
}
@@ -538,6 +543,35 @@
return false;
}
+ // Pressing delete triggers the removal of the selected suggestion from the
+ // DB.
+ if (event.windows_key_code == base::VKEY_DELETE &&
+ autocomplete_popup_->selectedIndex() != -1) {
+ Node* node = GetFocusedNode();
+ if (!node || (node->nodeType() != WebCore::Node::ELEMENT_NODE)) {
+ NOTREACHED();
+ return false;
+ }
+ WebCore::Element* element = static_cast<WebCore::Element*>(node);
+ if (!element->hasLocalName(WebCore::HTMLNames::inputTag)) {
+ NOTREACHED();
+ return false;
+ }
+
+ 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);
+ // Update the entries in the currently showing popup to reflect the
+ // deletion.
+ autocomplete_popup_client_->RemoveItemAtIndex(selected_index);
+ RefreshAutofillPopup();
+ return false;
+ }
+
if (!autocomplete_popup_->isInterestedInEventForKey(event.windows_key_code))
return false;
@@ -1587,16 +1621,7 @@
if (autocomplete_popup_showing_) {
autocomplete_popup_client_->SetSuggestions(suggestions);
- IntRect old_bounds = autocomplete_popup_->boundsRect();
- autocomplete_popup_->refresh();
- IntRect new_bounds = autocomplete_popup_->boundsRect();
- // Let's resize the backing window if necessary.
- if (old_bounds != new_bounds) {
- WebWidgetImpl* web_widget =
- static_cast<WebWidgetImpl*>(autocomplete_popup_->client());
- web_widget->delegate()->SetWindowRect(
- web_widget, webkit_glue::FromIntRect(new_bounds));
- }
+ RefreshAutofillPopup();
} else {
autocomplete_popup_->show(focused_node->getRect(),
focused_node->ownerDocument()->view(), 0);
@@ -1696,6 +1721,20 @@
HideAutoCompletePopup();
}
+void WebViewImpl::RefreshAutofillPopup() {
+ DCHECK(autocomplete_popup_showing_);
+ IntRect old_bounds = autocomplete_popup_->boundsRect();
+ autocomplete_popup_->refresh();
+ IntRect new_bounds = autocomplete_popup_->boundsRect();
+ // Let's resize the backing window if necessary.
+ if (old_bounds != new_bounds) {
+ WebWidgetImpl* web_widget =
+ static_cast<WebWidgetImpl*>(autocomplete_popup_->client());
+ web_widget->delegate()->SetWindowRect(
+ web_widget, webkit_glue::FromIntRect(new_bounds));
+ }
+}
+
Node* WebViewImpl::GetFocusedNode() {
Frame* frame = page_->focusController()->focusedFrame();
if (!frame)
« no previous file with comments | « webkit/glue/webview_impl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698