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

Unified Diff: content/browser/renderer_host/render_widget_host_view_base.cc

Issue 2370393002: Extracting placeholder information from Webkit to Blimp (Closed)
Patch Set: Addressed some comments Created 4 years, 1 month 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
Index: content/browser/renderer_host/render_widget_host_view_base.cc
diff --git a/content/browser/renderer_host/render_widget_host_view_base.cc b/content/browser/renderer_host/render_widget_host_view_base.cc
index 24129edc19f8293342b6b580c309a230d6b7d9ee..15f1437bed681d27ff93c9024b7ed7ef7bd523a5 100644
--- a/content/browser/renderer_host/render_widget_host_view_base.cc
+++ b/content/browser/renderer_host/render_widget_host_view_base.cc
@@ -15,7 +15,9 @@
#include "content/browser/renderer_host/render_widget_host_view_base_observer.h"
#include "content/browser/renderer_host/text_input_manager.h"
#include "content/common/content_switches_internal.h"
+#include "content/common/view_messages.h"
#include "content/public/browser/render_widget_host_view_frame_subscriber.h"
+#include "content/public/common/form_field_data.h"
#include "ui/display/display.h"
#include "ui/display/screen.h"
#include "ui/gfx/geometry/point_conversions.h"
@@ -29,6 +31,8 @@ namespace {
// How many microseconds apart input events should be flushed.
const int kFlushInputRateInUs = 16666;
+// For tracking requests for form field data.
+int next_request_id_ = 0;
}
RenderWidgetHostViewBase::RenderWidgetHostViewBase()
@@ -50,6 +54,14 @@ RenderWidgetHostViewBase::RenderWidgetHostViewBase()
RenderWidgetHostViewBase::~RenderWidgetHostViewBase() {
DCHECK(!mouse_locked_);
+
+ // Run callbacks for the outstanding text input info requests, if any.
+ for (auto iter = extract_form_field_data_callbacks_.begin();
+ iter != extract_form_field_data_callbacks_.end(); ++iter) {
+ ExtractFormFieldDataCallback callback = iter->second;
+ callback.Run(FormFieldData());
Charlie Reis 2016/11/04 20:59:46 This is a bit surprising to me-- it seems like we
David Trainor- moved to gerrit 2016/11/04 21:14:07 Yeah I had suggested this to make sure we properly
shaktisahu 2016/11/11 01:15:03 I see some more examples of callbacks getting call
Charlie Reis 2016/11/11 22:20:46 Hmm, those aren't reasons it's safe. :) It depen
David Trainor- moved to gerrit 2016/11/12 00:17:35 Posting the task guarantees you run after the clas
shaktisahu 2016/11/15 05:44:54 Very good point. I thought a bit about how to make
Charlie Reis 2016/11/16 00:18:00 Hmm. If the callback is just going to return earl
shaktisahu 2016/11/16 20:26:58 Ok. I am removing this from the destructor and cle
+ }
+
// We call this here to guarantee that observers are notified before we go
// away. However, some subclasses may wish to call this earlier in their
// shutdown process, e.g. to force removal from
@@ -157,6 +169,28 @@ ui::TextInputClient* RenderWidgetHostViewBase::GetTextInputClient() {
return NULL;
}
+void RenderWidgetHostViewBase::OnFocusedFormFieldDataReply(
+ int request_id,
+ const FormFieldData& field_data) {
+ DCHECK(extract_form_field_data_callbacks_.find(request_id) !=
+ extract_form_field_data_callbacks_.end());
+ extract_form_field_data_callbacks_[request_id].Run(field_data);
+ extract_form_field_data_callbacks_.erase(request_id);
+}
+
+void RenderWidgetHostViewBase::GetFocusedFormFieldData(
+ ExtractFormFieldDataCallback& reply) {
+ if (!GetRenderWidgetHost()) {
+ reply.Run(FormFieldData());
+ return;
+ }
+
+ int request_id = ++next_request_id_;
+ extract_form_field_data_callbacks_[request_id] = reply;
+ GetRenderWidgetHost()->Send(new ViewMsg_GetFocusedFormFieldData(
+ GetRenderWidgetHost()->GetRoutingID(), request_id));
+}
+
bool RenderWidgetHostViewBase::IsShowingContextMenu() const {
return showing_context_menu_;
}

Powered by Google App Engine
This is Rietveld 408576698