// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

// Use the <code>chrome.app.runtime</code> API to manage the app lifecycle.
// The app runtime manages app installation, controls the event page, and can
// shut down the app at anytime.
namespace app.runtime {

  [inline_doc] dictionary LaunchItem {
    // FileEntry for the file.
    [instanceOf=FileEntry] object entry;

    // The MIME type of the file.
    DOMString type;
  };

  // Optional data for the launch. Either <code>items</code>, or
  // the pair (<code>url, referrerUrl</code>) can be present for any given
  // launch.
  [inline_doc] dictionary LaunchData {
    // The ID of the file or URL handler that the app is being invoked with.
    // Handler IDs are the top-level keys in the <code>file_handlers</code>
    // and/or <code>url_handlers</code> dictionaries in the manifest.
    DOMString? id;

    // The file entries for the <code>onLaunched</code> event triggered by a
    // matching file handler in the <code>file_handlers</code> manifest key.
    LaunchItem[]? items;

    // The URL for the <code>onLaunched</code> event triggered by a matching
    // URL handler in the <code>url_handlers</code> manifest key.
    DOMString? url;

    // The referrer URL for the <code>onLaunched</code> event triggered by a
    // matching URL handler in the <code>url_handlers</code> manifest key.
    DOMString? referrerUrl;

    // Whether the app is being launched in a <a
    // href="https://support.google.com/chromebook/answer/3134673">Chrome OS
    // kiosk session</a>.
    boolean? isKioskSession;
  };

  interface Events {
    // Fired when an app is launched from the launcher.
    static void onLaunched(optional LaunchData launchData);

    // Fired at Chrome startup to apps that were running when Chrome last shut
    // down.
    static void onRestarted();
  };
};