Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(423)

Unified Diff: tools/dom/src/chrome/app_runtime.dart

Issue 12209045: Initial commit of generated dart:chrome app_window and app_runtime (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Added chromegenerator.py, which (if run from its local directory), generates app_window and app_run… Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: tools/dom/src/chrome/app_runtime.dart
diff --git a/tools/dom/src/chrome/app.runtime.dart b/tools/dom/src/chrome/app_runtime.dart
similarity index 57%
rename from tools/dom/src/chrome/app.runtime.dart
rename to tools/dom/src/chrome/app_runtime.dart
index 8b38aac859048bffad042d533c42e4a701026f3c..070acecef53aa9791f128f476ffe151a04e516a9 100644
--- a/tools/dom/src/chrome/app.runtime.dart
+++ b/tools/dom/src/chrome/app_runtime.dart
@@ -2,26 +2,17 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
-// from app_runtime.idl
+// Generated from namespace: app.runtime
+
part of chrome;
/**
* Types
*/
-/// A WebIntents intent object. Deprecated.
class Intent extends ChromeObject {
/*
- * Public (Dart) constructor
- */
- Intent({String action, String type, var data}) {
- this.action = action;
- this.type = type;
- this.data = data;
- }
-
- /*
- * Private (JS) constructor
+ * Private constructor
*/
Intent._proxy(_jsObject) : super._proxy(_jsObject);
@@ -44,7 +35,6 @@ class Intent extends ChromeObject {
}
/// Data associated with the intent.
- // TODO(sashab): What is the best way to serialize/return generic JS objects?
Object get data => JS('Object', '#.data', this._jsObject);
void set data(Object data) {
@@ -52,10 +42,12 @@ class Intent extends ChromeObject {
}
/*
- * TODO(sashab): What is a NullCallback() type?
- * Add postResult and postFailure once understanding what this type is, and
- * once there is a way to pass functions back from JS.
+ * Methods
*/
+ /// Callback to be compatible with WebIntents.
+ void postResult() => JS('void', '#.postResult()', this._jsObject);
+ /// Callback to be compatible with WebIntents.
+ void postFailure() => JS('void', '#.postFailure()', this._jsObject);
}
class LaunchItem extends ChromeObject {
@@ -63,8 +55,10 @@ class LaunchItem extends ChromeObject {
* Public constructor
*/
LaunchItem({FileEntry entry, String type}) {
- this.entry = entry;
- this.type = type;
+ if (?entry)
+ this.entry = entry;
+ if (?type)
+ this.type = type;
}
/*
@@ -80,7 +74,7 @@ class LaunchItem extends ChromeObject {
FileEntry get entry => JS('FileEntry', '#.entry', this._jsObject);
void set entry(FileEntry entry) {
- JS('void', '#.entry = #', this._jsObject, entry);
+ JS('void', '#.entry = #', this._jsObject, convertArgument(entry));
}
/// The MIME type of the file.
@@ -91,15 +85,17 @@ class LaunchItem extends ChromeObject {
}
}
-/// Optional data for the launch.
class LaunchData extends ChromeObject {
/*
* Public constructor
*/
LaunchData({Intent intent, String id, List<LaunchItem> items}) {
- this.intent = intent;
- this.id = id;
- this.items = items;
+ if (?intent)
+ this.intent = intent;
+ if (?id)
+ this.id = id;
+ if (?items)
+ this.items = items;
}
/*
@@ -110,6 +106,7 @@ class LaunchData extends ChromeObject {
/*
* Public accessors
*/
+
Intent get intent => new Intent._proxy(JS('', '#.intent', this._jsObject));
void set intent(Intent intent) {
@@ -123,12 +120,12 @@ class LaunchData extends ChromeObject {
JS('void', '#.id = #', this._jsObject, id);
}
- List<LaunchItem> get items() {
- List<LaunchItem> items_final = new List<LaunchItem>();
+ List<LaunchItem> get items {
+ List<LaunchItem> __proxy_items = new List<LaunchItem>();
for (var o in JS('List', '#.items', this._jsObject)) {
- items_final.add(new LaunchItem._proxy(o));
+ __proxy_items.add(new LaunchItem._proxy(o));
}
- return items_final;
+ return __proxy_items;
}
void set items(List<LaunchItem> items) {
@@ -141,9 +138,12 @@ class IntentResponse extends ChromeObject {
* Public constructor
*/
IntentResponse({int intentId, bool success, Object data}) {
- this.intentId = intentId;
- this.success = success;
- this.data = data;
+ if (?intentId)
+ this.intentId = intentId;
+ if (?success)
+ this.success = success;
+ if (?data)
+ this.data = data;
}
/*
@@ -170,7 +170,6 @@ class IntentResponse extends ChromeObject {
}
/// Data associated with the intent response.
- // TODO(sashab): What's the best way to serialize/return generic JS objects?
Object get data => JS('Object', '#.data', this._jsObject);
void set data(Object data) {
@@ -182,48 +181,56 @@ class IntentResponse extends ChromeObject {
* Events
*/
+/// Fired when an app is launched from the launcher or in response to a web
+/// intent.
+class Event_app_runtime_onLaunched extends Event {
+ void addListener(void callback(LaunchData launchData)) {
+ void __proxy_callback(launchData) {
+ if (?callback) {
+ callback(new LaunchData._proxy(launchData));
+ }
+ }
+ super.addListener(callback);
+ }
+
+ void removeListener(void callback(LaunchData launchData)) {
+ void __proxy_callback(launchData) {
+ if (?callback) {
+ callback(new LaunchData._proxy(launchData));
+ }
+ }
+ super.removeListener(callback);
+ }
+
+ bool hasListener(void callback(LaunchData launchData)) {
+ void __proxy_callback(launchData) {
+ if (?callback) {
+ callback(new LaunchData._proxy(launchData));
+ }
+ }
+ super.hasListener(callback);
+ }
+
+ Event_app_runtime_onLaunched(jsObject) : super._(jsObject, 1);
+}
+
/// Fired at Chrome startup to apps that were running when Chrome last shut
/// down.
-class Event_ChromeAppRuntimeOnRestarted extends Event {
- /*
- * Override callback type definitions
- */
- void addListener(void callback())
- => super.addListener(callback);
- void removeListener(void callback())
- => super.removeListener(callback);
- bool hasListener(void callback())
- => super.hasListener(callback);
+class Event_app_runtime_onRestarted extends Event {
+ void addListener(void callback()) => super.addListener(callback);
- /*
- * Constructor
- */
- Event_ChromeAppRuntimeOnRestarted(jsObject) : super._(jsObject, 0);
-}
+ void removeListener(void callback()) => super.removeListener(callback);
-/// Fired when an app is launched from the launcher or in response to a web
-/// intent.
-class Event_ChromeAppRuntimeOnLaunched extends Event {
- /*
- * Override callback type definitions
- */
- void addListener(void callback(LaunchData launchData))
- => super.addListener(callback);
- void removeListener(void callback(LaunchData launchData))
- => super.removeListener(callback);
- bool hasListener(void callback(LaunchData launchData))
- => super.hasListener(callback);
+ bool hasListener(void callback()) => super.hasListener(callback);
- /*
- * Constructor
- */
- Event_ChromeAppRuntimeOnLaunched(jsObject) : super._(jsObject, 1);
+ Event_app_runtime_onRestarted(jsObject) : super._(jsObject, 0);
}
/**
* Functions
*/
-class API_ChromeAppRuntime {
+
+class API_app_runtime {
/*
* API connection
*/
@@ -232,26 +239,20 @@ class API_ChromeAppRuntime {
/*
* Events
*/
- Event_ChromeAppRuntimeOnRestarted onRestarted;
- Event_ChromeAppRuntimeOnLaunched onLaunched;
+ Event_app_runtime_onLaunched onLaunched;
+ Event_app_runtime_onRestarted onRestarted;
/*
* Functions
*/
- void postIntentResponse(IntentResponse intentResponse) =>
- JS('void', '#.postIntentResponse(#)', this._jsObject,
- convertArgument(intentResponse));
- /*
- * Constructor
- */
- API_ChromeAppRuntime(this._jsObject) {
- onRestarted = new Event_ChromeAppRuntimeOnRestarted(JS('Object',
- '#.onRestarted',
- this._jsObject));
- onLaunched = new Event_ChromeAppRuntimeOnLaunched(JS('Object',
- '#.onLaunched',
- this._jsObject));
- }
-}
+ /// postIntentResponse is an internal method to responds to an intent
+ /// previously sent to a packaged app. This is identified by intentId, and
+ /// should only be invoked at most once per intentId.
+ void postIntentResponse(IntentResponse intentResponse) => JS('void', '#.postIntentResponse(#)', this._jsObject, convertArgument(intentResponse));
+ API_app_runtime(this._jsObject) {
+ onLaunched = new Event_app_runtime_onLaunched(JS('', '#.onLaunched', this._jsObject));
+ onRestarted = new Event_app_runtime_onRestarted(JS('', '#.onRestarted', this._jsObject));
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698