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

Unified Diff: tools/dom/src/chrome/app.runtime.dart

Issue 12049030: Initial commit for Chrome.* APIs in Dart (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Removed getMember() and setMember(), replacing with direct calls to JS() Created 7 years, 11 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
« no previous file with comments | « sdk/lib/chrome/dart2js/chrome_dart2js.dart ('k') | tools/dom/src/chrome/app.window.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
new file mode 100644
index 0000000000000000000000000000000000000000..8b38aac859048bffad042d533c42e4a701026f3c
--- /dev/null
+++ b/tools/dom/src/chrome/app.runtime.dart
@@ -0,0 +1,257 @@
+// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
+// 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
+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
+ */
+ Intent._proxy(_jsObject) : super._proxy(_jsObject);
+
+ /*
+ * Public accessors
+ */
+
+ /// The WebIntent being invoked.
+ String get action => JS('String', '#.action', this._jsObject);
+
+ void set action(String action) {
+ JS('void', '#.action = #', this._jsObject, action);
+ }
+
+ /// The MIME type of the data.
+ String get type => JS('String', '#.type', this._jsObject);
+
+ void set type(String type) {
+ JS('void', '#.type = #', this._jsObject, type);
+ }
+
+ /// 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) {
+ JS('void', '#.data = #', this._jsObject, convertArgument(data));
+ }
+
+ /*
+ * 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.
+ */
+}
+
+class LaunchItem extends ChromeObject {
+ /*
+ * Public constructor
+ */
+ LaunchItem({FileEntry entry, String type}) {
+ this.entry = entry;
+ this.type = type;
+ }
+
+ /*
+ * Private constructor
+ */
+ LaunchItem._proxy(_jsObject) : super._proxy(_jsObject);
+
+ /*
+ * Public accessors
+ */
+
+ /// FileEntry for the file.
+ FileEntry get entry => JS('FileEntry', '#.entry', this._jsObject);
+
+ void set entry(FileEntry entry) {
+ JS('void', '#.entry = #', this._jsObject, entry);
+ }
+
+ /// The MIME type of the file.
+ String get type => JS('String', '#.type', this._jsObject);
+
+ void set type(String type) {
+ JS('void', '#.type = #', this._jsObject, type);
+ }
+}
+
+/// 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;
+ }
+
+ /*
+ * Private constructor
+ */
+ LaunchData._proxy(_jsObject) : super._proxy(_jsObject);
+
+ /*
+ * Public accessors
+ */
+ Intent get intent => new Intent._proxy(JS('', '#.intent', this._jsObject));
+
+ void set intent(Intent intent) {
+ JS('void', '#.intent = #', this._jsObject, convertArgument(intent));
+ }
+
+ /// The id of the file handler that the app is being invoked with.
+ String get id => JS('String', '#.id', this._jsObject);
+
+ void set id(String id) {
+ JS('void', '#.id = #', this._jsObject, id);
+ }
+
+ List<LaunchItem> get items() {
+ List<LaunchItem> items_final = new List<LaunchItem>();
+ for (var o in JS('List', '#.items', this._jsObject)) {
+ items_final.add(new LaunchItem._proxy(o));
+ }
+ return items_final;
+ }
+
+ void set items(List<LaunchItem> items) {
+ JS('void', '#.items = #', this._jsObject, convertArgument(items));
+ }
+}
+
+class IntentResponse extends ChromeObject {
+ /*
+ * Public constructor
+ */
+ IntentResponse({int intentId, bool success, Object data}) {
+ this.intentId = intentId;
+ this.success = success;
+ this.data = data;
+ }
+
+ /*
+ * Private constructor
+ */
+ IntentResponse._proxy(_jsObject) : super._proxy(_jsObject);
+
+ /*
+ * Public accessors
+ */
+
+ /// Identifies the intent.
+ int get intentId => JS('int', '#.intentId', this._jsObject);
+
+ void set intentId(int intentId) {
+ JS('void', '#.intentId = #', this._jsObject, intentId);
+ }
+
+ /// Was this intent successful? (i.e., postSuccess vs postFailure).
+ bool get success => JS('bool', '#.success', this._jsObject);
+
+ void set success(bool success) {
+ JS('void', '#.success = #', this._jsObject, success);
+ }
+
+ /// 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) {
+ JS('void', '#.data = #', this._jsObject, convertArgument(data));
+ }
+}
+
+/**
+ * Events
+ */
+
+/// 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);
+
+ /*
+ * Constructor
+ */
+ Event_ChromeAppRuntimeOnRestarted(jsObject) : super._(jsObject, 0);
+}
+
+/// 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);
+
+ /*
+ * Constructor
+ */
+ Event_ChromeAppRuntimeOnLaunched(jsObject) : super._(jsObject, 1);
+}
+
+/**
+ * Functions
+ */
+class API_ChromeAppRuntime {
+ /*
+ * API connection
+ */
+ Object _jsObject;
+
+ /*
+ * Events
+ */
+ Event_ChromeAppRuntimeOnRestarted onRestarted;
+ Event_ChromeAppRuntimeOnLaunched onLaunched;
+
+ /*
+ * 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));
+ }
+}
+
« no previous file with comments | « sdk/lib/chrome/dart2js/chrome_dart2js.dart ('k') | tools/dom/src/chrome/app.window.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698