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 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
74 } // namespace | 74 } // namespace |
75 | 75 |
76 static int s_next_debugger_id = 1; | 76 static int s_next_debugger_id = 1; |
77 | 77 |
78 DocumentView::DocumentView( | 78 DocumentView::DocumentView( |
79 mojo::InterfaceRequest<mojo::ServiceProvider> services, | 79 mojo::InterfaceRequest<mojo::ServiceProvider> services, |
80 mojo::ServiceProviderPtr exported_services, | 80 mojo::ServiceProviderPtr exported_services, |
81 mojo::URLResponsePtr response, | 81 mojo::URLResponsePtr response, |
82 mojo::Shell* shell) | 82 mojo::Shell* shell) |
83 : response_(response.Pass()), | 83 : response_(response.Pass()), |
| 84 exported_services_(services.Pass()), |
84 shell_(shell), | 85 shell_(shell), |
85 web_view_(nullptr), | 86 web_view_(nullptr), |
86 root_(nullptr), | 87 root_(nullptr), |
87 view_manager_client_factory_(shell_, this), | 88 view_manager_client_factory_(shell_, this), |
88 inspector_service_factory_(this), | 89 inspector_service_factory_(this), |
89 bitmap_rasterizer_(nullptr), | 90 bitmap_rasterizer_(nullptr), |
90 debugger_id_(s_next_debugger_id++), | 91 debugger_id_(s_next_debugger_id++), |
91 weak_factory_(this) { | 92 weak_factory_(this) { |
92 // TODO(jamesr): Is this right? | |
93 exported_services_.AddService(&view_manager_client_factory_); | 93 exported_services_.AddService(&view_manager_client_factory_); |
94 mojo::WeakBindToPipe(&exported_services_, services.PassMessagePipe()); | 94 inspector_service_provider_impl_.AddService(&inspector_service_factory_); |
95 } | 95 } |
96 | 96 |
97 DocumentView::~DocumentView() { | 97 DocumentView::~DocumentView() { |
98 if (web_view_) | 98 if (web_view_) |
99 web_view_->close(); | 99 web_view_->close(); |
100 if (root_) | 100 if (root_) |
101 root_->RemoveObserver(this); | 101 root_->RemoveObserver(this); |
102 } | 102 } |
103 | 103 |
104 base::WeakPtr<DocumentView> DocumentView::GetWeakPtr() { | 104 base::WeakPtr<DocumentView> DocumentView::GetWeakPtr() { |
105 return weak_factory_.GetWeakPtr(); | 105 return weak_factory_.GetWeakPtr(); |
106 } | 106 } |
107 | 107 |
108 void DocumentView::OnEmbed( | 108 void DocumentView::OnEmbed( |
109 mojo::View* root, | 109 mojo::View* root, |
110 mojo::ServiceProviderImpl* exported_services, | 110 mojo::InterfaceRequest<mojo::ServiceProvider> services, |
111 scoped_ptr<mojo::ServiceProvider> imported_services) { | 111 mojo::ServiceProviderPtr exposed_services) { |
112 root_ = root; | 112 root_ = root; |
113 imported_services_ = imported_services.Pass(); | 113 imported_services_ = exposed_services.Pass(); |
114 navigator_host_.set_service_provider(imported_services_.get()); | 114 navigator_host_.set_service_provider(imported_services_.get()); |
115 exported_services->AddService(&inspector_service_factory_); | 115 |
| 116 if (services.is_pending()) |
| 117 inspector_service_provider_impl_.Bind(services.Pass()); |
116 | 118 |
117 Load(response_.Pass()); | 119 Load(response_.Pass()); |
118 | 120 |
119 auto& bounds = root_->bounds(); | 121 auto& bounds = root_->bounds(); |
120 float device_pixel_ratio = GetDevicePixelRatio(); | 122 float device_pixel_ratio = GetDevicePixelRatio(); |
121 web_view_->resize(blink::WebSize(bounds.width / device_pixel_ratio, | 123 web_view_->resize(blink::WebSize(bounds.width / device_pixel_ratio, |
122 bounds.height / device_pixel_ratio)); | 124 bounds.height / device_pixel_ratio)); |
123 | 125 |
124 // TODO(abarth): We should ask the view whether it is focused instead of | 126 // TODO(abarth): We should ask the view whether it is focused instead of |
125 // assuming that we're focused. | 127 // assuming that we're focused. |
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
316 void DocumentView::StartDebuggerInspectorBackend() { | 318 void DocumentView::StartDebuggerInspectorBackend() { |
317 if (!inspector_backend_) { | 319 if (!inspector_backend_) { |
318 inspector_host_.reset(new InspectorHostImpl(web_view_, shell_)); | 320 inspector_host_.reset(new InspectorHostImpl(web_view_, shell_)); |
319 inspector_backend_.reset( | 321 inspector_backend_.reset( |
320 new inspector::InspectorBackendMojo(inspector_host_.get())); | 322 new inspector::InspectorBackendMojo(inspector_host_.get())); |
321 } | 323 } |
322 inspector_backend_->Connect(); | 324 inspector_backend_->Connect(); |
323 } | 325 } |
324 | 326 |
325 } // namespace sky | 327 } // namespace sky |
OLD | NEW |