├── .gitignore
├── LICENSE
├── README.md
├── camera-capture
├── README.md
├── pubspec.yaml
├── screenshot.png
└── web
│ ├── background.js
│ ├── camera.png
│ ├── camera_capture.css
│ ├── camera_capture.dart
│ ├── camera_capture.html
│ └── manifest.json
├── chrome-app-with-polymer-dart
├── CHANGELOG.md
├── LICENSE
├── README.md
├── build.dart
├── lib
│ ├── main_app.dart
│ └── main_app.html
├── pubspec.yaml
└── web
│ ├── apple-touch-icon-precomposed.png
│ ├── background.js
│ ├── favicon.ico
│ ├── images
│ └── touch
│ │ ├── chrome-touch-icon-192x192.png
│ │ └── ms-touch-icon-144x144-precomposed.png
│ ├── index.html
│ ├── manifest.json
│ ├── robots.txt
│ └── styles.css
├── context-menu
├── README.md
├── pubspec.yaml
├── screenshot.png
└── web
│ ├── a.dart
│ ├── a.html
│ ├── b.dart
│ ├── b.html
│ ├── background.js
│ ├── common.dart
│ ├── context_menu.css
│ ├── dart_icon.png
│ └── manifest.json
├── desktop-capture
├── README.md
├── pubspec.yaml
├── screenshot.png
└── web
│ ├── background.js
│ ├── desktop.png
│ ├── desktop_capture.css
│ ├── desktop_capture.dart
│ ├── desktop_capture.html
│ └── manifest.json
├── filesystem-access
├── README.md
├── pubspec.yaml
├── screenshot.png
└── web
│ ├── background.js
│ ├── dart_icon.png
│ ├── dnd.dart
│ ├── filesystem_access.css
│ ├── filesystem_access.dart
│ ├── filesystem_access.html
│ └── manifest.json
├── media-gallery
├── README.md
├── pubspec.yaml
├── screenshot.png
└── web
│ ├── background.js
│ ├── manifest.json
│ ├── mediagallery.css
│ ├── mediagallery.dart
│ ├── mediagallery.html
│ └── mga-128color.png
└── windows
├── README.md
├── pubspec.yaml
├── screenshot.png
└── web
├── background.js
├── copycat.dart
├── copycat.html
├── img
├── copycat.png
└── original.png
├── manifest.json
├── original.dart
├── original.html
├── script
└── update.dart
└── styles
└── windows.css
/.gitignore:
--------------------------------------------------------------------------------
1 | # Don’t commit the following directories created by pub.
2 | build/
3 | packages/
4 |
5 | # Or the files created by dart2js.
6 | *.dart.js
7 | *.dart.precompiled.js
8 | *.js_
9 | *.js.deps
10 | *.js.map
11 |
12 | # Include when developing application packages.
13 | pubspec.lock
14 |
15 | .idea
16 | .pub
17 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | Copyright (c) 2014, Shared Projects for Dart GDE's
2 | All rights reserved.
3 |
4 | Redistribution and use in source and binary forms, with or without
5 | modification, are permitted provided that the following conditions are met:
6 |
7 | * Redistributions of source code must retain the above copyright notice, this
8 | list of conditions and the following disclaimer.
9 |
10 | * Redistributions in binary form must reproduce the above copyright notice,
11 | this list of conditions and the following disclaimer in the documentation
12 | and/or other materials provided with the distribution.
13 |
14 | * Neither the name of the {organization} nor the names of its
15 | contributors may be used to endorse or promote products derived from
16 | this software without specific prior written permission.
17 |
18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
22 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
24 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
25 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
26 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | dart-chrome-app-samples
2 | =======================
3 |
4 | Chrome App Samples in Dart
5 |
--------------------------------------------------------------------------------
/camera-capture/README.md:
--------------------------------------------------------------------------------
1 | # Camera Capture
2 |
3 | Shows how to grab a camera and microphone feed using getUserMedia. Requires
4 | the appropriate permissions (`audioCapture` and `videoCapture`)
5 | to be set in the manifest file.
6 |
7 | ## APIs
8 |
9 | * [Runtime](http://developer.chrome.com/apps/app.runtime.html)
10 | * [Window](http://developer.chrome.com/apps/app.window.html)
11 | * [videoCapture and audioCapture](http://developer.chrome.com/apps/manifest.html#permissions)
12 |
13 |
14 | ## Screenshot
15 | 
--------------------------------------------------------------------------------
/camera-capture/pubspec.yaml:
--------------------------------------------------------------------------------
1 | name: camera-capture
2 | description: A sample Chrome packaged application
3 | dependencies:
4 | chrome: any
5 | transformers:
6 | - chrome
7 |
--------------------------------------------------------------------------------
/camera-capture/screenshot.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dart-gde/dart-chrome-app-samples/44ba20283aee00137277ddaf60abbd3e047a225b/camera-capture/screenshot.png
--------------------------------------------------------------------------------
/camera-capture/web/background.js:
--------------------------------------------------------------------------------
1 |
2 | chrome.app.runtime.onLaunched.addListener(function(launchData) {
3 | chrome.app.window.create('camera_capture.html', {
4 | 'id': '_mainWindow', 'bounds': {'width': 800, 'height': 600 }
5 | });
6 | });
7 |
--------------------------------------------------------------------------------
/camera-capture/web/camera.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dart-gde/dart-chrome-app-samples/44ba20283aee00137277ddaf60abbd3e047a225b/camera-capture/web/camera.png
--------------------------------------------------------------------------------
/camera-capture/web/camera_capture.css:
--------------------------------------------------------------------------------
1 | body {
2 | background: white;
3 | display: -webkit-flex;
4 | -webkit-justify-content: center;
5 | -webkit-align-items: center;
6 | -webkit-flex-direction: column;
7 | }
8 | video {
9 | width: 640px;
10 | height: 480px;
11 | background: rgba(0,0,0,0.25);
12 | }
13 | button {
14 | display: inline-block;
15 | background: -webkit-linear-gradient(#F9F9F9 40%, #E3E3E3 70%);
16 | background: linear-gradient(#F9F9F9 40%, #E3E3E3 70%);
17 | border: 1px solid #999;
18 | -webkit-border-radius: 3px;
19 | border-radius: 3px;
20 | padding: 5px 8px;
21 | outline: none;
22 | white-space: nowrap;
23 | -webkit-user-select: none;
24 | user-select: none;
25 | cursor: pointer;
26 | text-shadow: 1px 1px #fff;
27 | font-weight: 700;
28 | font-size: 10pt;
29 | }
30 | button:hover,
31 | button.active {
32 | border-color: black;
33 | }
34 | button:active,
35 | button.active {
36 | background: -webkit-linear-gradient(#E3E3E3 40%, #F9F9F9 70%);
37 | background: linear-gradient(#E3E3E3 40%, #F9F9F9 70%);
38 | }
39 |
40 | video {
41 | background: white url(camera.png) center no-repeat;
42 | border: 1px solid #e2e2e2;
43 | box-shadow: 0 1px 1px rgba(0,0,0,0.2);
44 | }
--------------------------------------------------------------------------------
/camera-capture/web/camera_capture.dart:
--------------------------------------------------------------------------------
1 | import 'dart:html';
2 |
3 | void main() {
4 | document.querySelector("button").onClick.listen((MouseEvent mouse_event) {
5 | window.navigator.getUserMedia(audio: true, video: true).then((MediaStream media_stream) {
6 | VideoElement video = document.querySelector("video");
7 | video.src = Url.createObjectUrlFromStream(media_stream);
8 | }).catchError((e) => window.console.error(e));
9 | });
10 | }
11 |
--------------------------------------------------------------------------------
/camera-capture/web/camera_capture.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | Camera capture
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/camera-capture/web/manifest.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "Camera capture",
3 | "version": "1",
4 |
5 | "manifest_version": 2,
6 |
7 | "icons": {
8 | "16": "camera.png",
9 | "128": "camera.png"
10 | },
11 |
12 | "app": {
13 | "background": {
14 | "scripts": ["background.js"]
15 | }
16 | },
17 | "permissions": [
18 | "audioCapture",
19 | "videoCapture"
20 | ]
21 | }
22 |
--------------------------------------------------------------------------------
/chrome-app-with-polymer-dart/CHANGELOG.md:
--------------------------------------------------------------------------------
1 | # Changelog
2 |
3 | ## 0.1.0
4 |
5 | - Example work correctly
6 |
7 | ## 0.0.1
8 |
9 | - Initial version, created by Stagehand
10 |
--------------------------------------------------------------------------------
/chrome-app-with-polymer-dart/LICENSE:
--------------------------------------------------------------------------------
1 | Copyright (c) 2015, .
2 | All rights reserved.
3 |
4 | Redistribution and use in source and binary forms, with or without
5 | modification, are permitted provided that the following conditions are met:
6 | * Redistributions of source code must retain the above copyright
7 | notice, this list of conditions and the following disclaimer.
8 | * Redistributions in binary form must reproduce the above copyright
9 | notice, this list of conditions and the following disclaimer in the
10 | documentation and/or other materials provided with the distribution.
11 | * Neither the name of the nor the
12 | names of its contributors may be used to endorse or promote products
13 | derived from this software without specific prior written permission.
14 |
15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
16 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18 | DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY
19 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
21 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
22 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
24 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 |
--------------------------------------------------------------------------------
/chrome-app-with-polymer-dart/README.md:
--------------------------------------------------------------------------------
1 | # Dart Chrome apps with PolymerDart
2 |
3 | This is an example of how to use PolymerDart in a chrome apps.
4 |
5 | ## How to get all work together
6 |
7 | ### Step 1
8 |
9 | First create a polymer dart project using stagehand.
10 |
11 | ### Step 2
12 |
13 | When you have that open your pubspec.yaml and add the chrome dependencies you should have something like that :
14 |
15 | ```yaml
16 | dependencies:
17 | browser: any
18 | polymer: '>=0.15.4 <0.16.0'
19 | paper_elements: '>=0.6.1 <0.7.0'
20 | chrome: any
21 | ```
22 |
23 | ### Step 3
24 |
25 | After that add the chrome transformer and the dart2js transformer :
26 |
27 | ```yaml
28 | - chrome
29 | - $dart2js:
30 | csp: true
31 | ```
32 |
33 | ### Step 4
34 |
35 | Don't forget to add the background.js and the manifest.json inside your web directory.
36 |
37 | ### Step 5
38 |
39 | Build your application
40 |
41 |
42 | ### Step 6
43 |
44 | Load your unpacked extension from your build folder and launch it.
45 |
--------------------------------------------------------------------------------
/chrome-app-with-polymer-dart/build.dart:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2015, . All rights reserved. Use of this source code
2 | // is governed by a BSD-style license that can be found in the LICENSE file.
3 |
4 | // This file is only used by Dart Editor. It displays errors and warnings after
5 | // analyzing a polymer.dart app.
6 |
7 | export 'package:polymer/default_build.dart';
8 |
--------------------------------------------------------------------------------
/chrome-app-with-polymer-dart/lib/main_app.dart:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2015, . All rights reserved. Use of this source code
2 | // is governed by a BSD-style license that can be found in the LICENSE file.
3 |
4 | import 'dart:html';
5 |
6 | import 'package:chrome/chrome_app.dart' as chrome;
7 |
8 | import 'package:polymer/polymer.dart';
9 |
10 | @CustomTag('main-app')
11 | class MainApp extends PolymerElement {
12 | int _boundsChange = 100;
13 |
14 |
15 | /// Constructor used to create instance of MainApp.
16 | MainApp.created() : super.created();
17 |
18 | void resizeWindow() {
19 | chrome.ContentBounds bounds = chrome.app.window.current().getBounds();
20 |
21 | bounds.width += this._boundsChange;
22 | bounds.left -= this._boundsChange ~/ 2;
23 |
24 | chrome.app.window.current().setBounds(bounds);
25 |
26 | this._boundsChange *= -1;
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/chrome-app-with-polymer-dart/lib/main_app.html:
--------------------------------------------------------------------------------
1 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
35 |
Test
36 |
37 |
Hello world from PolymerDart!
38 |
39 |
40 |
Click me!
41 |
42 |
43 |
44 |
45 |
--------------------------------------------------------------------------------
/chrome-app-with-polymer-dart/pubspec.yaml:
--------------------------------------------------------------------------------
1 | name: 'chrome_app_with_polymer'
2 | version: 0.1.0
3 | description: >
4 | A starter template for a polymer.dart web app.
5 | #author:
6 | #homepage: https://www.example.com
7 | environment:
8 | sdk: '>=1.0.0 <2.0.0'
9 | dependencies:
10 | browser: any
11 | polymer: '>=0.15.4 <0.16.0'
12 | paper_elements: '>=0.6.1 <0.7.0'
13 | chrome: any
14 | transformers:
15 | - polymer:
16 | entry_points: web/index.html
17 | csp: true
18 | - chrome
19 | - $dart2js:
20 | csp: true
--------------------------------------------------------------------------------
/chrome-app-with-polymer-dart/web/apple-touch-icon-precomposed.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dart-gde/dart-chrome-app-samples/44ba20283aee00137277ddaf60abbd3e047a225b/chrome-app-with-polymer-dart/web/apple-touch-icon-precomposed.png
--------------------------------------------------------------------------------
/chrome-app-with-polymer-dart/web/background.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Created by kevin on 3/24/2015.
3 | */
4 |
5 | chrome.app.runtime.onLaunched.addListener(function(launchData) {
6 | chrome.app.window.create('index.html', {
7 | 'id': '_mainWindow', 'bounds': {'width': 800, 'height': 600 }
8 | });
9 | });
10 |
--------------------------------------------------------------------------------
/chrome-app-with-polymer-dart/web/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dart-gde/dart-chrome-app-samples/44ba20283aee00137277ddaf60abbd3e047a225b/chrome-app-with-polymer-dart/web/favicon.ico
--------------------------------------------------------------------------------
/chrome-app-with-polymer-dart/web/images/touch/chrome-touch-icon-192x192.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dart-gde/dart-chrome-app-samples/44ba20283aee00137277ddaf60abbd3e047a225b/chrome-app-with-polymer-dart/web/images/touch/chrome-touch-icon-192x192.png
--------------------------------------------------------------------------------
/chrome-app-with-polymer-dart/web/images/touch/ms-touch-icon-144x144-precomposed.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dart-gde/dart-chrome-app-samples/44ba20283aee00137277ddaf60abbd3e047a225b/chrome-app-with-polymer-dart/web/images/touch/ms-touch-icon-144x144-precomposed.png
--------------------------------------------------------------------------------
/chrome-app-with-polymer-dart/web/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 | chrome_app_with_polymer
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
--------------------------------------------------------------------------------
/chrome-app-with-polymer-dart/web/manifest.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "PolymerDart in Chrome apps",
3 | "version": "1",
4 |
5 | "manifest_version": 2,
6 |
7 | "icons": {
8 | },
9 |
10 | "app": {
11 | "background": {
12 | "scripts": ["background.js"]
13 | }
14 | }
15 | }
--------------------------------------------------------------------------------
/chrome-app-with-polymer-dart/web/robots.txt:
--------------------------------------------------------------------------------
1 | # www.robotstxt.org/
2 |
3 | # Allow crawling of all content
4 | User-agent: *
5 | Disallow:
6 |
--------------------------------------------------------------------------------
/chrome-app-with-polymer-dart/web/styles.css:
--------------------------------------------------------------------------------
1 | /* Copyright (c) 2015, . All rights reserved. Use of this source code */
2 | /* is governed by a BSD-style license that can be found in the LICENSE file. */
3 |
4 | body {
5 | font-family: RobotoDraft, sans-serif;
6 | color: #333;
7 | -webkit-user-select: none;
8 | -moz-user-select: none;
9 | -ms-user-select: none;
10 | user-select: none;
11 | -webkit-tap-highlight-color: rgba(0,0,0,0);
12 | -webkit-touch-callout: none;
13 | }
14 |
--------------------------------------------------------------------------------
/context-menu/README.md:
--------------------------------------------------------------------------------
1 | # Context menus
2 |
3 | Sample that shows how to use the [context menu API](http://developer.chrome.com/apps/contextMenus.html) in an app to manage various application context menus, such as menus that only apply to particular windows, menus that apply to selections or media types, and context menus that work on the app launcher.
4 |
5 | A single context menu structure is normally global to the entire app, and thus all windows would have the same menu. This sample uses a `focus` event handler in each window to detect when a window is brought to the foreground. When it is, the contents of the context menu are updated with that window's commands, while leaving the other menus intact. The `chrome.contextMenus.onClicked` event handler also only handles events that occur in that window.
6 |
7 | ## APIs
8 |
9 | * [Context menu API](http://developer.chrome.com/apps/contextMenus.html)
10 | * [Runtime](http://developer.chrome.com/apps/app.runtime.html)
11 | * [Window](http://developer.chrome.com/apps/app.window.html)
12 |
13 |
14 |
15 | ## Screenshot
16 | 
--------------------------------------------------------------------------------
/context-menu/pubspec.yaml:
--------------------------------------------------------------------------------
1 | name: context-menu
2 | description: A sample Chrome packaged application
3 | dependencies:
4 | chrome: any
5 | transformers:
6 | - chrome
7 |
--------------------------------------------------------------------------------
/context-menu/screenshot.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dart-gde/dart-chrome-app-samples/44ba20283aee00137277ddaf60abbd3e047a225b/context-menu/screenshot.png
--------------------------------------------------------------------------------
/context-menu/web/a.dart:
--------------------------------------------------------------------------------
1 |
2 | import 'dart:html';
3 |
4 | import "package:chrome/chrome_app.dart" as chrome;
5 |
6 | import "common.dart";
7 |
8 |
9 | void main() {
10 | bool focus = false;
11 | window.onLoad.listen((event) {
12 | log('Window A is loaded');
13 | setupContextMenu("windowA");
14 | });
15 |
16 | window.onBlur.listen((event) {
17 | log("Window A is blur");
18 | focus = false;
19 | });
20 |
21 | window.onFocus.listen((event) {
22 | log('Window A is focus');
23 | focus = true;
24 | setupContextMenu("windowA");
25 | });
26 |
27 | chrome.contextMenus.onClicked.listen((chrome.OnClickedEvent info) {
28 | clickOnContext(focus, 'A', info);
29 | });
30 | }
31 |
--------------------------------------------------------------------------------
/context-menu/web/a.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | Context menu
7 |
8 |
9 |
10 |