Stocks.apk should have icons when run offline
This CL adds the concept of a root asset bundle to Sky. If the Sky app was launched from a bundle, the root bundle is that bundle. This CL teaches icon.dart to default to loading icons out of the root bundle, if a root bundle exists. The next result is that Stocks has icons when run offline because the icons are present in stock's skyx bundle. TBR=eseidel@google.com Review URL: https://codereview.chromium.org/1208273003.
This commit is contained in:
parent
35dbae5e3c
commit
12171c63ef
@ -200,7 +200,8 @@ void Engine::RunFromBundle(const mojo::String& path) {
|
||||
|
||||
void Engine::DidCreateIsolate(Dart_Isolate isolate) {
|
||||
Internals::Create(isolate,
|
||||
CreateServiceProvider(config_.service_provider_context));
|
||||
CreateServiceProvider(config_.service_provider_context),
|
||||
root_bundle_.Pass());
|
||||
}
|
||||
|
||||
void Engine::ScheduleFrame() {
|
||||
|
@ -29,6 +29,11 @@ Internals* GetInternals() {
|
||||
void NotifyTestComplete(Dart_NativeArguments args) {
|
||||
}
|
||||
|
||||
void TakeRootBundleHandle(Dart_NativeArguments args) {
|
||||
Dart_SetIntegerReturnValue(
|
||||
args, GetInternals()->TakeRootBundleHandle().value());
|
||||
}
|
||||
|
||||
void TakeShellProxyHandle(Dart_NativeArguments args) {
|
||||
Dart_SetIntegerReturnValue(args, 0);
|
||||
}
|
||||
@ -48,10 +53,11 @@ void TakeServiceRegistry(Dart_NativeArguments args) {
|
||||
|
||||
const DartBuiltin::Natives kNativeFunctions[] = {
|
||||
{"notifyTestComplete", NotifyTestComplete, 1},
|
||||
{"takeShellProxyHandle", TakeShellProxyHandle, 0},
|
||||
{"takeRootBundleHandle", TakeRootBundleHandle, 0},
|
||||
{"takeServiceRegistry", TakeServiceRegistry, 0},
|
||||
{"takeServicesProvidedByEmbedder", TakeServicesProvidedByEmbedder, 0},
|
||||
{"takeServicesProvidedToEmbedder", TakeServicesProvidedToEmbedder, 0},
|
||||
{"takeServiceRegistry", TakeServiceRegistry, 0},
|
||||
{"takeShellProxyHandle", TakeShellProxyHandle, 0},
|
||||
};
|
||||
|
||||
const DartBuiltin& GetBuiltin() {
|
||||
@ -75,17 +81,21 @@ const char kLibraryName[] = "dart:sky.internals";
|
||||
} // namespace
|
||||
|
||||
void Internals::Create(Dart_Isolate isolate,
|
||||
mojo::ServiceProviderPtr service_provider) {
|
||||
mojo::ServiceProviderPtr service_provider,
|
||||
mojo::asset_bundle::AssetBundlePtr root_bundle) {
|
||||
DartState* state = DartState::From(isolate);
|
||||
state->SetUserData(&kInternalsKey, new Internals(service_provider.Pass()));
|
||||
state->SetUserData(&kInternalsKey, new Internals(service_provider.Pass(),
|
||||
root_bundle.Pass()));
|
||||
Dart_Handle library =
|
||||
Dart_LookupLibrary(Dart_NewStringFromCString(kLibraryName));
|
||||
CHECK(!LogIfError(library));
|
||||
CHECK(!LogIfError(Dart_SetNativeResolver(library, Resolver, Symbolizer)));
|
||||
}
|
||||
|
||||
Internals::Internals(mojo::ServiceProviderPtr platform_service_provider)
|
||||
: service_provider_impl_(GetProxy(&service_provider_)),
|
||||
Internals::Internals(mojo::ServiceProviderPtr platform_service_provider,
|
||||
mojo::asset_bundle::AssetBundlePtr root_bundle)
|
||||
: root_bundle_(root_bundle.Pass()),
|
||||
service_provider_impl_(GetProxy(&service_provider_)),
|
||||
platform_service_provider_(platform_service_provider.Pass()) {
|
||||
service_provider_impl_.set_fallback_service_provider(
|
||||
platform_service_provider_.get());
|
||||
@ -106,5 +116,9 @@ mojo::Handle Internals::TakeServicesProvidedByEmbedder() {
|
||||
return service_provider_.PassInterface().PassHandle().release();
|
||||
}
|
||||
|
||||
mojo::Handle Internals::TakeRootBundleHandle() {
|
||||
return root_bundle_.PassInterface().PassHandle().release();
|
||||
}
|
||||
|
||||
} // namespace shell
|
||||
} // namespace sky
|
||||
|
@ -26,18 +26,22 @@ class Internals
|
||||
~Internals() override;
|
||||
|
||||
static void Create(Dart_Isolate isolate,
|
||||
mojo::ServiceProviderPtr platform_service_provider);
|
||||
mojo::ServiceProviderPtr platform_service_provider,
|
||||
mojo::asset_bundle::AssetBundlePtr root_bundle);
|
||||
|
||||
mojo::Handle TakeServicesProvidedByEmbedder();
|
||||
mojo::Handle TakeRootBundleHandle();
|
||||
|
||||
private:
|
||||
explicit Internals(mojo::ServiceProviderPtr platform_service_provider);
|
||||
explicit Internals(mojo::ServiceProviderPtr platform_service_provider,
|
||||
mojo::asset_bundle::AssetBundlePtr root_bundle);
|
||||
|
||||
// |mojo::InterfaceFactory<mojo::asset_bundle::AssetUnpacker>| implementation:
|
||||
void Create(
|
||||
mojo::ApplicationConnection* connection,
|
||||
mojo::InterfaceRequest<mojo::asset_bundle::AssetUnpacker>) override;
|
||||
|
||||
mojo::asset_bundle::AssetBundlePtr root_bundle_;
|
||||
mojo::ServiceProviderPtr service_provider_;
|
||||
mojo::ServiceProviderImpl service_provider_impl_;
|
||||
mojo::ServiceProviderPtr platform_service_provider_;
|
||||
|
Loading…
x
Reference in New Issue
Block a user