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

Unified Diff: blimp/engine/session/tab.cc

Issue 2370393002: Extracting placeholder information from Webkit to Blimp (Closed)
Patch Set: Removed callback from RenderFrameHost destructor 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: blimp/engine/session/tab.cc
diff --git a/blimp/engine/session/tab.cc b/blimp/engine/session/tab.cc
index 895902350dcc244a3438d8d417faa6f5cd83685c..3e48d42277230ab6031f5cfb9b3baedf715941fc 100644
--- a/blimp/engine/session/tab.cc
+++ b/blimp/engine/session/tab.cc
@@ -19,6 +19,7 @@
#include "content/public/browser/render_widget_host.h"
#include "content/public/browser/render_widget_host_view.h"
#include "content/public/browser/web_contents.h"
+#include "content/public/common/form_field_data.h"
#include "content/public/common/renderer_preferences.h"
#include "ui/aura/window.h"
#include "ui/gfx/geometry/size.h"
@@ -26,6 +27,13 @@
namespace blimp {
namespace engine {
+namespace {
+
+// Tracks the number of text input requests.
+static int g_text_input_request_id = 0;
+
+} // namespace
+
Tab::Tab(std::unique_ptr<content::WebContents> web_contents,
const int tab_id,
EngineRenderWidgetFeature* render_widget_feature,
@@ -34,7 +42,8 @@ Tab::Tab(std::unique_ptr<content::WebContents> web_contents,
tab_id_(tab_id),
render_widget_feature_(render_widget_feature),
navigation_message_sender_(navigation_message_sender),
- page_load_tracker_(web_contents_.get(), this) {
+ page_load_tracker_(web_contents_.get(), this),
+ weak_factory_(this) {
DCHECK(render_widget_feature_);
DCHECK(navigation_message_sender_);
@@ -168,6 +177,41 @@ void Tab::OnWebGestureEvent(content::RenderWidgetHost* render_widget_host,
render_widget_host->ForwardGestureEvent(*event);
}
+void Tab::ShowTextInputUI() {
+ g_text_input_request_id++;
+ content::FormFieldDataCallback callback =
+ base::Bind(&Tab::ProcessTextInputInfo, weak_factory_.GetWeakPtr(),
+ g_text_input_request_id);
+
+ content::RenderFrameHost* focused_frame = web_contents()->GetFocusedFrame();
+ if (focused_frame) {
+ focused_frame->RequestFocusedFormFieldData(callback);
+ }
+}
+
+void Tab::HideTextInputUI() {
+ g_text_input_request_id++;
+ render_widget_feature_->SendHideImeRequest(
+ tab_id(),
+ web_contents()->GetRenderWidgetHostView()->GetRenderWidgetHost());
+}
+
+void Tab::ProcessTextInputInfo(int request_id,
+ const content::FormFieldData& field) {
+ if (field.text_input_type == ui::TEXT_INPUT_TYPE_NONE)
Charlie Reis 2016/11/16 20:32:49 Do you still need this? Probably better to remove
shaktisahu 2016/11/17 01:16:15 Yes, we still return TEXT_INPUT_TYPE_NONE when the
+ return;
+
+ // Discard the results for old requests.
+ if (request_id < g_text_input_request_id) {
Charlie Reis 2016/11/16 20:32:49 Does this need to be global? Seems like a member
shaktisahu 2016/11/17 01:16:15 I am not sure. I felt like this is cleaner. Making
David Trainor- moved to gerrit 2016/11/17 23:05:41 A member sounds good IMO. current_form_request_id
+ return;
+ }
+
+ // TODO(shaktisahu): Remove adding RenderWidgetHost info to the proto.
+ render_widget_feature_->SendShowImeRequest(
+ tab_id(),
+ web_contents()->GetRenderWidgetHostView()->GetRenderWidgetHost(), field);
+}
+
void Tab::OnCompositorMessageReceived(
content::RenderWidgetHost* render_widget_host,
const std::vector<uint8_t>& message) {

Powered by Google App Engine
This is Rietveld 408576698