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 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
117 Load(response_.Pass()); | 117 Load(response_.Pass()); |
118 | 118 |
119 auto& bounds = root_->bounds(); | 119 auto& bounds = root_->bounds(); |
120 float device_pixel_ratio = GetDevicePixelRatio(); | 120 float device_pixel_ratio = GetDevicePixelRatio(); |
121 web_view_->resize(blink::WebSize(bounds.width / device_pixel_ratio, | 121 web_view_->resize(blink::WebSize(bounds.width / device_pixel_ratio, |
122 bounds.height / device_pixel_ratio)); | 122 bounds.height / device_pixel_ratio)); |
123 | 123 |
124 // TODO(abarth): We should ask the view whether it is focused instead of | 124 // TODO(abarth): We should ask the view whether it is focused instead of |
125 // assuming that we're focused. | 125 // assuming that we're focused. |
126 web_view_->setFocus(true); | 126 web_view_->setFocus(true); |
| 127 // Needed on android, as the window does not get the focus otherwise. |
| 128 root_->SetFocus(); |
127 root_->AddObserver(this); | 129 root_->AddObserver(this); |
128 } | 130 } |
129 | 131 |
130 void DocumentView::OnViewManagerDisconnected(mojo::ViewManager* view_manager) { | 132 void DocumentView::OnViewManagerDisconnected(mojo::ViewManager* view_manager) { |
131 // TODO(aa): Need to figure out how shutdown works. | 133 // TODO(aa): Need to figure out how shutdown works. |
132 } | 134 } |
133 | 135 |
134 void DocumentView::Load(mojo::URLResponsePtr response) { | 136 void DocumentView::Load(mojo::URLResponsePtr response) { |
135 web_view_ = blink::WebView::create(this); | 137 web_view_ = blink::WebView::create(this); |
136 ConfigureSettings(web_view_->settings()); | 138 ConfigureSettings(web_view_->settings()); |
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
318 void DocumentView::StartDebuggerInspectorBackend() { | 320 void DocumentView::StartDebuggerInspectorBackend() { |
319 if (!inspector_backend_) { | 321 if (!inspector_backend_) { |
320 inspector_host_.reset(new InspectorHostImpl(web_view_, shell_)); | 322 inspector_host_.reset(new InspectorHostImpl(web_view_, shell_)); |
321 inspector_backend_.reset( | 323 inspector_backend_.reset( |
322 new inspector::InspectorBackendMojo(inspector_host_.get())); | 324 new inspector::InspectorBackendMojo(inspector_host_.get())); |
323 } | 325 } |
324 inspector_backend_->Connect(); | 326 inspector_backend_->Connect(); |
325 } | 327 } |
326 | 328 |
327 } // namespace sky | 329 } // namespace sky |
OLD | NEW |