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

Side by Side 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 unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 "blimp/engine/session/tab.h" 5 #include "blimp/engine/session/tab.h"
6 6
7 #include "base/strings/utf_string_conversions.h" 7 #include "base/strings/utf_string_conversions.h"
8 #include "base/trace_event/trace_event.h" 8 #include "base/trace_event/trace_event.h"
9 #include "blimp/common/create_blimp_message.h" 9 #include "blimp/common/create_blimp_message.h"
10 #include "blimp/common/proto/blimp_message.pb.h" 10 #include "blimp/common/proto/blimp_message.pb.h"
11 #include "blimp/common/proto/render_widget.pb.h" 11 #include "blimp/common/proto/render_widget.pb.h"
12 #include "blimp/common/proto/tab_control.pb.h" 12 #include "blimp/common/proto/tab_control.pb.h"
13 #include "blimp/engine/common/blimp_user_agent.h" 13 #include "blimp/engine/common/blimp_user_agent.h"
14 #include "blimp/engine/feature/engine_render_widget_feature.h" 14 #include "blimp/engine/feature/engine_render_widget_feature.h"
15 #include "blimp/net/blimp_message_processor.h" 15 #include "blimp/net/blimp_message_processor.h"
16 #include "content/public/browser/navigation_controller.h" 16 #include "content/public/browser/navigation_controller.h"
17 #include "content/public/browser/navigation_entry.h" 17 #include "content/public/browser/navigation_entry.h"
18 #include "content/public/browser/render_view_host.h" 18 #include "content/public/browser/render_view_host.h"
19 #include "content/public/browser/render_widget_host.h" 19 #include "content/public/browser/render_widget_host.h"
20 #include "content/public/browser/render_widget_host_view.h" 20 #include "content/public/browser/render_widget_host_view.h"
21 #include "content/public/browser/web_contents.h" 21 #include "content/public/browser/web_contents.h"
22 #include "content/public/common/form_field_data.h"
22 #include "content/public/common/renderer_preferences.h" 23 #include "content/public/common/renderer_preferences.h"
23 #include "ui/aura/window.h" 24 #include "ui/aura/window.h"
24 #include "ui/gfx/geometry/size.h" 25 #include "ui/gfx/geometry/size.h"
25 26
26 namespace blimp { 27 namespace blimp {
27 namespace engine { 28 namespace engine {
28 29
30 namespace {
31
32 // Tracks the number of text input requests.
33 static int g_text_input_request_id = 0;
34
35 } // namespace
36
29 Tab::Tab(std::unique_ptr<content::WebContents> web_contents, 37 Tab::Tab(std::unique_ptr<content::WebContents> web_contents,
30 const int tab_id, 38 const int tab_id,
31 EngineRenderWidgetFeature* render_widget_feature, 39 EngineRenderWidgetFeature* render_widget_feature,
32 BlimpMessageProcessor* navigation_message_sender) 40 BlimpMessageProcessor* navigation_message_sender)
33 : web_contents_(std::move(web_contents)), 41 : web_contents_(std::move(web_contents)),
34 tab_id_(tab_id), 42 tab_id_(tab_id),
35 render_widget_feature_(render_widget_feature), 43 render_widget_feature_(render_widget_feature),
36 navigation_message_sender_(navigation_message_sender), 44 navigation_message_sender_(navigation_message_sender),
37 page_load_tracker_(web_contents_.get(), this) { 45 page_load_tracker_(web_contents_.get(), this),
46 weak_factory_(this) {
38 DCHECK(render_widget_feature_); 47 DCHECK(render_widget_feature_);
39 DCHECK(navigation_message_sender_); 48 DCHECK(navigation_message_sender_);
40 49
41 // A Tab is created upon client's request, thus an updated 50 // A Tab is created upon client's request, thus an updated
42 // user agent info (containing client OS info) is available, and we will use 51 // user agent info (containing client OS info) is available, and we will use
43 // that to override user agent string from BlimpContentRendererClient. 52 // that to override user agent string from BlimpContentRendererClient.
44 web_contents_->SetUserAgentOverride(GetBlimpEngineUserAgent()); 53 web_contents_->SetUserAgentOverride(GetBlimpEngineUserAgent());
45 54
46 render_widget_feature_->SetDelegate(tab_id_, this); 55 render_widget_feature_->SetDelegate(tab_id_, this);
47 56
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 navigation_message_sender_->ProcessMessage(std::move(message), 170 navigation_message_sender_->ProcessMessage(std::move(message),
162 net::CompletionCallback()); 171 net::CompletionCallback());
163 } 172 }
164 173
165 void Tab::OnWebGestureEvent(content::RenderWidgetHost* render_widget_host, 174 void Tab::OnWebGestureEvent(content::RenderWidgetHost* render_widget_host,
166 std::unique_ptr<blink::WebGestureEvent> event) { 175 std::unique_ptr<blink::WebGestureEvent> event) {
167 TRACE_EVENT1("blimp", "Tab::OnWebGestureEvent", "type", event->type); 176 TRACE_EVENT1("blimp", "Tab::OnWebGestureEvent", "type", event->type);
168 render_widget_host->ForwardGestureEvent(*event); 177 render_widget_host->ForwardGestureEvent(*event);
169 } 178 }
170 179
180 void Tab::ShowTextInputUI() {
181 g_text_input_request_id++;
182 content::FormFieldDataCallback callback =
183 base::Bind(&Tab::ProcessTextInputInfo, weak_factory_.GetWeakPtr(),
184 g_text_input_request_id);
185
186 content::RenderFrameHost* focused_frame = web_contents()->GetFocusedFrame();
187 if (focused_frame) {
188 focused_frame->RequestFocusedFormFieldData(callback);
189 }
190 }
191
192 void Tab::HideTextInputUI() {
193 g_text_input_request_id++;
194 render_widget_feature_->SendHideImeRequest(
195 tab_id(),
196 web_contents()->GetRenderWidgetHostView()->GetRenderWidgetHost());
197 }
198
199 void Tab::ProcessTextInputInfo(int request_id,
200 const content::FormFieldData& field) {
201 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
202 return;
203
204 // Discard the results for old requests.
205 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
206 return;
207 }
208
209 // TODO(shaktisahu): Remove adding RenderWidgetHost info to the proto.
210 render_widget_feature_->SendShowImeRequest(
211 tab_id(),
212 web_contents()->GetRenderWidgetHostView()->GetRenderWidgetHost(), field);
213 }
214
171 void Tab::OnCompositorMessageReceived( 215 void Tab::OnCompositorMessageReceived(
172 content::RenderWidgetHost* render_widget_host, 216 content::RenderWidgetHost* render_widget_host,
173 const std::vector<uint8_t>& message) { 217 const std::vector<uint8_t>& message) {
174 TRACE_EVENT0("blimp", "Tab::OnCompositorMessageReceived"); 218 TRACE_EVENT0("blimp", "Tab::OnCompositorMessageReceived");
175 219
176 render_widget_host->HandleCompositorProto(message); 220 render_widget_host->HandleCompositorProto(message);
177 } 221 }
178 222
179 } // namespace engine 223 } // namespace engine
180 } // namespace blimp 224 } // namespace blimp
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698