| 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/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 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 85 bool* auto_setup_scope) { | 85 bool* auto_setup_scope) { |
| 86 return GetBuiltin().Resolver(name, argument_count, auto_setup_scope); | 86 return GetBuiltin().Resolver(name, argument_count, auto_setup_scope); |
| 87 } | 87 } |
| 88 | 88 |
| 89 const uint8_t* Symbolizer(Dart_NativeFunction native_function) { | 89 const uint8_t* Symbolizer(Dart_NativeFunction native_function) { |
| 90 return GetBuiltin().Symbolizer(native_function); | 90 return GetBuiltin().Symbolizer(native_function); |
| 91 } | 91 } |
| 92 | 92 |
| 93 const char kLibraryName[] = "dart:sky.internals"; | 93 const char kLibraryName[] = "dart:sky.internals"; |
| 94 | 94 |
| 95 // When editing this, also update sky/sdk/lib/internals.dart | |
| 96 // so that the analyzer can see it | |
| 97 const char kLibrarySource[] = R"DART( | |
| 98 String contentAsText() native "contentAsText"; | |
| 99 String renderTreeAsText() native "renderTreeAsText"; | |
| 100 void notifyTestComplete(String test_result) native "notifyTestComplete"; | |
| 101 int takeShellProxyHandle() native "takeShellProxyHandle"; | |
| 102 int takeServicesProvidedByEmbedder() native "takeServicesProvidedByEmbedder"; | |
| 103 int takeServicesProvidedToEmbedder() native "takeServicesProvidedToEmbedder"; | |
| 104 int takeServiceRegistry() native "takeServiceRegistry"; | |
| 105 )DART"; | |
| 106 | |
| 107 } // namespace | 95 } // namespace |
| 108 | 96 |
| 109 void Internals::Create(Dart_Isolate isolate, DocumentView* document_view) { | 97 void Internals::Create(Dart_Isolate isolate, DocumentView* document_view) { |
| 110 DartState* state = DartState::From(isolate); | 98 DartState* state = DartState::From(isolate); |
| 111 state->SetUserData(&kInternalsKey, new Internals(document_view)); | 99 state->SetUserData(&kInternalsKey, new Internals(document_view)); |
| 112 Dart_Handle library = | 100 Dart_Handle library = |
| 113 Dart_LoadLibrary(Dart_NewStringFromCString(kLibraryName), | 101 Dart_LookupLibrary(Dart_NewStringFromCString(kLibraryName)); |
| 114 Dart_NewStringFromCString(kLibrarySource), 0, 0); | |
| 115 CHECK(!LogIfError(library)); | 102 CHECK(!LogIfError(library)); |
| 116 CHECK(!LogIfError(Dart_FinalizeLoading(true))); | |
| 117 CHECK(!LogIfError(Dart_SetNativeResolver(library, Resolver, Symbolizer))); | 103 CHECK(!LogIfError(Dart_SetNativeResolver(library, Resolver, Symbolizer))); |
| 118 } | 104 } |
| 119 | 105 |
| 120 Internals::Internals(DocumentView* document_view) | 106 Internals::Internals(DocumentView* document_view) |
| 121 : document_view_(document_view->GetWeakPtr()), | 107 : document_view_(document_view->GetWeakPtr()), |
| 122 shell_binding_(this) { | 108 shell_binding_(this) { |
| 123 test_harness_ = document_view_->TakeTestHarness(); | 109 test_harness_ = document_view_->TakeTestHarness(); |
| 124 } | 110 } |
| 125 | 111 |
| 126 Internals::~Internals() { | 112 Internals::~Internals() { |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 182 const mojo::String& application_url, | 168 const mojo::String& application_url, |
| 183 mojo::InterfaceRequest<mojo::ServiceProvider> services, | 169 mojo::InterfaceRequest<mojo::ServiceProvider> services, |
| 184 mojo::ServiceProviderPtr exposed_services) { | 170 mojo::ServiceProviderPtr exposed_services) { |
| 185 if (document_view_) { | 171 if (document_view_) { |
| 186 document_view_->shell()->ConnectToApplication( | 172 document_view_->shell()->ConnectToApplication( |
| 187 application_url, services.Pass(), exposed_services.Pass()); | 173 application_url, services.Pass(), exposed_services.Pass()); |
| 188 } | 174 } |
| 189 } | 175 } |
| 190 | 176 |
| 191 } // namespace sky | 177 } // namespace sky |
| OLD | NEW |