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/internals.h" | 5 #include "sky/viewer/internals.h" |
6 | 6 |
7 #include "mojo/edk/js/core.h" | 7 #include "mojo/edk/js/core.h" |
8 #include "mojo/edk/js/handle.h" | 8 #include "mojo/edk/js/handle.h" |
9 #include "mojo/edk/js/support.h" | 9 #include "mojo/edk/js/support.h" |
10 #include "mojo/public/cpp/application/connect.h" | 10 #include "mojo/public/cpp/application/connect.h" |
11 #include "mojo/public/interfaces/application/shell.mojom.h" | 11 #include "mojo/public/interfaces/application/shell.mojom.h" |
| 12 #include "sky/engine/public/web/WebDocument.h" |
12 #include "sky/engine/public/web/WebFrame.h" | 13 #include "sky/engine/public/web/WebFrame.h" |
13 #include "sky/engine/public/web/WebView.h" | 14 #include "sky/engine/public/web/WebView.h" |
14 #include "sky/viewer/document_view.h" | 15 #include "sky/viewer/document_view.h" |
15 #include "v8/include/v8.h" | 16 #include "v8/include/v8.h" |
16 #include <limits> | 17 #include <limits> |
17 | 18 |
18 namespace sky { | 19 namespace sky { |
19 | 20 |
20 gin::WrapperInfo Internals::kWrapperInfo = {gin::kEmbedderNativeGin}; | 21 gin::WrapperInfo Internals::kWrapperInfo = {gin::kEmbedderNativeGin}; |
21 | 22 |
(...skipping 17 matching lines...) Expand all Loading... |
39 | 40 |
40 Internals::~Internals() { | 41 Internals::~Internals() { |
41 } | 42 } |
42 | 43 |
43 gin::ObjectTemplateBuilder Internals::GetObjectTemplateBuilder( | 44 gin::ObjectTemplateBuilder Internals::GetObjectTemplateBuilder( |
44 v8::Isolate* isolate) { | 45 v8::Isolate* isolate) { |
45 return Wrappable<Internals>::GetObjectTemplateBuilder(isolate) | 46 return Wrappable<Internals>::GetObjectTemplateBuilder(isolate) |
46 .SetMethod("renderTreeAsText", &Internals::RenderTreeAsText) | 47 .SetMethod("renderTreeAsText", &Internals::RenderTreeAsText) |
47 .SetMethod("contentAsText", &Internals::ContentAsText) | 48 .SetMethod("contentAsText", &Internals::ContentAsText) |
48 .SetMethod("notifyTestComplete", &Internals::NotifyTestComplete) | 49 .SetMethod("notifyTestComplete", &Internals::NotifyTestComplete) |
49 .SetMethod("connectToService", &Internals::ConnectToService); | 50 .SetMethod("connectToService", &Internals::ConnectToService) |
| 51 .SetMethod("pauseAnimations", &Internals::pauseAnimations); |
50 } | 52 } |
51 | 53 |
52 std::string Internals::RenderTreeAsText() { | 54 std::string Internals::RenderTreeAsText() { |
53 if (!document_view_) | 55 if (!document_view_) |
54 return std::string(); | 56 return std::string(); |
55 return document_view_->web_view()->mainFrame()->renderTreeAsText().utf8(); | 57 return document_view_->web_view()->mainFrame()->renderTreeAsText().utf8(); |
56 } | 58 } |
57 | 59 |
58 std::string Internals::ContentAsText() { | 60 std::string Internals::ContentAsText() { |
59 if (!document_view_) | 61 if (!document_view_) |
(...skipping 13 matching lines...) Expand all Loading... |
73 | 75 |
74 mojo::ServiceProviderPtr service_provider; | 76 mojo::ServiceProviderPtr service_provider; |
75 document_view_->shell()->ConnectToApplication( | 77 document_view_->shell()->ConnectToApplication( |
76 application_url, mojo::GetProxy(&service_provider)); | 78 application_url, mojo::GetProxy(&service_provider)); |
77 | 79 |
78 mojo::MessagePipe pipe; | 80 mojo::MessagePipe pipe; |
79 service_provider->ConnectToService(interface_name, pipe.handle1.Pass()); | 81 service_provider->ConnectToService(interface_name, pipe.handle1.Pass()); |
80 return pipe.handle0.release(); | 82 return pipe.handle0.release(); |
81 } | 83 } |
82 | 84 |
| 85 void Internals::pauseAnimations(double pauseTime) { |
| 86 if (pauseTime < 0) |
| 87 return; |
| 88 |
| 89 document_view_->web_view()->mainFrame()->document().pauseAnimationsForTestin
g(pauseTime); |
| 90 } |
| 91 |
83 } // namespace sky | 92 } // namespace sky |
OLD | NEW |