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" |
(...skipping 24 matching lines...) Expand all Loading... |
35 navigation_message_sender_(navigation_message_sender), | 35 navigation_message_sender_(navigation_message_sender), |
36 page_load_tracker_(web_contents_.get(), this) { | 36 page_load_tracker_(web_contents_.get(), this) { |
37 DCHECK(render_widget_feature_); | 37 DCHECK(render_widget_feature_); |
38 DCHECK(navigation_message_sender_); | 38 DCHECK(navigation_message_sender_); |
39 | 39 |
40 // A Tab is created upon client's request, thus an updated | 40 // A Tab is created upon client's request, thus an updated |
41 // user agent info (containing client OS info) is available, and we will use | 41 // user agent info (containing client OS info) is available, and we will use |
42 // that to override user agent string from BlimpContentRendererClient. | 42 // that to override user agent string from BlimpContentRendererClient. |
43 web_contents_->SetUserAgentOverride(GetBlimpEngineUserAgent()); | 43 web_contents_->SetUserAgentOverride(GetBlimpEngineUserAgent()); |
44 | 44 |
| 45 render_widget_feature_->SetDelegate(tab_id_, this); |
| 46 |
45 Observe(web_contents_.get()); | 47 Observe(web_contents_.get()); |
46 } | 48 } |
47 | 49 |
48 Tab::~Tab() {} | 50 Tab::~Tab() { |
| 51 render_widget_feature_->RemoveDelegate(tab_id_); |
| 52 } |
49 | 53 |
50 void Tab::Resize(float device_pixel_ratio, const gfx::Size& size_in_dips) { | 54 void Tab::Resize(float device_pixel_ratio, const gfx::Size& size_in_dips) { |
51 DVLOG(1) << "Resize to " << size_in_dips.ToString() << ", " | 55 DVLOG(1) << "Resize to " << size_in_dips.ToString() << ", " |
52 << device_pixel_ratio; | 56 << device_pixel_ratio; |
53 web_contents_->GetNativeView()->SetBounds(gfx::Rect(size_in_dips)); | 57 web_contents_->GetNativeView()->SetBounds(gfx::Rect(size_in_dips)); |
54 | 58 |
55 if (web_contents_->GetRenderViewHost() && | 59 if (web_contents_->GetRenderViewHost() && |
56 web_contents_->GetRenderViewHost()->GetWidget()) { | 60 web_contents_->GetRenderViewHost()->GetWidget()) { |
57 web_contents_->GetRenderViewHost()->GetWidget()->WasResized(); | 61 web_contents_->GetRenderViewHost()->GetWidget()->WasResized(); |
58 } | 62 } |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
147 std::unique_ptr<BlimpMessage> message = | 151 std::unique_ptr<BlimpMessage> message = |
148 CreateBlimpMessage(&navigation_message, tab_id_); | 152 CreateBlimpMessage(&navigation_message, tab_id_); |
149 navigation_message->set_type(NavigationMessage::NAVIGATION_STATE_CHANGED); | 153 navigation_message->set_type(NavigationMessage::NAVIGATION_STATE_CHANGED); |
150 navigation_message->mutable_navigation_state_changed() | 154 navigation_message->mutable_navigation_state_changed() |
151 ->set_page_load_completed(load_status == PageLoadStatus::LOADED); | 155 ->set_page_load_completed(load_status == PageLoadStatus::LOADED); |
152 | 156 |
153 navigation_message_sender_->ProcessMessage(std::move(message), | 157 navigation_message_sender_->ProcessMessage(std::move(message), |
154 net::CompletionCallback()); | 158 net::CompletionCallback()); |
155 } | 159 } |
156 | 160 |
| 161 void Tab::OnWebGestureEvent(content::RenderWidgetHost* render_widget_host, |
| 162 std::unique_ptr<blink::WebGestureEvent> event) { |
| 163 TRACE_EVENT1("blimp", "Tab::OnWebGestureEvent", "type", event->type); |
| 164 render_widget_host->ForwardGestureEvent(*event); |
| 165 } |
| 166 |
| 167 void Tab::OnCompositorMessageReceived( |
| 168 content::RenderWidgetHost* render_widget_host, |
| 169 const std::vector<uint8_t>& message) { |
| 170 TRACE_EVENT0("blimp", "Tab::OnCompositorMessageReceived"); |
| 171 |
| 172 render_widget_host->HandleCompositorProto(message); |
| 173 } |
| 174 |
157 } // namespace engine | 175 } // namespace engine |
158 } // namespace blimp | 176 } // namespace blimp |
OLD | NEW |