blob: 51330d5606d33dd019d62a21b5c3d9bf2f8c46eb [file] [log] [blame]
// Copyright 2016 The Fuchsia Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
library fuchsia.modular;
using fuchsia.ui.views;
using fuchsia.mem;
/// This interface is exposed to all Module instances in a story. It allows to
/// create Link instances and run more Module instances.
protocol ModuleContext {
/// Starts a new Module instance and adds it to the story. The Module to
/// execute is identified by the contents of [intent] and the Module instance
/// is given a [name] in the scope of the starting Module instance. The view
/// for the Module is given to the story shell for display.
/// Providing a [surface_relation] advises the StoryShell how to layout
/// surfaces that the new module creates. If [surface_relation] is null then
/// a default relation is used.
/// If the method is called again with the same [name] by the same Module
/// instance, but with different arguments, the existing Module instance is
/// restarted with the changed arguments. If the other arguments don't
/// change, just an additional ModuleController connection is made.
AddModuleToStory(string name, Intent intent,
request<ModuleController> module_controller,
SurfaceRelation? surface_relation)
-> (StartModuleStatus status);
/// Like AddModuleToStory(), but passes a [view_token] explicitly to embed
/// the view of the requested Module instance in the view of the requesting
/// Module instance, instead of relying on the story shell for display. If a
/// Module instance with the same [name] and [intent] is already running,
/// [view_token] is destroyed.
EmbedModule(string name, Intent intent,
request<ModuleController> module_controller,
fuchsia.ui.views.ViewToken view_token)
-> (StartModuleStatus status);
/// When a module calls [RemoveSelfFromStory()] the framework will stop the
/// module and remove it from the story. If there are no more running modules
/// in the story the story will be deleted.
/// Creates a [fuchsia.modular.Entity] with the given [type] and [data]. The
/// lifetime of the created entity is tied to the lifetime of the current story,
/// but can be dereferenced by modules and agents outside the scope of the story.
/// [entity_request] will be connected to the created entity, or closed if the
/// creation fails.
/// The returned [reference] is the entity reference for the created entity, or
/// null if the entity creation failed.
CreateEntity(string type, fuchsia.mem.Buffer data, request<Entity> entity_request)
-> (string? entity_reference);
/// Communicates the status of an Intent to a Module.
enum StartModuleStatus {
/// This interface defines the protocol over which a Module can communicate about
/// an ongoing activity to the framework. It is provided to Modules via
/// ModuleContext.StartOngoingActivity().
protocol OngoingActivity {
enum OngoingActivityType {
VIDEO = 1;
AUDIO = 2;