WebRTC�
Chrome Appsで作る新しいユーザー体験
Eiji Kitamura @agektmr
Today's menu
Chrome Apps
Introduction
Chrome Apps v1
"Packaged apps deliver an experience as capable as a native app, but as safe as a web page. Just like web apps, packaged apps are written in HTML5, JavaScript, and CSS."
Chrome Apps v2 will bring...
Demo
Chrome Music Player
http://github.com/agektmr/ChromeMusicPlayer
Chrome Music Player
mediaGalleries API
ID3 parser
Audio
AngularJS
IndexedDB
FileSystem
How does Chrome Music Player work?
Chrome Music Player
IndexedDB
FileSystem
Components
yeoman
Modern workflows for modern web apps
What's yeoman?
Life of Chrome Apps
Event Pages
background.js
chrome.app.runtime.onLaunched.addListener(function() {
chrome.app.window.create('index.html', {
width: 840,
minWidth: 770,
height: 500,
minHeight: 400,
singleton: true
}, function(win) {
...
});
});
AngularJS
HTML enhanced for web apps!
What's AngularJS?
Live coding
Introduction to AngualrJS
chrome.mediaGalleries API
chrome.mediaGalleries.getMediaFileSystems({
interactive: 'if_needed'
}, function(localfilesystem) {
localfilesystem.forEach(function(fs) {
var metadata = chrome.mediaGalleries.getMediaFileSystemMetadata(fs);
if (metadata.name === 'Music') {
mediaRoot = fs.root;
}
});
});
IndexedDB API
var music = db.createObjectStore('music', {keyPath: 'path'});
music.createIndex('name', 'name', {unique: false});
music.createIndex('path', 'path', {unique: false});
music.createIndex('artist', 'artist', {unique: false});
music.createIndex('title', 'title', {unique: false});
FileSystem API
filer.js で UNIX コマンドライクに操作
filer.cd('/', function(dir) {
filer.write(entry.name, {data:file, type:file.type},
function(fileEntry, fileWriter)
console.log(fileEntry, fileWriter);
});
});
- JavaScript-ID3-Reader for reading MP3's ID3 tag
- LESS for better CSS management
Other APIs
One more thing...
Content Security Policy
"Content Security Policy (CSP) は、クロスサイトスクリプティング (XSS) やデータインジェクション攻撃を含む、よく知られた種類の攻撃を検出して軽減する、セキュリティの追加レイヤーです。"
Introducing Content Security Policy
(Mozilla Developer Network)
What is Content Security Policy?
X-Content-Security-Policy: allow 'self'; img-src 'self' data:
Content Security Policy on Chrome Apps
dom.innerHTML = 'this is innerHTML';
<div onclick="javascript:alert('test');">button</div>
厳しいデフォルトポリシー
Work around
Thanks!
Eiji Kitamura @agektmr
�