| OLD | NEW |
| 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 |
| 29 Tab::Tab(std::unique_ptr<content::WebContents> web_contents, | 30 Tab::Tab(std::unique_ptr<content::WebContents> web_contents, |
| 30 const int tab_id, | 31 const int tab_id, |
| 31 EngineRenderWidgetFeature* render_widget_feature, | 32 EngineRenderWidgetFeature* render_widget_feature, |
| 32 BlimpMessageProcessor* navigation_message_sender) | 33 BlimpMessageProcessor* navigation_message_sender) |
| 33 : web_contents_(std::move(web_contents)), | 34 : web_contents_(std::move(web_contents)), |
| 34 tab_id_(tab_id), | 35 tab_id_(tab_id), |
| 35 render_widget_feature_(render_widget_feature), | 36 render_widget_feature_(render_widget_feature), |
| 36 navigation_message_sender_(navigation_message_sender), | 37 navigation_message_sender_(navigation_message_sender), |
| 37 page_load_tracker_(web_contents_.get(), this) { | 38 page_load_tracker_(web_contents_.get(), this), |
| 39 weak_factory_(this) { |
| 38 DCHECK(render_widget_feature_); | 40 DCHECK(render_widget_feature_); |
| 39 DCHECK(navigation_message_sender_); | 41 DCHECK(navigation_message_sender_); |
| 40 | 42 |
| 41 // A Tab is created upon client's request, thus an updated | 43 // 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 | 44 // user agent info (containing client OS info) is available, and we will use |
| 43 // that to override user agent string from BlimpContentRendererClient. | 45 // that to override user agent string from BlimpContentRendererClient. |
| 44 web_contents_->SetUserAgentOverride(GetBlimpEngineUserAgent()); | 46 web_contents_->SetUserAgentOverride(GetBlimpEngineUserAgent()); |
| 45 | 47 |
| 46 render_widget_feature_->SetDelegate(tab_id_, this); | 48 render_widget_feature_->SetDelegate(tab_id_, this); |
| 47 | 49 |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 161 navigation_message_sender_->ProcessMessage(std::move(message), | 163 navigation_message_sender_->ProcessMessage(std::move(message), |
| 162 net::CompletionCallback()); | 164 net::CompletionCallback()); |
| 163 } | 165 } |
| 164 | 166 |
| 165 void Tab::OnWebGestureEvent(content::RenderWidgetHost* render_widget_host, | 167 void Tab::OnWebGestureEvent(content::RenderWidgetHost* render_widget_host, |
| 166 std::unique_ptr<blink::WebGestureEvent> event) { | 168 std::unique_ptr<blink::WebGestureEvent> event) { |
| 167 TRACE_EVENT1("blimp", "Tab::OnWebGestureEvent", "type", event->type); | 169 TRACE_EVENT1("blimp", "Tab::OnWebGestureEvent", "type", event->type); |
| 168 render_widget_host->ForwardGestureEvent(*event); | 170 render_widget_host->ForwardGestureEvent(*event); |
| 169 } | 171 } |
| 170 | 172 |
| 173 void Tab::ShowTextInputUI() { |
| 174 content::FormFieldDataCallback callback = |
| 175 base::Bind(&Tab::ProcessTextInputInfo, weak_factory_.GetWeakPtr()); |
| 176 |
| 177 content::RenderFrameHost* focused_frame = web_contents()->GetFocusedFrame(); |
| 178 if (focused_frame) { |
| 179 focused_frame->RequestFocusedFormFieldData(callback); |
| 180 } |
| 181 } |
| 182 |
| 183 void Tab::HideTextInputUI() { |
| 184 render_widget_feature_->SendHideImeRequest( |
| 185 tab_id(), |
| 186 web_contents()->GetRenderWidgetHostView()->GetRenderWidgetHost()); |
| 187 } |
| 188 |
| 189 void Tab::ProcessTextInputInfo(const content::FormFieldData& field) { |
| 190 // TODO(shaktisahu): Remove adding RenderWidgetHost info to the proto. |
| 191 render_widget_feature_->SendShowImeRequest( |
| 192 tab_id(), |
| 193 web_contents()->GetRenderWidgetHostView()->GetRenderWidgetHost(), field); |
| 194 } |
| 195 |
| 171 void Tab::OnCompositorMessageReceived( | 196 void Tab::OnCompositorMessageReceived( |
| 172 content::RenderWidgetHost* render_widget_host, | 197 content::RenderWidgetHost* render_widget_host, |
| 173 const std::vector<uint8_t>& message) { | 198 const std::vector<uint8_t>& message) { |
| 174 TRACE_EVENT0("blimp", "Tab::OnCompositorMessageReceived"); | 199 TRACE_EVENT0("blimp", "Tab::OnCompositorMessageReceived"); |
| 175 | 200 |
| 176 render_widget_host->HandleCompositorProto(message); | 201 render_widget_host->HandleCompositorProto(message); |
| 177 } | 202 } |
| 178 | 203 |
| 179 } // namespace engine | 204 } // namespace engine |
| 180 } // namespace blimp | 205 } // namespace blimp |
| OLD | NEW |