| 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/public/cpp/application/connect.h" | 7 #include "mojo/public/cpp/application/connect.h" |
| 8 #include "mojo/public/cpp/bindings/array.h" | 8 #include "mojo/public/cpp/bindings/array.h" |
| 9 #include "sky/engine/tonic/dart_builtin.h" | 9 #include "sky/engine/tonic/dart_builtin.h" |
| 10 #include "sky/engine/tonic/dart_converter.h" | 10 #include "sky/engine/tonic/dart_converter.h" |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 Internals* GetInternals() { | 23 Internals* GetInternals() { |
| 24 DartState* state = DartState::Current(); | 24 DartState* state = DartState::Current(); |
| 25 return static_cast<Internals*>(state->GetUserData(&kInternalsKey)); | 25 return static_cast<Internals*>(state->GetUserData(&kInternalsKey)); |
| 26 } | 26 } |
| 27 | 27 |
| 28 void NotifyTestComplete(Dart_NativeArguments args) { | 28 void NotifyTestComplete(Dart_NativeArguments args) { |
| 29 Dart_Handle test_result = Dart_GetNativeArgument(args, 0); | 29 Dart_Handle test_result = Dart_GetNativeArgument(args, 0); |
| 30 GetInternals()->NotifyTestComplete(StdStringFromDart(test_result)); | 30 GetInternals()->NotifyTestComplete(StdStringFromDart(test_result)); |
| 31 } | 31 } |
| 32 | 32 |
| 33 void TakeRootBundleHandle(Dart_NativeArguments args) { |
| 34 Dart_SetIntegerReturnValue(args, 0); |
| 35 } |
| 36 |
| 33 void TakeShellProxyHandle(Dart_NativeArguments args) { | 37 void TakeShellProxyHandle(Dart_NativeArguments args) { |
| 34 Dart_SetIntegerReturnValue(args, | 38 Dart_SetIntegerReturnValue(args, |
| 35 GetInternals()->TakeShellProxyHandle().value()); | 39 GetInternals()->TakeShellProxyHandle().value()); |
| 36 } | 40 } |
| 37 | 41 |
| 38 void TakeServicesProvidedByEmbedder(Dart_NativeArguments args) { | 42 void TakeServicesProvidedByEmbedder(Dart_NativeArguments args) { |
| 39 Dart_SetIntegerReturnValue( | 43 Dart_SetIntegerReturnValue( |
| 40 args, GetInternals()->TakeServicesProvidedByEmbedder().value()); | 44 args, GetInternals()->TakeServicesProvidedByEmbedder().value()); |
| 41 } | 45 } |
| 42 | 46 |
| 43 void TakeServicesProvidedToEmbedder(Dart_NativeArguments args) { | 47 void TakeServicesProvidedToEmbedder(Dart_NativeArguments args) { |
| 44 Dart_SetIntegerReturnValue( | 48 Dart_SetIntegerReturnValue( |
| 45 args, GetInternals()->TakeServicesProvidedToEmbedder().value()); | 49 args, GetInternals()->TakeServicesProvidedToEmbedder().value()); |
| 46 } | 50 } |
| 47 | 51 |
| 48 void TakeServiceRegistry(Dart_NativeArguments args) { | 52 void TakeServiceRegistry(Dart_NativeArguments args) { |
| 49 Dart_SetIntegerReturnValue( | 53 Dart_SetIntegerReturnValue( |
| 50 args, GetInternals()->TakeServiceRegistry().value()); | 54 args, GetInternals()->TakeServiceRegistry().value()); |
| 51 } | 55 } |
| 52 | 56 |
| 53 const DartBuiltin::Natives kNativeFunctions[] = { | 57 const DartBuiltin::Natives kNativeFunctions[] = { |
| 54 {"notifyTestComplete", NotifyTestComplete, 1}, | 58 {"notifyTestComplete", NotifyTestComplete, 1}, |
| 55 {"takeShellProxyHandle", TakeShellProxyHandle, 0}, | 59 {"takeRootBundleHandle", TakeRootBundleHandle, 0}, |
| 60 {"takeServiceRegistry", TakeServiceRegistry, 0}, |
| 56 {"takeServicesProvidedByEmbedder", TakeServicesProvidedByEmbedder, 0}, | 61 {"takeServicesProvidedByEmbedder", TakeServicesProvidedByEmbedder, 0}, |
| 57 {"takeServicesProvidedToEmbedder", TakeServicesProvidedToEmbedder, 0}, | 62 {"takeServicesProvidedToEmbedder", TakeServicesProvidedToEmbedder, 0}, |
| 58 {"takeServiceRegistry", TakeServiceRegistry, 0}, | 63 {"takeShellProxyHandle", TakeShellProxyHandle, 0}, |
| 59 }; | 64 }; |
| 60 | 65 |
| 61 const DartBuiltin& GetBuiltin() { | 66 const DartBuiltin& GetBuiltin() { |
| 62 static DartBuiltin& builtin = *new DartBuiltin(kNativeFunctions, | 67 static DartBuiltin& builtin = *new DartBuiltin(kNativeFunctions, |
| 63 arraysize(kNativeFunctions)); | 68 arraysize(kNativeFunctions)); |
| 64 return builtin; | 69 return builtin; |
| 65 } | 70 } |
| 66 | 71 |
| 67 Dart_NativeFunction Resolver(Dart_Handle name, | 72 Dart_NativeFunction Resolver(Dart_Handle name, |
| 68 int argument_count, | 73 int argument_count, |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 139 const mojo::String& application_url, | 144 const mojo::String& application_url, |
| 140 mojo::InterfaceRequest<mojo::ServiceProvider> services, | 145 mojo::InterfaceRequest<mojo::ServiceProvider> services, |
| 141 mojo::ServiceProviderPtr exposed_services) { | 146 mojo::ServiceProviderPtr exposed_services) { |
| 142 if (document_view_) { | 147 if (document_view_) { |
| 143 document_view_->shell()->ConnectToApplication( | 148 document_view_->shell()->ConnectToApplication( |
| 144 application_url, services.Pass(), exposed_services.Pass()); | 149 application_url, services.Pass(), exposed_services.Pass()); |
| 145 } | 150 } |
| 146 } | 151 } |
| 147 | 152 |
| 148 } // namespace sky | 153 } // namespace sky |
| OLD | NEW |