SlideShare a Scribd company logo
EMPOWERING THE

MOBILE WEB
Chris Mills // Mozilla cmills@mozilla.com // @chrisdavidmills
don’t stress about taking notes:
๏ These slides are all at slideshare.net/chrisdavidmills
๏ developer.mozilla.org
๏ @chrisdavidmills
๏ cmills@mozilla.com
๏ #mdn irc channel on mozilla irc
๏ dev-mdc@lists.mozilla.org mailing list
๏ heavy metal drummer turned web nerd
๏ tech writer @ mozilla
๏ web tinkerer (HTML, CSS, JS)
๏ accessibility whiner
๏ educator
who am i?
mdn!!
what is THE

MOBILE WEB?
what is the mobile web?
wap
๏ (blarrrgh, awful...)
what is the mobile web?
the web for mobile phones
๏ real mobile browsers
๏ separate web sites for mobiles
๏ lots of ua sniffing crimes
what is the mobile web?
the web as it is experienced on mobiles/tablets/etc.
๏ more thought given to ux; to context
๏ progressive enhancement
๏ feature detection
๏ responsive
what is the mobile web?
the web while you’re on the move
๏ geolocation
๏ offline data storage
what is the mobile web?
web technologies providing “native” capabilities
๏ installable apps
๏ control over device hardware and key services
๏ app ecosystem/marketplace
๏ fully functional offline apps
๏ high fps performance
what’s the

problem?
web versus native, the age-old struggle
the usual arguments
native is better?
๏ faster?
๏ more integrated, consistent experience?
๏ better developer ecosystem?
๏ more secure?
the usual arguments
๏ web sites accessing other tabs or apps?
๏ web sites accessing

camera

contacts

e-mail?
solutions,

moz style
solutions
we’ve been working hard on this at mozilla
๏ app ecosystem
๏ firefox os
๏ apis
๏ developer experience and tools
๏ performance
app ecosystem
installable apps
not a new phenomenon, but...
๏ pretty recent concept for the web
๏ manifest file defines app (manifest.webapp)
๏ installation controlled by app installation and management apis
{
"version": "0.1",
"name": "To-do alarms",
"description": "My awesome open web app",
"launch_path": "/index.html",
"icons": {
"128": "/img/icon-128.png"
},
"developer": {
"name": "Chris Mills",
"url": "http://yourawesomeapp.com"
},
"locales": {
"es": {
"description": "Su nueva aplicación impresionante Open Web",
"developer": {
"url": "http://yourawesomeapp.com"
}
}, manifest example
var manifest_url = location.href.substring(0,
location.href.lastIndexOf("/")) + "/manifest.webapp";
function install() {
// install the app
var install = navigator.mozApps.install(manifest_url);
install.onsuccess = function(data) {
// App is installed, do something if you like
};
install.onerror = function() {
// App wasn't installed, info is in
// install.error.name
alert(install.error.name);
};
};
installation example
app types
Apps can be:
๏ hosted: just like a normal web site, but with a manifest and install
functionality
๏ packaged: zipped up, hosted somewhere (like the firefox
marketplace)
app stores
you are free to distribute your apps how you like
๏ marketplace.firefox.com
๏ team of reviewers verify apps before they are accepted
๏ you can also host your own apps
๏ or set up your own marketplace
app payments
now you can charge money for web apps
๏ payments api (mozpay) that uses the bango payments provider
๏ receipt verification to make sure payments are completed
๏ in-app payments also available
web runtime
web rt allows installable apps to work on other platforms
๏ apk wrapper for android apps, which includes native equivalents
where possible
๏ similar native wrappers for desktop platforms coming up
๏ firefox marketplace/Firefox will generate these
firefox os
firefox os!
our mobile platform
๏ totally built on open web technologies
๏ mostly standards
๏ some are new inventions, with standardization being worked on
๏ designed for low power devices
successes so far
lots of success so far:
๏ 4 hardware partners
๏ 16 launches in 15 countries
๏ 30% market share with TEF in Uruguay; 12% market share with TEF
in Colombia
๏ vibrant developer community
๏ developer preview devices available
architecture
three main layers
๏ gonk: linux kernel plus hardware abstraction layer
๏ gecko: entire system runs on our rendering engine
๏ gaia: ui plus default system apps
architecture
everything runs in gecko
๏ each app runs in an iframe, hanging off main process
๏ this enforces cross app security (sandbox)
๏ as does api permissions system (see later)
๏ oom errors handled via a priority system
apis
apis!!!
we want to control everything from the web
๏ so we’re creating apis to handle access to device hardware, system
functions, etc.
๏ security handled by permissions, in the manifest
api permissions
different apis have different permission levels:
๏ standard apis can be accessed by any app
๏ privileged apis can only be used in a packaged, verified apps (e.g.
contacts, device storage, keyboard)
๏ certified apis can only be used by vendor-installed apps (e.g.
camera, sms, dialer, bluetooth)
var pick = new MozActivity({
name: "pick",
data: {
type: ["image/png", "image/jpg", "image/jpeg"]


}
});
web activities (intents)
web activities
pick.onsuccess = function () {
// Create image and set the returned blob as the src
var img = document.createElement("img");
img.src = window.URL.createObjectURL(this.result.blob);
// Present that image in your app
var imagePresenter = document.querySelector("#image-presenter");
imagePresenter.appendChild(img);
};
pick.onerror = function () {
// If an error occurred or the user canceled the activity
alert("Can't view the image!");
};
web activities
var img = '/to-do-notifications/img/icon-128.png';
var text = 'HEY! Your task "' + title + '" is now overdue.';
var notification = new Notification('To do list', { body: text, icon:
img });
notification
!
var myAlarmDate = new Date(month.value + " " + day.value + ", " +
year.value + " " + hours.value + ":" + minutes.value + ":00");
!
var data = {
task: title.value
}
!
var request = navigator.mozAlarms.add(myAlarmDate, "ignoreTimezone",
data);
!
request.onsuccess = function () {
console.log("Alarm successfully scheduled");
var alarmRequest = navigator.mozAlarms.getAll();
alarmRequest.onsuccess = function() {
newAlarmId = this.result[(this.result.length)-1].id;
}
};
alarm
navigator.mozSetMessageHandler("alarm", function (alarm) {
// only launch a notification if the Alarm is of the right type for this
app
if(alarm.data.task) {
// Create a notification when the alarm is due
new Notification("Your task " + alarm.data.task + " is now due!");
updateNotified(alarm.data.task);
}
});
alarm + notification
alarm + notification
window.navigator.vibrate(200); // vibrate for 200ms
!
window.navigator.vibrate([100,30,100,30,100,200,200,30,200,30,200,200,10
0,30,100,30,100]); // Vibrate 'SOS' in Morse.
vibration
window.addEventListener('devicelight', function(deviceLightEvent) {
/* Check ambient light status */
if (deviceLightEvent.value > 500) { // snow
_self.setSnow();
}
else if (deviceLightEvent.value > 100) { // morning
_self.setMorning();
}
else if (deviceLightEvent.value > 10) { // evening
_self.setEvening();
}
else { // night
_self.setNight();
}
});
light sensor
light sensor
light sensor
window.addEventListener("deviceorientation", handleOrientation, true);
!
function handleOrientation(event) {
var alpha = event.alpha;
var beta = event.beta;
var gamma = event.gamma;
!
// Do stuff with the new orientation data
}
device orientation
device orientation
alpha
betagamma
window.addEventListener('devicemotion', function(event) {
console.log(event.acceleration.x + ' m/s2');
});
device motion
var person = new mozContact();
person.givenName = ["John"];
person.familyName = ["Doe"];
person.nickname = ["No kidding"];
!
var person = new mozContact(contactData); // Firefox OS 1.3 takes a
parameter to initialize the object
if ("init" in person) {
// Firefox OS 1.2 and below uses a "init" method to initialize the
object
person.init(contactData);
}
!
// save the new contact
var saving = navigator.mozContacts.save(person);
!
saving.onsuccess = function() {
console.log('new contact saved');
}; contacts
var message = "Hi!";
var number = "1234"; // There are several ways to retrieve a valid phone
number
!
navigator.mozMobileMessage.send(number, message);
SMS
regular web stuff!
other standards features also work great in this context:
๏ indexeddb/localstorage
๏ web rtc/getusermedia
๏ css animations
๏ SVg
developer

experience
developer experience
we want to give the web a first class development experience,
alongside native ecosystems:
๏ documentation
๏ developer tools
๏ frameworks, templates, libraries
documentation
announce new things, provide useful references, give
recommendations
๏ hacks blog
๏ mdn app center
developer tools
developer tools
๏ firefox’s standard toolbox
๏ app manager
๏ remote debugging
๏ you can run gaia inside desktop firefox too
frameworks and libraries
ready made code to make development easier
๏ mortar app templates
๏ brick: web components for building up interfaces quickly
๏ libraries to solve real world problems, for example localforage
๏ firefox os boilerplate: great resource for learning about fxos
๏ phonegap now has firefox os as a target platform
performance

enhancers
performance enhancers
because the web can still be a bit slow
๏ web workers
๏ asm.js
๏ emscripten
web workers
web workers
๏ run scripts in a background thread
๏ don’t block the main thread execution
๏ specify a script to run in the background
๏ pass messages between the two
asm.js
asm.js
๏ just javascript
๏ a very efficient low-level subset
๏ suitable for ahead-of-time optimizing compilation
๏ Unity3d now has asm.js/WebGL support
emscripten
emscripteN
๏ an LLVM to javascript compiler (well, asm.js, specifically)
๏ compile c++ (and others) into JS and run it on the web
๏ = “very fast shit” ™
resources
๏ look up localforage - polyfill for indexeddb/websql/localstorage
๏ simplewebrtc.com - simple webrtc library
๏ animate.css - good library for css animations
๏ raphaeljs.com, d3js.org - svg libraries
๏ emscripten.org - try quakejs.com and unrealengine.com/html5 in
a recent version of firefox, opera or chrome
๏ asmjs.org
๏ MDN app center: developer.mozilla.org/en-US/Apps
๏ hacks blog: hacks.mozilla.org
thanks for

listening!!
slideshare.net/chrisdavidmills cmills@mozilla.com // @chrisdavidmills
The end

More Related Content

PDF
Web versus Native: round 1!
PDF
APIs, now and in the future
PDF
APIs for modern web apps
PDF
High Performance JavaScript - WebDirections USA 2010
PDF
High Performance JavaScript - jQuery Conference SF Bay Area 2010
PDF
Instant and offline apps with Service Worker
PPTX
Enough with the JavaScript already!
PDF
Performance on the Yahoo! Homepage
Web versus Native: round 1!
APIs, now and in the future
APIs for modern web apps
High Performance JavaScript - WebDirections USA 2010
High Performance JavaScript - jQuery Conference SF Bay Area 2010
Instant and offline apps with Service Worker
Enough with the JavaScript already!
Performance on the Yahoo! Homepage

What's hot (19)

PDF
High Performance JavaScript (YUIConf 2010)
PPTX
HTML5 Web Workers-unleashed
KEY
An Introduction to webOS
PDF
High Performance JavaScript (Amazon DevCon 2011)
PDF
React & The Art of Managing Complexity
PDF
Building Cross Platform Apps with Electron
KEY
Getting Started with HTML 5 Web workers
PDF
Keeping the frontend under control with Symfony and Webpack
PDF
Web workers
PPT
Responsive interfaces
PDF
Learning from the Best jQuery Plugins
PDF
JavaScript Web Workers
PPTX
Disrupting the application eco system with progressive web applications
PDF
PWA 與 Service Worker
PDF
High Performance JavaScript - Fronteers 2010
PDF
Chrome enchanted 2015
PDF
How to Develop a Rich, Native-quality User Experience for Mobile Using Web St...
PPTX
Don't Over-React - just use Vue!
PDF
Cool like a Frontend Developer: Grunt, RequireJS, Bower and other Tools
High Performance JavaScript (YUIConf 2010)
HTML5 Web Workers-unleashed
An Introduction to webOS
High Performance JavaScript (Amazon DevCon 2011)
React & The Art of Managing Complexity
Building Cross Platform Apps with Electron
Getting Started with HTML 5 Web workers
Keeping the frontend under control with Symfony and Webpack
Web workers
Responsive interfaces
Learning from the Best jQuery Plugins
JavaScript Web Workers
Disrupting the application eco system with progressive web applications
PWA 與 Service Worker
High Performance JavaScript - Fronteers 2010
Chrome enchanted 2015
How to Develop a Rich, Native-quality User Experience for Mobile Using Web St...
Don't Over-React - just use Vue!
Cool like a Frontend Developer: Grunt, RequireJS, Bower and other Tools
Ad

Viewers also liked (20)

PPTX
GOBIERNO ELECTRÓNICO COMO HERRAMIENTA DE GESTIÓN PÚBLICA EN VENEZUELA
PPTX
"basic of Costing" hearing session
PDF
Book Paula S.
PPTX
Apresentações: o que os melhores apresentadores sabem, fazem e falam
PPTX
Ecuaciones de tercer grado
PDF
Virginia Startup to Deliver Cheap and Healthy Meals to DC in Under 20 Minutes
PPTX
5 BS Facts About Data Privacy Everyone Thinks Are True
PDF
Travel pdf
PPTX
Puentes colgantes
PPTX
Open House 2010
DOCX
Pautas para la gestión de los árbitros 2
DOCX
DOCX
085277450480 087766274593 082123575794 085360504502 085360908052 ...
PPTX
Belgian mobile app developer profile
PDF
Doing the open source thingy
PPT
Plantilla powerpoint
PDF
Y jmrxzmobile rsearch case study ver.final
PPT
Business Expansion Planning Srategy
PPT
Tarea bulimia
GOBIERNO ELECTRÓNICO COMO HERRAMIENTA DE GESTIÓN PÚBLICA EN VENEZUELA
"basic of Costing" hearing session
Book Paula S.
Apresentações: o que os melhores apresentadores sabem, fazem e falam
Ecuaciones de tercer grado
Virginia Startup to Deliver Cheap and Healthy Meals to DC in Under 20 Minutes
5 BS Facts About Data Privacy Everyone Thinks Are True
Travel pdf
Puentes colgantes
Open House 2010
Pautas para la gestión de los árbitros 2
085277450480 087766274593 082123575794 085360504502 085360908052 ...
Belgian mobile app developer profile
Doing the open source thingy
Plantilla powerpoint
Y jmrxzmobile rsearch case study ver.final
Business Expansion Planning Srategy
Tarea bulimia
Ad

Similar to Empowering the "mobile web" (20)

PDF
Webapi
PDF
Web APIs & Apps - Mozilla
PDF
WebAPIs & Apps - Mozilla London
PPT
Firefox os-introduction
PDF
Firefox OS workshop, JSFoo, India
PDF
Fixing the mobile web - Internet World Romania
PDF
Frontend. Global domination.
PDF
Front-end. Global domination
PDF
(Christian heilman) firefox
PDF
Firefox OS Weekend
PDF
Bringing the open web and APIs to mobile devices with Firefox OS - Whisky W...
PDF
Firefox OS - HTML5 for a truly world-wide-web
PDF
Firefox OS - Answering global challenges
KEY
Open Web Device: The first phone running Firefox OS!
PDF
Firefox OS Apps & APIs - Dutch Mobile Conference / Serbia & Montenegro App da...
PDF
Øredev2013 - FirefoxOS - the platform HTML5 deserves
PDF
Firefox OS, HTML5 to the next level - Python Montreal - 2014-05-12
PPTX
Firefox OS, a startup opportunity - Mobile Startups Toronto & HTML Toronto me...
PDF
Firefox OS Apps and Web APIs
PDF
HTML for the Mobile Web, Firefox OS - All Things Open - 2014-10-22
Webapi
Web APIs & Apps - Mozilla
WebAPIs & Apps - Mozilla London
Firefox os-introduction
Firefox OS workshop, JSFoo, India
Fixing the mobile web - Internet World Romania
Frontend. Global domination.
Front-end. Global domination
(Christian heilman) firefox
Firefox OS Weekend
Bringing the open web and APIs to mobile devices with Firefox OS - Whisky W...
Firefox OS - HTML5 for a truly world-wide-web
Firefox OS - Answering global challenges
Open Web Device: The first phone running Firefox OS!
Firefox OS Apps & APIs - Dutch Mobile Conference / Serbia & Montenegro App da...
Øredev2013 - FirefoxOS - the platform HTML5 deserves
Firefox OS, HTML5 to the next level - Python Montreal - 2014-05-12
Firefox OS, a startup opportunity - Mobile Startups Toronto & HTML Toronto me...
Firefox OS Apps and Web APIs
HTML for the Mobile Web, Firefox OS - All Things Open - 2014-10-22

More from Chris Mills (20)

PDF
More efficient, usable web
PDF
Feedback handling, community wrangling, panhandlin’
PDF
Guerrilla education
PDF
BrazilJS MDN
PDF
Documentation and publishing
PDF
MDN is easy!
PDF
Getting rid of images with CSS
PDF
Future layouts
PDF
Laying out the future
PDF
Accessibility doesn't exist
PDF
Responsive web design standards?
PDF
Adapt! Media queries and viewport
PDF
Adapt and respond: keeping responsive into the future
KEY
Angels versus demons: balancing shiny and inclusive
PDF
HTML5 and CSS3: does now really mean now?
PDF
The W3C and the web design ecosystem
PDF
HTML5 Pearson preso
PDF
Brave new world of HTML5
KEY
Inclusive design: real accessibility for everyone
KEY
The web standards gentleman: a matter of (evolving) standards)
More efficient, usable web
Feedback handling, community wrangling, panhandlin’
Guerrilla education
BrazilJS MDN
Documentation and publishing
MDN is easy!
Getting rid of images with CSS
Future layouts
Laying out the future
Accessibility doesn't exist
Responsive web design standards?
Adapt! Media queries and viewport
Adapt and respond: keeping responsive into the future
Angels versus demons: balancing shiny and inclusive
HTML5 and CSS3: does now really mean now?
The W3C and the web design ecosystem
HTML5 Pearson preso
Brave new world of HTML5
Inclusive design: real accessibility for everyone
The web standards gentleman: a matter of (evolving) standards)

Recently uploaded (20)

PDF
CIFDAQ's Market Insight: SEC Turns Pro Crypto
PPTX
Big Data Technologies - Introduction.pptx
PPTX
MYSQL Presentation for SQL database connectivity
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PDF
NewMind AI Weekly Chronicles - August'25 Week I
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PDF
Shreyas Phanse Resume: Experienced Backend Engineer | Java • Spring Boot • Ka...
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PDF
KodekX | Application Modernization Development
PDF
Modernizing your data center with Dell and AMD
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PDF
cuic standard and advanced reporting.pdf
PDF
Review of recent advances in non-invasive hemoglobin estimation
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PPTX
A Presentation on Artificial Intelligence
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PPTX
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
CIFDAQ's Market Insight: SEC Turns Pro Crypto
Big Data Technologies - Introduction.pptx
MYSQL Presentation for SQL database connectivity
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
NewMind AI Weekly Chronicles - August'25 Week I
Agricultural_Statistics_at_a_Glance_2022_0.pdf
Shreyas Phanse Resume: Experienced Backend Engineer | Java • Spring Boot • Ka...
Advanced methodologies resolving dimensionality complications for autism neur...
Reach Out and Touch Someone: Haptics and Empathic Computing
KodekX | Application Modernization Development
Modernizing your data center with Dell and AMD
The Rise and Fall of 3GPP – Time for a Sabbatical?
cuic standard and advanced reporting.pdf
Review of recent advances in non-invasive hemoglobin estimation
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
A Presentation on Artificial Intelligence
Building Integrated photovoltaic BIPV_UPV.pdf
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx

Empowering the "mobile web"

  • 1. EMPOWERING THE
 MOBILE WEB Chris Mills // Mozilla cmills@mozilla.com // @chrisdavidmills
  • 2. don’t stress about taking notes: ๏ These slides are all at slideshare.net/chrisdavidmills ๏ developer.mozilla.org ๏ @chrisdavidmills ๏ cmills@mozilla.com ๏ #mdn irc channel on mozilla irc ๏ dev-mdc@lists.mozilla.org mailing list
  • 3. ๏ heavy metal drummer turned web nerd ๏ tech writer @ mozilla ๏ web tinkerer (HTML, CSS, JS) ๏ accessibility whiner ๏ educator who am i? mdn!!
  • 5. what is the mobile web? wap ๏ (blarrrgh, awful...)
  • 6. what is the mobile web? the web for mobile phones ๏ real mobile browsers ๏ separate web sites for mobiles ๏ lots of ua sniffing crimes
  • 7. what is the mobile web? the web as it is experienced on mobiles/tablets/etc. ๏ more thought given to ux; to context ๏ progressive enhancement ๏ feature detection ๏ responsive
  • 8. what is the mobile web? the web while you’re on the move ๏ geolocation ๏ offline data storage
  • 9. what is the mobile web? web technologies providing “native” capabilities ๏ installable apps ๏ control over device hardware and key services ๏ app ecosystem/marketplace ๏ fully functional offline apps ๏ high fps performance
  • 11. web versus native, the age-old struggle
  • 12. the usual arguments native is better? ๏ faster? ๏ more integrated, consistent experience? ๏ better developer ecosystem? ๏ more secure?
  • 13. the usual arguments ๏ web sites accessing other tabs or apps? ๏ web sites accessing
 camera
 contacts
 e-mail?
  • 15. solutions we’ve been working hard on this at mozilla ๏ app ecosystem ๏ firefox os ๏ apis ๏ developer experience and tools ๏ performance
  • 17. installable apps not a new phenomenon, but... ๏ pretty recent concept for the web ๏ manifest file defines app (manifest.webapp) ๏ installation controlled by app installation and management apis
  • 18. { "version": "0.1", "name": "To-do alarms", "description": "My awesome open web app", "launch_path": "/index.html", "icons": { "128": "/img/icon-128.png" }, "developer": { "name": "Chris Mills", "url": "http://yourawesomeapp.com" }, "locales": { "es": { "description": "Su nueva aplicación impresionante Open Web", "developer": { "url": "http://yourawesomeapp.com" } }, manifest example
  • 19. var manifest_url = location.href.substring(0, location.href.lastIndexOf("/")) + "/manifest.webapp"; function install() { // install the app var install = navigator.mozApps.install(manifest_url); install.onsuccess = function(data) { // App is installed, do something if you like }; install.onerror = function() { // App wasn't installed, info is in // install.error.name alert(install.error.name); }; }; installation example
  • 20. app types Apps can be: ๏ hosted: just like a normal web site, but with a manifest and install functionality ๏ packaged: zipped up, hosted somewhere (like the firefox marketplace)
  • 21. app stores you are free to distribute your apps how you like ๏ marketplace.firefox.com ๏ team of reviewers verify apps before they are accepted ๏ you can also host your own apps ๏ or set up your own marketplace
  • 22. app payments now you can charge money for web apps ๏ payments api (mozpay) that uses the bango payments provider ๏ receipt verification to make sure payments are completed ๏ in-app payments also available
  • 23. web runtime web rt allows installable apps to work on other platforms ๏ apk wrapper for android apps, which includes native equivalents where possible ๏ similar native wrappers for desktop platforms coming up ๏ firefox marketplace/Firefox will generate these
  • 25. firefox os! our mobile platform ๏ totally built on open web technologies ๏ mostly standards ๏ some are new inventions, with standardization being worked on ๏ designed for low power devices
  • 26. successes so far lots of success so far: ๏ 4 hardware partners ๏ 16 launches in 15 countries ๏ 30% market share with TEF in Uruguay; 12% market share with TEF in Colombia ๏ vibrant developer community ๏ developer preview devices available
  • 27. architecture three main layers ๏ gonk: linux kernel plus hardware abstraction layer ๏ gecko: entire system runs on our rendering engine ๏ gaia: ui plus default system apps
  • 28. architecture everything runs in gecko ๏ each app runs in an iframe, hanging off main process ๏ this enforces cross app security (sandbox) ๏ as does api permissions system (see later) ๏ oom errors handled via a priority system
  • 29. apis
  • 30. apis!!! we want to control everything from the web ๏ so we’re creating apis to handle access to device hardware, system functions, etc. ๏ security handled by permissions, in the manifest
  • 31. api permissions different apis have different permission levels: ๏ standard apis can be accessed by any app ๏ privileged apis can only be used in a packaged, verified apps (e.g. contacts, device storage, keyboard) ๏ certified apis can only be used by vendor-installed apps (e.g. camera, sms, dialer, bluetooth)
  • 32. var pick = new MozActivity({ name: "pick", data: { type: ["image/png", "image/jpg", "image/jpeg"] 
 } }); web activities (intents)
  • 34. pick.onsuccess = function () { // Create image and set the returned blob as the src var img = document.createElement("img"); img.src = window.URL.createObjectURL(this.result.blob); // Present that image in your app var imagePresenter = document.querySelector("#image-presenter"); imagePresenter.appendChild(img); }; pick.onerror = function () { // If an error occurred or the user canceled the activity alert("Can't view the image!"); }; web activities
  • 35. var img = '/to-do-notifications/img/icon-128.png'; var text = 'HEY! Your task "' + title + '" is now overdue.'; var notification = new Notification('To do list', { body: text, icon: img }); notification
  • 36. ! var myAlarmDate = new Date(month.value + " " + day.value + ", " + year.value + " " + hours.value + ":" + minutes.value + ":00"); ! var data = { task: title.value } ! var request = navigator.mozAlarms.add(myAlarmDate, "ignoreTimezone", data); ! request.onsuccess = function () { console.log("Alarm successfully scheduled"); var alarmRequest = navigator.mozAlarms.getAll(); alarmRequest.onsuccess = function() { newAlarmId = this.result[(this.result.length)-1].id; } }; alarm
  • 37. navigator.mozSetMessageHandler("alarm", function (alarm) { // only launch a notification if the Alarm is of the right type for this app if(alarm.data.task) { // Create a notification when the alarm is due new Notification("Your task " + alarm.data.task + " is now due!"); updateNotified(alarm.data.task); } }); alarm + notification
  • 39. window.navigator.vibrate(200); // vibrate for 200ms ! window.navigator.vibrate([100,30,100,30,100,200,200,30,200,30,200,200,10 0,30,100,30,100]); // Vibrate 'SOS' in Morse. vibration
  • 40. window.addEventListener('devicelight', function(deviceLightEvent) { /* Check ambient light status */ if (deviceLightEvent.value > 500) { // snow _self.setSnow(); } else if (deviceLightEvent.value > 100) { // morning _self.setMorning(); } else if (deviceLightEvent.value > 10) { // evening _self.setEvening(); } else { // night _self.setNight(); } }); light sensor
  • 43. window.addEventListener("deviceorientation", handleOrientation, true); ! function handleOrientation(event) { var alpha = event.alpha; var beta = event.beta; var gamma = event.gamma; ! // Do stuff with the new orientation data } device orientation
  • 46. var person = new mozContact(); person.givenName = ["John"]; person.familyName = ["Doe"]; person.nickname = ["No kidding"]; ! var person = new mozContact(contactData); // Firefox OS 1.3 takes a parameter to initialize the object if ("init" in person) { // Firefox OS 1.2 and below uses a "init" method to initialize the object person.init(contactData); } ! // save the new contact var saving = navigator.mozContacts.save(person); ! saving.onsuccess = function() { console.log('new contact saved'); }; contacts
  • 47. var message = "Hi!"; var number = "1234"; // There are several ways to retrieve a valid phone number ! navigator.mozMobileMessage.send(number, message); SMS
  • 48. regular web stuff! other standards features also work great in this context: ๏ indexeddb/localstorage ๏ web rtc/getusermedia ๏ css animations ๏ SVg
  • 50. developer experience we want to give the web a first class development experience, alongside native ecosystems: ๏ documentation ๏ developer tools ๏ frameworks, templates, libraries
  • 51. documentation announce new things, provide useful references, give recommendations ๏ hacks blog ๏ mdn app center
  • 52. developer tools developer tools ๏ firefox’s standard toolbox ๏ app manager ๏ remote debugging ๏ you can run gaia inside desktop firefox too
  • 53. frameworks and libraries ready made code to make development easier ๏ mortar app templates ๏ brick: web components for building up interfaces quickly ๏ libraries to solve real world problems, for example localforage ๏ firefox os boilerplate: great resource for learning about fxos ๏ phonegap now has firefox os as a target platform
  • 55. performance enhancers because the web can still be a bit slow ๏ web workers ๏ asm.js ๏ emscripten
  • 56. web workers web workers ๏ run scripts in a background thread ๏ don’t block the main thread execution ๏ specify a script to run in the background ๏ pass messages between the two
  • 57. asm.js asm.js ๏ just javascript ๏ a very efficient low-level subset ๏ suitable for ahead-of-time optimizing compilation ๏ Unity3d now has asm.js/WebGL support
  • 58. emscripten emscripteN ๏ an LLVM to javascript compiler (well, asm.js, specifically) ๏ compile c++ (and others) into JS and run it on the web ๏ = “very fast shit” ™
  • 59. resources ๏ look up localforage - polyfill for indexeddb/websql/localstorage ๏ simplewebrtc.com - simple webrtc library ๏ animate.css - good library for css animations ๏ raphaeljs.com, d3js.org - svg libraries ๏ emscripten.org - try quakejs.com and unrealengine.com/html5 in a recent version of firefox, opera or chrome ๏ asmjs.org ๏ MDN app center: developer.mozilla.org/en-US/Apps ๏ hacks blog: hacks.mozilla.org