chrome apps & extensions

23
Chrome Apps & Extension

Upload: varun-raj

Post on 19-May-2015

324 views

Category:

Technology


2 download

TRANSCRIPT

Page 1: Chrome Apps & Extensions

Chrome Apps & Extension

Page 2: Chrome Apps & Extensions

About Me

Varun

RajWeb Developer | Internet Addict |

Android Fan Boy | Techie | Engineering

Student

Page 3: Chrome Apps & Extensions

Chrome Extensions and AppsLooking beyond browsing on Chrome

Page 4: Chrome Apps & Extensions

What is an Extension?

• A compressed package

• Extends the functionality of the browser

• Minimal or No UI

• Usually enhances functionality of websites or web apps

Page 5: Chrome Apps & Extensions

What is an App?

• Runs inside your browser

• Has a Dedicated User Interface

• Rich User Interaction

• Ex. Games and Photo Editors

Page 6: Chrome Apps & Extensions

What an Extension contains?

• manifest.json

• browser action or page action

• content script - CSS/JS

• background pages

• Other media files

Page 7: Chrome Apps & Extensions

Extension UIs

Browser Action Page Action

Page 8: Chrome Apps & Extensions

Layout of an Extension

• chrome.extension.*

• chrome.browserAction.*

• chrome.pageAction.*

• chrome.windows.*

• chrome.tabs.*

• chrome.bookmarks.*

• Does not access much of the native code

chrome - top-level object & is exposed to extensions

Page 9: Chrome Apps & Extensions

Manifest.json

For details, see Manifest Files.

{ "manifest_version": 2, "name": “HUG Chennai", "description": "This is a sample app", "version": "1.0",

"browser_action": { "default_icon": "icon.png", "default_popup": "popup.html" }, "permissions": [ "https://secure.flickr.com/" ]}

JSON

Page 10: Chrome Apps & Extensions

Architecture

• The background page

• UI pages

Page 11: Chrome Apps & Extensions

Background Pages

• Persistent Background Pages

• Event Pages

Page 12: Chrome Apps & Extensions

UI Pages

• Written in HTML

• Provides the UI for an Extension

• Ex. popup.html

Page 13: Chrome Apps & Extensions

Content Script

• Part of the loaded page

• Injects contents into the page using scripts

• Exchange messages to parent script

Page 14: Chrome Apps & Extensions

Where are extensions stored?http://dev.chromium.org/user-experience/user-data-directory

Windows :%userprofile%\Local Settings\Application Data\Google\Chrome\User Data\Default\Extensions

or

C:\Documents and Settings\Admin\Local Settings\Application Data\Google\Chrome\User Data\Default\Extensions

Linux : ~/.config/google-chrome/Default/Extensions/

Mac OSX : ~/Library/Application Support/Google/Chrome/Default

File:///

Page 15: Chrome Apps & Extensions

Demo Time !

Page 16: Chrome Apps & Extensions

Nothing works!

• Refused to load script from 'http://code.jquery.com/jquery-latest.js' because of Content-Security-Policy.

• Refused to execute inline script because of Content-Security-Policy.• Refused to execute inline event handler because of Content-Security-Policy.

Need to:

• Load external scripts over HTTPS

• Extract own scripts to .js files

• Remove inline event handlers

Page 17: Chrome Apps & Extensions

CSP-ready extension

<!DOCTYPE html><html><head><title>ManifestLint</title><script src="https://ajax.googleapis.com/.../jquery.min.js" type="text/javascript"></script><script src="main.js" type="text/javascript"></script></head><body>...

HTML

Page 18: Chrome Apps & Extensions

Chrome Apps

Page 19: Chrome Apps & Extensions

The App Architecture

Page 20: Chrome Apps & Extensions

Links

• Manifest versions:

o http://code.google.com/chrome/extensions/manifestVersion.html

• Content Security Policy:

o http://code.google.com/chrome/extensions/contentSecurityPolicy.html

• HTML5 sandbox attribute for iframes:

o http://www.whatwg.org/specs/web-apps/current-work/multipage/the-ifr

ame-element.html#attr-iframe-sandbox

Page 21: Chrome Apps & Extensions

Creating an App

1. Create manifest.json

2. Create the background script

3. Create the window page

4. Create the icons

5. Enable Chrome Flags: chrome://flags - Experimental Extension APIs

6. Load the app as Unpacked Extension

Page 22: Chrome Apps & Extensions

Making money out of Chrome Apps

● In-App Purchases

● Google Wallet

Page 23: Chrome Apps & Extensions

Contact [email protected]

Thank You !