| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "sky/viewer/document_view.h" | 5 #include "sky/viewer/document_view.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/location.h" | 8 #include "base/location.h" |
| 9 #include "base/message_loop/message_loop_proxy.h" | 9 #include "base/message_loop/message_loop_proxy.h" |
| 10 #include "base/single_thread_task_runner.h" | 10 #include "base/single_thread_task_runner.h" |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 144 shell_->ConnectToApplication("mojo:native_viewport_service", | 144 shell_->ConnectToApplication("mojo:native_viewport_service", |
| 145 mojo::GetProxy(&gpu_service_provider)); | 145 mojo::GetProxy(&gpu_service_provider)); |
| 146 mojo::InterfacePtr<mojo::Gpu> gpu_service; | 146 mojo::InterfacePtr<mojo::Gpu> gpu_service; |
| 147 mojo::ConnectToService(gpu_service_provider.get(), &gpu_service); | 147 mojo::ConnectToService(gpu_service_provider.get(), &gpu_service); |
| 148 web_layer_tree_view_impl_.reset(new WebLayerTreeViewImpl( | 148 web_layer_tree_view_impl_.reset(new WebLayerTreeViewImpl( |
| 149 compositor_thread_, surfaces_service.Pass(), gpu_service.Pass())); | 149 compositor_thread_, surfaces_service.Pass(), gpu_service.Pass())); |
| 150 | 150 |
| 151 return web_layer_tree_view_impl_.get(); | 151 return web_layer_tree_view_impl_.get(); |
| 152 } | 152 } |
| 153 | 153 |
| 154 void DocumentView::createChildView(const blink::WebURL& url) { |
| 155 if (!root_) |
| 156 return; |
| 157 |
| 158 mojo::View* child = mojo::View::Create(root_->view_manager()); |
| 159 root_->AddChild(child); |
| 160 // TODO(mpcomplete): actual bounds. |
| 161 mojo::Rect mojo_bounds; |
| 162 mojo_bounds.x = 50; |
| 163 mojo_bounds.y = 50; |
| 164 mojo_bounds.width = 50; |
| 165 mojo_bounds.height = 50; |
| 166 child->SetBounds(mojo_bounds); |
| 167 child->Embed(mojo::String::From(url.string().utf8())); |
| 168 } |
| 169 |
| 154 void DocumentView::frameDetached(blink::WebFrame* frame) { | 170 void DocumentView::frameDetached(blink::WebFrame* frame) { |
| 155 // |frame| is invalid after here. | 171 // |frame| is invalid after here. |
| 156 frame->close(); | 172 frame->close(); |
| 157 } | 173 } |
| 158 | 174 |
| 159 blink::WebNavigationPolicy DocumentView::decidePolicyForNavigation( | 175 blink::WebNavigationPolicy DocumentView::decidePolicyForNavigation( |
| 160 const blink::WebFrameClient::NavigationPolicyInfo& info) { | 176 const blink::WebFrameClient::NavigationPolicyInfo& info) { |
| 161 | 177 |
| 162 navigator_host_->RequestNavigate( | 178 navigator_host_->RequestNavigate( |
| 163 WebNavigationPolicyToNavigationTarget(info.defaultPolicy), | 179 WebNavigationPolicyToNavigationTarget(info.defaultPolicy), |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 199 const mojo::Rect& old_bounds, | 215 const mojo::Rect& old_bounds, |
| 200 const mojo::Rect& new_bounds) { | 216 const mojo::Rect& new_bounds) { |
| 201 DCHECK_EQ(view, root_); | 217 DCHECK_EQ(view, root_); |
| 202 gfx::Size size = new_bounds.To<gfx::Rect>().size(); | 218 gfx::Size size = new_bounds.To<gfx::Rect>().size(); |
| 203 web_view_->resize(size); | 219 web_view_->resize(size); |
| 204 web_layer_tree_view_impl_->setViewportSize(size); | 220 web_layer_tree_view_impl_->setViewportSize(size); |
| 205 } | 221 } |
| 206 | 222 |
| 207 void DocumentView::OnViewDestroyed(mojo::View* view) { | 223 void DocumentView::OnViewDestroyed(mojo::View* view) { |
| 208 DCHECK_EQ(view, root_); | 224 DCHECK_EQ(view, root_); |
| 225 |
| 226 for (auto& child : root_->children()) |
| 227 child->Destroy(); |
| 228 |
| 209 delete this; | 229 delete this; |
| 210 } | 230 } |
| 211 | 231 |
| 212 void DocumentView::OnViewInputEvent( | 232 void DocumentView::OnViewInputEvent( |
| 213 mojo::View* view, const mojo::EventPtr& event) { | 233 mojo::View* view, const mojo::EventPtr& event) { |
| 214 scoped_ptr<blink::WebInputEvent> web_event = | 234 scoped_ptr<blink::WebInputEvent> web_event = |
| 215 event.To<scoped_ptr<blink::WebInputEvent> >(); | 235 event.To<scoped_ptr<blink::WebInputEvent> >(); |
| 216 if (web_event) | 236 if (web_event) |
| 217 web_view_->handleInputEvent(*web_event); | 237 web_view_->handleInputEvent(*web_event); |
| 218 } | 238 } |
| 219 | 239 |
| 220 } // namespace sky | 240 } // namespace sky |
| OLD | NEW |