Skip to content

Commit

Permalink
Regenerating classes exposed in "app.dart". (dart-gde#269)
Browse files Browse the repository at this point in the history
* Regenerating classes exposed in "app.dart".

Several classes where missing from "app.dart" including ChromeAppRuntime which caused some dependencies to break. This commit regenerates those classes.

* Updates version on `pubspec.yaml` and adds new entry on `changelog.md`.
  • Loading branch information
wigahluk authored and bholtz committed May 3, 2018
1 parent 4232583 commit 6960c90
Show file tree
Hide file tree
Showing 3 changed files with 223 additions and 1 deletion.
3 changes: 3 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Changelog - chrome.dart

## 0.10.1 2018-05-02
- fix missing classes on generated `app.dart` file.

## 0.10.0 2018-04-30
- updated to be compatible with Chrome 66 IDL's
- Ignoring `app.runtime.ActionType` in AppWindow API
Expand Down
219 changes: 219 additions & 0 deletions lib/gen/app.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
library chrome.app;

import '../src/common.dart';
import '../src/files.dart';
import 'windows.dart';

part 'app_patch.dart';
Expand All @@ -12,12 +13,230 @@ final ChromeApp app = new ChromeApp._();
class ChromeApp {
ChromeApp._();

/**
* Accessor for the `chrome.app.runtime` namespace.
*/
final ChromeAppRuntime runtime = new ChromeAppRuntime._();

/**
* Accessor for the `chrome.app.window` namespace.
*/
final ChromeAppWindow window = new ChromeAppWindow._();
}

/**
* Use the `chrome.app.runtime` API to manage the app lifecycle. The app runtime
* manages app installation, controls the event page, and can shut down the app
* at anytime.
*/
class ChromeAppRuntime extends ChromeApi {
JsObject get _app_runtime => chrome['app']['runtime'];

Stream<EmbedRequest> get onEmbedRequested => _onEmbedRequested.stream;
ChromeStreamController<EmbedRequest> _onEmbedRequested;

Stream<LaunchData> get onLaunched => _onLaunched.stream;
ChromeStreamController<LaunchData> _onLaunched;

Stream get onRestarted => _onRestarted.stream;
ChromeStreamController _onRestarted;

ChromeAppRuntime._() {
var getApi = () => _app_runtime;
_onEmbedRequested = new ChromeStreamController<EmbedRequest>.oneArg(getApi, 'onEmbedRequested', _createEmbedRequest);
_onLaunched = new ChromeStreamController<LaunchData>.oneArg(getApi, 'onLaunched', _createLaunchData);
_onRestarted = new ChromeStreamController.noArgs(getApi, 'onRestarted');
}

bool get available => _app_runtime != null;
}

/**
* Enumeration of app launch sources. This should be kept in sync with
* AppLaunchSource in extensions/common/constants.h, and GetLaunchSourceEnum()
* in extensions/browser/api/app_runtime/app_runtime_api.cc. Note the
* enumeration is used in UMA histogram so entries should not be re-ordered or
* removed.
*/
class LaunchSource extends ChromeEnum {
static const LaunchSource UNTRACKED = const LaunchSource._('untracked');
static const LaunchSource APP_LAUNCHER = const LaunchSource._('app_launcher');
static const LaunchSource NEW_TAB_PAGE = const LaunchSource._('new_tab_page');
static const LaunchSource RELOAD = const LaunchSource._('reload');
static const LaunchSource RESTART = const LaunchSource._('restart');
static const LaunchSource LOAD_AND_LAUNCH = const LaunchSource._('load_and_launch');
static const LaunchSource COMMAND_LINE = const LaunchSource._('command_line');
static const LaunchSource FILE_HANDLER = const LaunchSource._('file_handler');
static const LaunchSource URL_HANDLER = const LaunchSource._('url_handler');
static const LaunchSource SYSTEM_TRAY = const LaunchSource._('system_tray');
static const LaunchSource ABOUT_PAGE = const LaunchSource._('about_page');
static const LaunchSource KEYBOARD = const LaunchSource._('keyboard');
static const LaunchSource EXTENSIONS_PAGE = const LaunchSource._('extensions_page');
static const LaunchSource MANAGEMENT_API = const LaunchSource._('management_api');
static const LaunchSource EPHEMERAL_APP = const LaunchSource._('ephemeral_app');
static const LaunchSource BACKGROUND = const LaunchSource._('background');
static const LaunchSource KIOSK = const LaunchSource._('kiosk');
static const LaunchSource CHROME_INTERNAL = const LaunchSource._('chrome_internal');
static const LaunchSource TEST = const LaunchSource._('test');
static const LaunchSource INSTALLED_NOTIFICATION = const LaunchSource._('installed_notification');
static const LaunchSource CONTEXT_MENU = const LaunchSource._('context_menu');

static const List<LaunchSource> VALUES = const[UNTRACKED, APP_LAUNCHER, NEW_TAB_PAGE, RELOAD, RESTART, LOAD_AND_LAUNCH, COMMAND_LINE, FILE_HANDLER, URL_HANDLER, SYSTEM_TRAY, ABOUT_PAGE, KEYBOARD, EXTENSIONS_PAGE, MANAGEMENT_API, EPHEMERAL_APP, BACKGROUND, KIOSK, CHROME_INTERNAL, TEST, INSTALLED_NOTIFICATION, CONTEXT_MENU];

const LaunchSource._(String str): super(str);
}

/**
* An app can be launched with a specific action in mind, for example, to create
* a new note. The type of action the app was launched with is available inside
* of the [actionData] field from the LaunchData instance.
*/
class AppRuntimeActionType extends ChromeEnum {
static const AppRuntimeActionType NEW_NOTE = const AppRuntimeActionType._('new_note');

static const List<AppRuntimeActionType> VALUES = const[NEW_NOTE];

const AppRuntimeActionType._(String str): super(str);
}

/**
* Status of the play store.
*/
class PlayStoreStatus extends ChromeEnum {
static const PlayStoreStatus ENABLED = const PlayStoreStatus._('enabled');
static const PlayStoreStatus AVAILABLE = const PlayStoreStatus._('available');
static const PlayStoreStatus UNKNOWN = const PlayStoreStatus._('unknown');

static const List<PlayStoreStatus> VALUES = const[ENABLED, AVAILABLE, UNKNOWN];

const PlayStoreStatus._(String str): super(str);
}

class LaunchItem extends ChromeObject {
LaunchItem({Entry entry, String type}) {
if (entry != null) this.entry = entry;
if (type != null) this.type = type;
}
LaunchItem.fromProxy(JsObject jsProxy): super.fromProxy(jsProxy);

Entry get entry => _createEntry(jsProxy['entry']);
set entry(Entry value) => jsProxy['entry'] = jsify(value);

String get type => jsProxy['type'];
set type(String value) => jsProxy['type'] = value;
}

/**
* Optional data that includes action-specific launch information.
*/
class ActionData extends ChromeObject {
ActionData({AppRuntimeActionType actionType, bool isLockScreenAction, bool restoreLastActionState}) {
if (actionType != null) this.actionType = actionType;
if (isLockScreenAction != null) this.isLockScreenAction = isLockScreenAction;
if (restoreLastActionState != null) this.restoreLastActionState = restoreLastActionState;
}
ActionData.fromProxy(JsObject jsProxy): super.fromProxy(jsProxy);

AppRuntimeActionType get actionType => _createActionType(jsProxy['actionType']);
set actionType(AppRuntimeActionType value) => jsProxy['actionType'] = jsify(value);

bool get isLockScreenAction => jsProxy['isLockScreenAction'];
set isLockScreenAction(bool value) => jsProxy['isLockScreenAction'] = value;

bool get restoreLastActionState => jsProxy['restoreLastActionState'];
set restoreLastActionState(bool value) => jsProxy['restoreLastActionState'] = value;
}

/**
* Optional data for the launch. Either `items`, or the pair (`url,
* referrerUrl`) can be present for any given launch.
*/
class LaunchData extends ChromeObject {
LaunchData({String id, List<LaunchItem> items, String url, String referrerUrl, bool isKioskSession, bool isPublicSession, LaunchSource source, ActionData actionData, PlayStoreStatus playStoreStatus}) {
if (id != null) this.id = id;
if (items != null) this.items = items;
if (url != null) this.url = url;
if (referrerUrl != null) this.referrerUrl = referrerUrl;
if (isKioskSession != null) this.isKioskSession = isKioskSession;
if (isPublicSession != null) this.isPublicSession = isPublicSession;
if (source != null) this.source = source;
if (actionData != null) this.actionData = actionData;
if (playStoreStatus != null) this.playStoreStatus = playStoreStatus;
}
LaunchData.fromProxy(JsObject jsProxy): super.fromProxy(jsProxy);

String get id => jsProxy['id'];
set id(String value) => jsProxy['id'] = value;

List<LaunchItem> get items => listify(jsProxy['items'], _createLaunchItem);
set items(List<LaunchItem> value) => jsProxy['items'] = jsify(value);

String get url => jsProxy['url'];
set url(String value) => jsProxy['url'] = value;

String get referrerUrl => jsProxy['referrerUrl'];
set referrerUrl(String value) => jsProxy['referrerUrl'] = value;

bool get isKioskSession => jsProxy['isKioskSession'];
set isKioskSession(bool value) => jsProxy['isKioskSession'] = value;

bool get isPublicSession => jsProxy['isPublicSession'];
set isPublicSession(bool value) => jsProxy['isPublicSession'] = value;

LaunchSource get source => _createLaunchSource(jsProxy['source']);
set source(LaunchSource value) => jsProxy['source'] = jsify(value);

ActionData get actionData => _createActionData(jsProxy['actionData']);
set actionData(ActionData value) => jsProxy['actionData'] = jsify(value);

PlayStoreStatus get playStoreStatus => _createPlayStoreStatus(jsProxy['playStoreStatus']);
set playStoreStatus(PlayStoreStatus value) => jsProxy['playStoreStatus'] = jsify(value);
}

/**
* This object specifies details and operations to perform on the embedding
* request. The app to be embedded can make a decision on whether or not to
* allow the embedding and what to embed based on the embedder making the
* request.
*/
class EmbedRequest extends ChromeObject {
EmbedRequest({String embedderId, dynamic data}) {
if (embedderId != null) this.embedderId = embedderId;
if (data != null) this.data = data;
}
EmbedRequest.fromProxy(JsObject jsProxy): super.fromProxy(jsProxy);

String get embedderId => jsProxy['embedderId'];
set embedderId(String value) => jsProxy['embedderId'] = value;

dynamic get data => jsProxy['data'];
set data(dynamic value) => jsProxy['data'] = jsify(value);

/**
* Allows `embedderId` to embed this app in an <appview> element. The `url`
* specifies the content to embed.
*/
void allow(String url) {
jsProxy.callMethod('allow', [url]);
}

/**
* Prevents ` embedderId` from embedding this app in an <appview> element.
*/
void deny() {
jsProxy.callMethod('deny');
}
}

EmbedRequest _createEmbedRequest(JsObject jsProxy) => jsProxy == null ? null : new EmbedRequest.fromProxy(jsProxy);
LaunchData _createLaunchData(JsObject jsProxy) => jsProxy == null ? null : new LaunchData.fromProxy(jsProxy);
Entry _createEntry(JsObject jsProxy) => jsProxy == null ? null : new CrEntry.fromProxy(jsProxy);
AppRuntimeActionType _createActionType(String value) => AppRuntimeActionType.VALUES.singleWhere((ChromeEnum e) => e.value == value);
LaunchItem _createLaunchItem(JsObject jsProxy) => jsProxy == null ? null : new LaunchItem.fromProxy(jsProxy);
LaunchSource _createLaunchSource(String value) => LaunchSource.VALUES.singleWhere((ChromeEnum e) => e.value == value);
ActionData _createActionData(JsObject jsProxy) => jsProxy == null ? null : new ActionData.fromProxy(jsProxy);
PlayStoreStatus _createPlayStoreStatus(String value) => PlayStoreStatus.VALUES.singleWhere((ChromeEnum e) => e.value == value);

/**
* Use the `chrome.app.window` API to create windows. Windows have an optional
* frame with title bar and size controls. They are not associated with any
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: chrome
version: 0.10.0
version: 0.10.1
authors:
- Adam Bender <[email protected]>
- Ben Holtz <[email protected]>
Expand Down

0 comments on commit 6960c90

Please sign in to comment.