| 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" |
| 11 #include "base/strings/string_util.h" | 11 #include "base/strings/string_util.h" |
| 12 #include "base/thread_task_runner_handle.h" | 12 #include "base/thread_task_runner_handle.h" |
| 13 #include "mojo/converters/geometry/geometry_type_converters.h" | 13 #include "mojo/converters/geometry/geometry_type_converters.h" |
| 14 #include "mojo/public/cpp/application/connect.h" | 14 #include "mojo/public/cpp/application/connect.h" |
| 15 #include "mojo/public/cpp/system/data_pipe.h" | 15 #include "mojo/public/cpp/system/data_pipe.h" |
| 16 #include "mojo/public/interfaces/application/shell.mojom.h" | 16 #include "mojo/public/interfaces/application/shell.mojom.h" |
| 17 #include "mojo/services/public/cpp/view_manager/view.h" | 17 #include "mojo/services/public/cpp/view_manager/view.h" |
| 18 #include "mojo/services/public/interfaces/surfaces/surfaces_service.mojom.h" | 18 #include "mojo/services/public/interfaces/surfaces/surfaces_service.mojom.h" |
| 19 #include "skia/ext/refptr.h" | 19 #include "skia/ext/refptr.h" |
| 20 #include "sky/engine/public/platform/Platform.h" | 20 #include "sky/engine/public/platform/Platform.h" |
| 21 #include "sky/engine/public/platform/WebHTTPHeaderVisitor.h" | 21 #include "sky/engine/public/platform/WebHTTPHeaderVisitor.h" |
| 22 #include "sky/engine/public/web/Sky.h" |
| 22 #include "sky/engine/public/web/WebConsoleMessage.h" | 23 #include "sky/engine/public/web/WebConsoleMessage.h" |
| 23 #include "sky/engine/public/web/WebDocument.h" | 24 #include "sky/engine/public/web/WebDocument.h" |
| 24 #include "sky/engine/public/web/WebElement.h" | 25 #include "sky/engine/public/web/WebElement.h" |
| 25 #include "sky/engine/public/web/WebInputEvent.h" | 26 #include "sky/engine/public/web/WebInputEvent.h" |
| 26 #include "sky/engine/public/web/WebLocalFrame.h" | 27 #include "sky/engine/public/web/WebLocalFrame.h" |
| 27 #include "sky/engine/public/web/WebScriptSource.h" | 28 #include "sky/engine/public/web/WebScriptSource.h" |
| 28 #include "sky/engine/public/web/WebSettings.h" | 29 #include "sky/engine/public/web/WebSettings.h" |
| 29 #include "sky/engine/public/web/WebView.h" | 30 #include "sky/engine/public/web/WebView.h" |
| 31 #include "sky/engine/v8_inspector/inspector_backend_mojo.h" |
| 32 #include "sky/engine/v8_inspector/inspector_host.h" |
| 30 #include "sky/viewer/converters/input_event_types.h" | 33 #include "sky/viewer/converters/input_event_types.h" |
| 31 #include "sky/viewer/converters/url_request_types.h" | 34 #include "sky/viewer/converters/url_request_types.h" |
| 32 #include "sky/viewer/internals.h" | 35 #include "sky/viewer/internals.h" |
| 33 #include "sky/viewer/platform/weblayertreeview_impl.h" | 36 #include "sky/viewer/platform/weblayertreeview_impl.h" |
| 34 #include "sky/viewer/platform/weburlloader_impl.h" | 37 #include "sky/viewer/platform/weburlloader_impl.h" |
| 35 #include "sky/viewer/script/script_runner.h" | 38 #include "sky/viewer/script/script_runner.h" |
| 36 #include "third_party/skia/include/core/SkCanvas.h" | 39 #include "third_party/skia/include/core/SkCanvas.h" |
| 37 #include "third_party/skia/include/core/SkColor.h" | 40 #include "third_party/skia/include/core/SkColor.h" |
| 38 #include "third_party/skia/include/core/SkDevice.h" | 41 #include "third_party/skia/include/core/SkDevice.h" |
| 39 #include "v8/include/v8.h" | 42 #include "v8/include/v8.h" |
| (...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 246 } | 249 } |
| 247 | 250 |
| 248 void DocumentView::OnViewInputEvent( | 251 void DocumentView::OnViewInputEvent( |
| 249 mojo::View* view, const mojo::EventPtr& event) { | 252 mojo::View* view, const mojo::EventPtr& event) { |
| 250 scoped_ptr<blink::WebInputEvent> web_event = | 253 scoped_ptr<blink::WebInputEvent> web_event = |
| 251 event.To<scoped_ptr<blink::WebInputEvent> >(); | 254 event.To<scoped_ptr<blink::WebInputEvent> >(); |
| 252 if (web_event) | 255 if (web_event) |
| 253 web_view_->handleInputEvent(*web_event); | 256 web_view_->handleInputEvent(*web_event); |
| 254 } | 257 } |
| 255 | 258 |
| 259 class InspectorHostImpl : public inspector::InspectorHost { |
| 260 public: |
| 261 InspectorHostImpl(blink::WebView* web_view, mojo::Shell* shell) |
| 262 : web_view_(web_view), shell_(shell) {} |
| 263 |
| 264 virtual ~InspectorHostImpl() {} |
| 265 |
| 266 mojo::Shell* GetShell() override { return shell_; } |
| 267 v8::Isolate* GetIsolate() override { return blink::mainThreadIsolate(); } |
| 268 v8::Local<v8::Context> GetContext() override { |
| 269 return web_view_->mainFrame()->mainWorldScriptContext(); |
| 270 } |
| 271 |
| 272 private: |
| 273 blink::WebView* web_view_; |
| 274 mojo::Shell* shell_; |
| 275 }; |
| 276 |
| 277 void DocumentView::StartDebuggerInspectorBackend() { |
| 278 if (!inspector_backend_) { |
| 279 inspector_host_.reset(new InspectorHostImpl(web_view_, shell_.get())); |
| 280 inspector_backend_.reset( |
| 281 new inspector::InspectorBackendMojo(inspector_host_.get())); |
| 282 } |
| 283 inspector_backend_->Connect(); |
| 284 } |
| 285 |
| 256 } // namespace sky | 286 } // namespace sky |
| OLD | NEW |