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

Side by Side Diff: chrome/renderer/render_view.cc

Issue 2138005: AutoFill: Preview form field values when the user changes the AutoFill dropdown (Closed)
Patch Set: Rebase. Created 10 years, 6 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 unified diff | Download patch
« no previous file with comments | « chrome/renderer/render_view.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/renderer/render_view.h" 5 #include "chrome/renderer/render_view.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 384 matching lines...) Expand 10 before | Expand all | Expand 10 after
395 #if defined(OS_MACOSX) 395 #if defined(OS_MACOSX)
396 has_document_tag_(false), 396 has_document_tag_(false),
397 #endif 397 #endif
398 document_tag_(0), 398 document_tag_(0),
399 webkit_preferences_(webkit_preferences), 399 webkit_preferences_(webkit_preferences),
400 session_storage_namespace_id_(session_storage_namespace_id), 400 session_storage_namespace_id_(session_storage_namespace_id),
401 ALLOW_THIS_IN_INITIALIZER_LIST(cookie_jar_(this)), 401 ALLOW_THIS_IN_INITIALIZER_LIST(cookie_jar_(this)),
402 ALLOW_THIS_IN_INITIALIZER_LIST(translate_helper_(this)), 402 ALLOW_THIS_IN_INITIALIZER_LIST(translate_helper_(this)),
403 cross_origin_access_count_(0), 403 cross_origin_access_count_(0),
404 same_origin_access_count_(0), 404 same_origin_access_count_(0),
405 ALLOW_THIS_IN_INITIALIZER_LIST(pepper_delegate_(this)) { 405 ALLOW_THIS_IN_INITIALIZER_LIST(pepper_delegate_(this)),
406 autofill_action_(AUTOFILL_NONE) {
406 ClearBlockedContentSettings(); 407 ClearBlockedContentSettings();
407 } 408 }
408 409
409 RenderView::~RenderView() { 410 RenderView::~RenderView() {
410 if (decrement_shared_popup_at_destruction_) 411 if (decrement_shared_popup_at_destruction_)
411 shared_popup_counter_->data--; 412 shared_popup_counter_->data--;
412 413
413 // Dispose of un-disposed image fetchers. 414 // Dispose of un-disposed image fetchers.
414 for (ImageResourceFetcherSet::iterator i = image_fetchers_.begin(); 415 for (ImageResourceFetcherSet::iterator i = image_fetchers_.begin();
415 i != image_fetchers_.end(); ++i) { 416 i != image_fetchers_.end(); ++i) {
(...skipping 1082 matching lines...) Expand 10 before | Expand all | Expand 10 after
1498 int default_suggestion_index) { 1499 int default_suggestion_index) {
1499 if (webview() && query_id == autofill_query_id_) { 1500 if (webview() && query_id == autofill_query_id_) {
1500 webview()->applyAutocompleteSuggestions( 1501 webview()->applyAutocompleteSuggestions(
1501 autofill_query_node_, suggestions, default_suggestion_index); 1502 autofill_query_node_, suggestions, default_suggestion_index);
1502 } 1503 }
1503 autofill_query_node_.reset(); 1504 autofill_query_node_.reset();
1504 } 1505 }
1505 1506
1506 void RenderView::OnAutoFillFormDataFilled(int query_id, 1507 void RenderView::OnAutoFillFormDataFilled(int query_id,
1507 const webkit_glue::FormData& form) { 1508 const webkit_glue::FormData& form) {
1508 if (query_id != autofill_query_id_) 1509 if (!webview() || query_id != autofill_query_id_)
1509 return; 1510 return;
1510 1511
1511 form_manager_.FillForm(form); 1512 DCHECK_NE(AUTOFILL_NONE, autofill_action_);
1513
1514 if (autofill_action_ == AUTOFILL_FILL)
1515 form_manager_.FillForm(form);
1516 else if (autofill_action_ == AUTOFILL_PREVIEW)
1517 form_manager_.PreviewForm(form);
1518
1519 autofill_action_ = AUTOFILL_NONE;
1512 } 1520 }
1513 1521
1514 void RenderView::OnAllowScriptToClose(bool script_can_close) { 1522 void RenderView::OnAllowScriptToClose(bool script_can_close) {
1515 script_can_close_ = script_can_close; 1523 script_can_close_ = script_can_close;
1516 } 1524 }
1517 1525
1518 uint32 RenderView::GetCPBrowsingContext() { 1526 uint32 RenderView::GetCPBrowsingContext() {
1519 uint32 context = 0; 1527 uint32 context = 0;
1520 Send(new ViewHostMsg_GetCPBrowsingContext(&context)); 1528 Send(new ViewHostMsg_GetCPBrowsingContext(&context));
1521 return context; 1529 return context;
(...skipping 501 matching lines...) Expand 10 before | Expand all | Expand 10 after
2023 2031
2024 Send(new ViewHostMsg_QueryFormFieldAutofill( 2032 Send(new ViewHostMsg_QueryFormFieldAutofill(
2025 routing_id_, autofill_query_id_, field)); 2033 routing_id_, autofill_query_id_, field));
2026 } 2034 }
2027 2035
2028 void RenderView::removeAutofillSuggestions(const WebString& name, 2036 void RenderView::removeAutofillSuggestions(const WebString& name,
2029 const WebString& value) { 2037 const WebString& value) {
2030 Send(new ViewHostMsg_RemoveAutofillEntry(routing_id_, name, value)); 2038 Send(new ViewHostMsg_RemoveAutofillEntry(routing_id_, name, value));
2031 } 2039 }
2032 2040
2033 void RenderView::didAcceptAutoFillSuggestion( 2041 void RenderView::didAcceptAutoFillSuggestion(const WebKit::WebNode& node,
2034 const WebKit::WebNode& node, 2042 const WebKit::WebString& value,
2035 const WebKit::WebString& value, 2043 const WebKit::WebString& label) {
2036 const WebKit::WebString& label) { 2044 QueryAutoFillFormData(node, value, label, AUTOFILL_FILL);
2037 static int query_counter = 0; 2045 }
2038 autofill_query_id_ = query_counter++;
2039 2046
2047 void RenderView::didSelectAutoFillSuggestion(const WebKit::WebNode& node,
2048 const WebKit::WebString& value,
2049 const WebKit::WebString& label) {
2050 didClearAutoFillSelection(node);
2051 QueryAutoFillFormData(node, value, label, AUTOFILL_PREVIEW);
2052 }
2053
2054 void RenderView::didClearAutoFillSelection(const WebKit::WebNode& node) {
2040 webkit_glue::FormData form; 2055 webkit_glue::FormData form;
2041 const WebInputElement element = node.toConst<WebInputElement>(); 2056 const WebFormControlElement element = node.toConst<WebFormControlElement>();
2042 if (!form_manager_.FindFormWithFormControlElement( 2057 if (!form_manager_.FindFormWithFormControlElement(
2043 element, FormManager::REQUIRE_NONE, &form)) 2058 element, FormManager::REQUIRE_NONE, &form))
2044 return; 2059 return;
2045 2060 form_manager_.ClearPreviewedForm(form);
2046 Send(new ViewHostMsg_FillAutoFillFormData(
2047 routing_id_, autofill_query_id_, form, value, label));
2048 } 2061 }
2049 2062
2050 // WebKit::WebWidgetClient ---------------------------------------------------- 2063 // WebKit::WebWidgetClient ----------------------------------------------------
2051 2064
2052 // We are supposed to get a single call to Show for a newly created RenderView 2065 // We are supposed to get a single call to Show for a newly created RenderView
2053 // that was created via RenderView::CreateWebView. So, we wait until this 2066 // that was created via RenderView::CreateWebView. So, we wait until this
2054 // point to dispatch the ShowView message. 2067 // point to dispatch the ShowView message.
2055 // 2068 //
2056 // This method provides us with the information about how to display the newly 2069 // This method provides us with the information about how to display the newly
2057 // created RenderView (i.e., as a constrained popup or as a new tab). 2070 // created RenderView (i.e., as a constrained popup or as a new tab).
(...skipping 2979 matching lines...) Expand 10 before | Expand all | Expand 10 after
5037 5050
5038 if (last_top_level_navigation_page_id_ != page_id_ && 5051 if (last_top_level_navigation_page_id_ != page_id_ &&
5039 // Not interested in reloads. 5052 // Not interested in reloads.
5040 type != WebKit::WebNavigationTypeReload && 5053 type != WebKit::WebNavigationTypeReload &&
5041 type != WebKit::WebNavigationTypeFormSubmitted) { 5054 type != WebKit::WebNavigationTypeFormSubmitted) {
5042 return true; 5055 return true;
5043 } 5056 }
5044 } 5057 }
5045 return false; 5058 return false;
5046 } 5059 }
5060
5061 void RenderView::QueryAutoFillFormData(const WebKit::WebNode& node,
5062 const WebKit::WebString& value,
5063 const WebKit::WebString& label,
5064 AutoFillAction action) {
5065 static int query_counter = 0;
5066 autofill_query_id_ = query_counter++;
5067
5068 webkit_glue::FormData form;
5069 const WebInputElement element = node.toConst<WebInputElement>();
5070 if (!form_manager_.FindFormWithFormControlElement(
5071 element, FormManager::REQUIRE_NONE, &form))
5072 return;
5073
5074 autofill_action_ = action;
5075 Send(new ViewHostMsg_FillAutoFillFormData(
5076 routing_id_, autofill_query_id_, form, value, label));
5077 }
OLDNEW
« no previous file with comments | « chrome/renderer/render_view.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698