Slide 1

Slide 1 text

No content

Slide 2

Slide 2 text

Sept 9, 2009 Many many extensions

Slide 3

Slide 3 text

DOCS developer.chrome.com/ extensions STORE chrome.google.com/webstore/ category/extensions

Slide 4

Slide 4 text

Manipulate any (set of) pages Provide notifications Deep web app integration

Slide 5

Slide 5 text

Painless Payments for Droids Tim Messerschmidt

Slide 6

Slide 6 text

Auto updating OS independent Step up to chrome apps

Slide 7

Slide 7 text

No content

Slide 8

Slide 8 text

The manifest Manifest.json {      "name":  "Demo  Extension",      "version":  "0.0.1",      "manifest_version":  2   }   Chrome://extensions

Slide 9

Slide 9 text

THE BARE BASICS

Slide 10

Slide 10 text

No content

Slide 11

Slide 11 text

UI BUILDING BLOCKS BROWSER ACTIONS {      "name":  "My  extension",      ...      "browser_action":  {          "default_icon":  {                                        //  optional              "19":  "images/icon19.png",                  //  optional              "38":  "images/icon38.png"                    //  optional          },          "default_title":  "Google  Mail",            //  optional          "default_popup":  "popup.html"                //  optional      },      ...   }  

Slide 12

Slide 12 text

UI BUILDING BLOCKS BROWSER ACTIONS Icon Badge Tooltip popup

Slide 13

Slide 13 text

UI BUILDING BLOCKS PAGE ACTIONS {      "name":  "My  extension",      ...      "page_action":  {          "default_icon":  {                                        //  optional              "19":  "images/icon19.png",                      //  optional              "38":  "images/icon38.png"                        //  optional          },          "default_title":  "Google  Mail",            //  optional          "default_popup":  "popup.html"                //  optional      },      ...   }    

Slide 14

Slide 14 text

UI BUILDING BLOCKS PAGE ACTIONS Icon Tooltip Popup No badge Not shown until needed

Slide 15

Slide 15 text

There can only be one

Slide 16

Slide 16 text

UI BUILDING BLOCKS Desktop notifications {      "name":  "My  extension",      "manifest_version":  2,      ...      "permissions":  [          "notifications"      ],      ...   }  

Slide 17

Slide 17 text

UI BUILDING BLOCKS Desktop notifications

Slide 18

Slide 18 text

UI BUILDING BLOCKS Options page {      "name":  "My  extension",      ...      "options_page":  "options.html",      ...   }    

Slide 19

Slide 19 text

UI BUILDING BLOCKS Override pages omnibox Context menus html

Slide 20

Slide 20 text

No content

Slide 21

Slide 21 text

ADVANCED INTERACTION xhr

Slide 22

Slide 22 text

ADVANCED INTERACTION permissions {      "name":  "My  extension",      ...      "permissions":  [          "http://www.google.com/",          "https://www.google.com/",          "notifications"      ],      ...   }     Chrome.* apis developer.chrome.com/extensions/api_index.html

Slide 23

Slide 23 text

ADVANCED INTERACTION xhr var  xhr  =  new  XMLHttpRequest();   xhr.open("GET",  "http://api.example.com/data.json",  true);   xhr.onreadystatechange  =  function()  {      if  (xhr.readyState  ==  4)  {          //  JSON.parse  does  not  evaluate  the  attacker's  scripts.          var  resp  =  JSON.parse(xhr.responseText);      }   }   xhr.send();  

Slide 24

Slide 24 text

ADVANCED INTERACTION Content scripts

Slide 25

Slide 25 text

ADVANCED INTERACTION Content scripts {      "name":  "My  extension",      ...      "content_scripts":  [          {              "matches":  ["http://www.google.com/*"],              "css":  ["mystyles.css"],              "js":  ["jquery.js",  "myscript.js"]          }      ],      ...   }  

Slide 26

Slide 26 text

ADVANCED INTERACTION Content scripts No interaction with JS on page No access to most chrome.* apis

Slide 27

Slide 27 text

ADVANCED INTERACTION DOM   CONTENT   SCRIPT   INLINE  JS   Shared dom with different scopes

Slide 28

Slide 28 text

ADVANCED INTERACTION Content scripts var  element  =  document.createElement("script");     element.type  =  "text/javascript";   element.text  =  "makeCall();";     document.body.appendChild(element);  

Slide 29

Slide 29 text

ADVANCED INTERACTION Background pages

Slide 30

Slide 30 text

ADVANCED INTERACTION Background/event pages {      "name":  "My  extension",      ...      "background":  {          "scripts":  [”eventpage.js"],          "persistent":  false      },      ...   }  

Slide 31

Slide 31 text

ADVANCED INTERACTION Eventpage.js chrome.browserAction.onClicked.addListener(function(tab)  {      //  do  something  cool   });   Chrome.* apis developer.chrome.com/extensions/api_index.html

Slide 32

Slide 32 text

ADVANCED INTERACTION STORAGE

Slide 33

Slide 33 text

ADVANCED INTERACTION chrome.storage  vs  chrome.localStorage   synced  vs  not  synced   type  safe  vs  not  type  safe   async  vs  sync  

Slide 34

Slide 34 text

No content

Slide 35

Slide 35 text

Advanced interaction messaging

Slide 36

Slide 36 text

ADVANCED INTERACTION messaging contentscript.js   ================   chrome.runtime.sendMessage({greeting:  "hello"},  function(response)  {      console.log(response.farewell);   });   background.html   ===============   chrome.tabs.getSelected(null,  function(tab)  {      chrome.tabs.sendMessage(tab.id,  {greeting:  "hello"},  function(response)  {          console.log(response.farewell);      });   });  

Slide 37

Slide 37 text

ADVANCED INTERACTION messaging chrome.runtime.onMessage.addListener(      function(request,  sender,  sendResponse)  {          console.log(sender.tab  ?                                  "from  a  content  script:"  +  sender.tab.url  :                                  "from  the  extension");          if  (request.greeting  ==  "hello")              sendResponse({farewell:  "goodbye"});      });   popups Options pages Content scripts Background pages

Slide 38

Slide 38 text

Advanced interaction deployment

Slide 39

Slide 39 text

Advanced interaction Chrome://extensions Don’t use “pack extension”

Slide 40

Slide 40 text

Advanced interaction chrome.google.com/webstore/developer/ dashboard Zip + upload One off $5 signup fee

Slide 41

Slide 41 text

No content

Slide 42

Slide 42 text

DOCS developer.chrome.com/ extensions Gem rubygems.org/gems/crxmake

Slide 43

Slide 43 text

No content