Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(359)

Side by Side Diff: sky/viewer/internals.cc

Issue 948943002: Gets HTMLIFrameElement::embedViewManagerClient to work with dart (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: feedback Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « sky/viewer/internals.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/engine/config.h" 5 #include "sky/engine/config.h"
6 #include "sky/viewer/internals.h" 6 #include "sky/viewer/internals.h"
7 7
8 #include "mojo/public/cpp/application/connect.h" 8 #include "mojo/public/cpp/application/connect.h"
9 #include "mojo/public/cpp/bindings/array.h" 9 #include "mojo/public/cpp/bindings/array.h"
10 #include "sky/engine/public/web/WebDocument.h" 10 #include "sky/engine/public/web/WebDocument.h"
(...skipping 11 matching lines...) Expand all
22 namespace sky { 22 namespace sky {
23 namespace { 23 namespace {
24 24
25 int kInternalsKey = 0; 25 int kInternalsKey = 0;
26 26
27 Internals* GetInternals() { 27 Internals* GetInternals() {
28 DartState* state = DartState::Current(); 28 DartState* state = DartState::Current();
29 return static_cast<Internals*>(state->GetUserData(&kInternalsKey)); 29 return static_cast<Internals*>(state->GetUserData(&kInternalsKey));
30 } 30 }
31 31
32 void RenderTreeAsText(Dart_NativeArguments args) {
33 Dart_Handle result = StdStringToDart(GetInternals()->RenderTreeAsText());
34 Dart_SetReturnValue(args, result);
35 }
36
37 void ContentAsText(Dart_NativeArguments args) { 32 void ContentAsText(Dart_NativeArguments args) {
38 Dart_Handle result = StdStringToDart(GetInternals()->ContentAsText()); 33 Dart_Handle result = StdStringToDart(GetInternals()->ContentAsText());
39 Dart_SetReturnValue(args, result); 34 Dart_SetReturnValue(args, result);
40 } 35 }
41 36
42 void NotifyTestComplete(Dart_NativeArguments args) { 37 void NotifyTestComplete(Dart_NativeArguments args) {
43 Dart_Handle test_result = Dart_GetNativeArgument(args, 0); 38 Dart_Handle test_result = Dart_GetNativeArgument(args, 0);
44 GetInternals()->NotifyTestComplete(StdStringFromDart(test_result)); 39 GetInternals()->NotifyTestComplete(StdStringFromDart(test_result));
45 } 40 }
46 41
42 void RenderTreeAsText(Dart_NativeArguments args) {
43 Dart_Handle result = StdStringToDart(GetInternals()->RenderTreeAsText());
44 Dart_SetReturnValue(args, result);
45 }
46
47 void TakeShellProxyHandle(Dart_NativeArguments args) { 47 void TakeShellProxyHandle(Dart_NativeArguments args) {
48 Dart_SetIntegerReturnValue(args, 48 Dart_SetIntegerReturnValue(args,
49 GetInternals()->TakeShellProxyHandle().value()); 49 GetInternals()->TakeShellProxyHandle().value());
50 } 50 }
51 51
52 void TakeServicesProvidedToEmbedder(Dart_NativeArguments args) { 52 void TakeServicesProvidedByEmbedder(Dart_NativeArguments args) {
53 Dart_SetIntegerReturnValue(args, 53 Dart_SetIntegerReturnValue(
54 GetInternals()->TakeServicesProvidedToEmbedder().value()); 54 args, GetInternals()->TakeServicesProvidedByEmbedder().value());
55 } 55 }
56 56
57 void TakeServicesProvidedByEmbedder(Dart_NativeArguments args) { 57 void TakeServicesProvidedToEmbedder(Dart_NativeArguments args) {
58 Dart_SetIntegerReturnValue(args, 58 Dart_SetIntegerReturnValue(
59 GetInternals()->TakeServicesProvidedByEmbedder().value()); 59 args, GetInternals()->TakeServicesProvidedToEmbedder().value());
60 } 60 }
61 61
62 const DartBuiltin::Natives kNativeFunctions[] = { 62 const DartBuiltin::Natives kNativeFunctions[] = {
63 {"renderTreeAsText", RenderTreeAsText, 0}, 63 {"contentAsText", ContentAsText, 0},
64 {"contentAsText", ContentAsText, 0}, 64 {"notifyTestComplete", NotifyTestComplete, 1},
65 {"notifyTestComplete", NotifyTestComplete, 1}, 65 {"renderTreeAsText", RenderTreeAsText, 0},
66 {"takeShellProxyHandle", TakeShellProxyHandle, 0}, 66 {"takeShellProxyHandle", TakeShellProxyHandle, 0},
67 {"takeServicesProvidedToEmbedder", TakeServicesProvidedToEmbedder, 0}, 67 {"takeServicesProvidedByEmbedder", TakeServicesProvidedByEmbedder, 0},
68 {"takeServicesProvidedByEmbedder", TakeServicesProvidedByEmbedder, 0}, 68 {"takeServicesProvidedToEmbedder", TakeServicesProvidedToEmbedder, 0},
69 }; 69 };
70 70
71 const DartBuiltin& GetBuiltin() { 71 const DartBuiltin& GetBuiltin() {
72 static DartBuiltin& builtin = *new DartBuiltin(kNativeFunctions, 72 static DartBuiltin& builtin = *new DartBuiltin(kNativeFunctions,
73 arraysize(kNativeFunctions)); 73 arraysize(kNativeFunctions));
74 return builtin; 74 return builtin;
75 } 75 }
76 76
77 Dart_NativeFunction Resolver(Dart_Handle name, 77 Dart_NativeFunction Resolver(Dart_Handle name,
78 int argument_count, 78 int argument_count,
79 bool* auto_setup_scope) { 79 bool* auto_setup_scope) {
80 return GetBuiltin().Resolver(name, argument_count, auto_setup_scope); 80 return GetBuiltin().Resolver(name, argument_count, auto_setup_scope);
81 } 81 }
82 82
83 const uint8_t* Symbolizer(Dart_NativeFunction native_function) { 83 const uint8_t* Symbolizer(Dart_NativeFunction native_function) {
84 return GetBuiltin().Symbolizer(native_function); 84 return GetBuiltin().Symbolizer(native_function);
85 } 85 }
86 86
87 const char kLibraryName[] = "dart:sky.internals"; 87 const char kLibraryName[] = "dart:sky.internals";
88 const char kLibrarySource[] = R"DART( 88 const char kLibrarySource[] = R"DART(
89 String renderTreeAsText() native "renderTreeAsText";
90 String contentAsText() native "contentAsText"; 89 String contentAsText() native "contentAsText";
91 void notifyTestComplete(String test_result) native "notifyTestComplete"; 90 void notifyTestComplete(String test_result) native "notifyTestComplete";
91 String renderTreeAsText() native "renderTreeAsText";
92 int takeShellProxyHandle() native "takeShellProxyHandle"; 92 int takeShellProxyHandle() native "takeShellProxyHandle";
93 int takeServicesProvidedByEmbedder() native "takeServicesProvidedByEmbedder";
93 int takeServicesProvidedToEmbedder() native "takeServicesProvidedToEmbedder"; 94 int takeServicesProvidedToEmbedder() native "takeServicesProvidedToEmbedder";
94 int takeServicesProvidedByEmbedder() native "takeServicesProvidedByEmbedder";
95 )DART"; 95 )DART";
96 96
97 } // namespace 97 } // namespace
98 98
99 void Internals::Create(Dart_Isolate isolate, DocumentView* document_view) { 99 void Internals::Create(Dart_Isolate isolate, DocumentView* document_view) {
100 DartState* state = DartState::From(isolate); 100 DartState* state = DartState::From(isolate);
101 state->SetUserData(&kInternalsKey, new Internals(document_view)); 101 state->SetUserData(&kInternalsKey, new Internals(document_view));
102 Dart_Handle library = 102 Dart_Handle library =
103 Dart_LoadLibrary(Dart_NewStringFromCString(kLibraryName), 103 Dart_LoadLibrary(Dart_NewStringFromCString(kLibraryName),
104 Dart_NewStringFromCString(kLibrarySource), 0, 0); 104 Dart_NewStringFromCString(kLibrarySource), 0, 0);
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
165 void Internals::ConnectToApplication( 165 void Internals::ConnectToApplication(
166 const mojo::String& application_url, 166 const mojo::String& application_url,
167 mojo::InterfaceRequest<mojo::ServiceProvider> services, 167 mojo::InterfaceRequest<mojo::ServiceProvider> services,
168 mojo::ServiceProviderPtr exposed_services) { 168 mojo::ServiceProviderPtr exposed_services) {
169 if (document_view_) { 169 if (document_view_) {
170 document_view_->shell()->ConnectToApplication( 170 document_view_->shell()->ConnectToApplication(
171 application_url, services.Pass(), exposed_services.Pass()); 171 application_url, services.Pass(), exposed_services.Pass());
172 } 172 }
173 } 173 }
174 174
175 mojo::Handle Internals::ConnectToService(
176 const std::string& application_url, const std::string& interface_name) {
177 if (!document_view_)
178 return mojo::Handle();
179
180 mojo::ServiceProviderPtr service_provider;
181 ConnectToApplication(application_url, mojo::GetProxy(&service_provider),
182 nullptr);
183
184 mojo::MessagePipe pipe;
185 service_provider->ConnectToService(interface_name, pipe.handle1.Pass());
186 return pipe.handle0.release();
187 }
188
189 void Internals::pauseAnimations(double pauseTime) { 175 void Internals::pauseAnimations(double pauseTime) {
190 if (pauseTime < 0) 176 if (pauseTime < 0)
191 return; 177 return;
192 178
193 document_view_->web_view()->mainFrame()->document().pauseAnimationsForTestin g(pauseTime); 179 document_view_->web_view()->mainFrame()->document().pauseAnimationsForTestin g(pauseTime);
194 } 180 }
195 181
196 } // namespace sky 182 } // namespace sky
OLDNEW
« no previous file with comments | « sky/viewer/internals.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698