这是indexloc提供的服务,不要输入任何密码
SlideShare a Scribd company logo
Google Chrome Extensions - DevFest09
Google Chrome Extensions - DevFest09
Developing Google
Chrome Extensions
Mihai Ionescu
Developer Advocate, Google
Agenda
• Introduction to Extensions
  o What Extensions Are
  o Why You Should Work on Extensions
  o When the Extension System Ships


• How to Build Extensions
  o Technical Overview
  o Step-by-Step Example

• Key Takeaways

• Q&A
Introduction to Extensions
What Extensions Are
• Programs that enhance Google Chrome's functionality

• Written in HTML, CSS, and JavaScript

• Integrated using a simple API

• Developed iteratively
What Extensions Are
• Installed instantly

• Update automatically

• Transparent about their capabilities

• Run in separate processes
Demo: Gmail Checker




           Shows how many unread
          messages are in your inbox.
Demo: Subscribe to a Feed




          Displays a subscription button
        when a page has an available feed.
Demo: Generate QR Codes




      Turns URLs and other text into QR codes to
     make them easy to transfer to mobile devices.
Why You Should Work on Extensions
• Part of an Important Platform

• Persistent Presence

• Source of Web Traffic

• Easy and Fun
When the Extension System Ships
• Chrome Dev Channel – available now

• Chrome Beta Channel – later this quarter, with a gallery

• Chrome Stable Channel – soon after
How to Build Extensions
Structure of an Extension
Compressed directory containing:
  – manifest file (manifest.json)

And one or more of these components:
  – Browser Action or Page Action
  – Content Script
  – Background Page
  – Other files (HTML, JS, etc.)
Extension Communication
• Internal:




• External:
   – Cross-origin XHR (requires permission)
Overview of the Extension API
chrome is the top level object and exposes:

• chrome.extension.*

• chrome.browserAction.*

• chrome.pageAction.*

• chrome.bookmarks.*

• chrome.tabs.*

• chrome.windows.*
Other APIs
Extensions can also use:
• Standard JavaScript and DOM APIs

• XMLHttpRequest

• HTML 5 APIs

• Webkit APIs

• V8 APIs

• Bundled JS APIs libraries
Step-by-step Example: Chritter




                    +
             A Twitter Toolbar
Step One
Add Browser Action UI

 manifest.json:
 {
   "name": "Chritter",
   "description": "A BrowserAction shows public tweets.",
   "icons": { "16": "icon16.png",
              "32": "icon32.png" },
   "browser_action": {
     "default_title": "Chritter",
     "default_icon": "browserActionIcon.png",
   },
   "version": "0.0.1"
 }
Step Two
Display public tweets timeline in a tab
 manifest.json:

   "browser_action" : {
      "popup": popup.html
   },
   "permissions": [
     "tabs",
     "http://twitter.com/*"
   ]

 popup.html:

   <a href="javascript:chrome.tabs.create(
   {url:'http://twitter.com/public_timeline'});")>
   Twitter</a>
Step Three
Retrieve public tweets with XHR and display in popup
 popup.html:

   // fetch public timeline from the server. 
   xhrRequest(
     "http://twitter.com/statuses/public_timeline.json",
     gotTweets);
 ....

   tweets = JSON.parse(req.responseText);

 ....
   for(i in tweets) {
     user = tweets[i].user;
     name = user.screen_name;
     image_url = user.profile_image_url;
  }
Step Four
Refactor code to use background processing
 manifest.json:
   "background_page": "background.html"

 background.html:
   // fetch tweets and update badge.
   incoming = JSON.parse(req.responseText);
   unread = unread + incoming.length;
   chrome.browserAction.setBadgeText({text:""+unread});
   chrome.browserAction.setBadgeBackgroundColor(
     {color:[255,0,0,255]});

 popup.html:
   // get data from background page.
   bg = chrome.extension.getBackgroundPage();
   for (i in bg.tweets) {
     user = bg.tweets[i].user;
Step Five
Authorize with Twitter and fetch private timeline
 manifest.json:
   "content_scripts": [{
       "js": ["authDone.js"], 
       "matches": ["http://twitter.com/oauth/authorize"] 
   }]

 authDone.js:
   // injected content script looks for oauth_pin 
   pin = document.getElementById("oauth_pin");
   // send the pin to the extension
   port = chrome.extension.connect();
   port.postMessage({"success": true, "pin": pin});

 background.html:
   // extension receives auth pin and logs into Twitter
   chrome.self.onConnect.addListener(function(port) {
     port.onMessage.addListener(function(data) {
       oauthRequest("http://twitter.com/oauth/access_token",
                    {"oauth_verifier": data.pin}, gotAccessToken);
Key Takeaways
• Part of fast growing platform with global reach

• Permanent presence in the browser

• Small learning curve

• Low maintenance needs

• Easy to distribute
Developer Resources
• Documentation
  http://code.google.com/chrome/extensions

• Blog
  http://blog.chromium.org

• Discussion group
  http://groups.google.com/group/chromium-extensions
Q&A
Google Chrome Extensions - DevFest09

More Related Content

What's hot (20)

PDF
5. Frames & Forms.pdf
qwertyuiop154709
 
PPTX
ppt of web development for diploma student
Abhishekchauhan863165
 
PPTX
Ppt full stack developer
SudhirVarpe1
 
PPTX
presentation in html,css,javascript
FaysalAhammed5
 
PPTX
OAuth2 + API Security
Amila Paranawithana
 
PPTX
Introduction to MERN
ShyamMohanKunwar
 
PPTX
Html coding
Briana VanBuskirk
 
PDF
Go Profiling - John Graham-Cumming
Cloudflare
 
PPT
Sentiment Analysis
prnk08
 
PDF
WEB I - 01 - Introduction to Web Development
Randy Connolly
 
PPTX
Introduction to React JS
Arnold Asllani
 
PPTX
Develop Chrome Extension
Aleksandr Golovatyi
 
PPT
Web development | Derin Dolen
Derin Dolen
 
PPT
Js ppt
Rakhi Thota
 
PPTX
Bootstrap 3
McSoftsis
 
PDF
Web develop in flask
Jim Yeh
 
PPTX
Java script
reddivarihareesh
 
PPTX
Front End Development | Introduction
JohnTaieb
 
PDF
Nodejs presentation
Arvind Devaraj
 
PPTX
Backend Programming
Ruwandi Madhunamali
 
5. Frames & Forms.pdf
qwertyuiop154709
 
ppt of web development for diploma student
Abhishekchauhan863165
 
Ppt full stack developer
SudhirVarpe1
 
presentation in html,css,javascript
FaysalAhammed5
 
OAuth2 + API Security
Amila Paranawithana
 
Introduction to MERN
ShyamMohanKunwar
 
Html coding
Briana VanBuskirk
 
Go Profiling - John Graham-Cumming
Cloudflare
 
Sentiment Analysis
prnk08
 
WEB I - 01 - Introduction to Web Development
Randy Connolly
 
Introduction to React JS
Arnold Asllani
 
Develop Chrome Extension
Aleksandr Golovatyi
 
Web development | Derin Dolen
Derin Dolen
 
Js ppt
Rakhi Thota
 
Bootstrap 3
McSoftsis
 
Web develop in flask
Jim Yeh
 
Java script
reddivarihareesh
 
Front End Development | Introduction
JohnTaieb
 
Nodejs presentation
Arvind Devaraj
 
Backend Programming
Ruwandi Madhunamali
 

Viewers also liked (12)

PPT
Google chrome
Melissa Brisbin
 
PPTX
Chrome Extensions
Pavel Klimiankou
 
PDF
HTML5 and Google Chrome - DevFest09
mihaiionescu
 
PPTX
Google chrome os
akoyena
 
PPTX
Chrome O.S.
Sukaant Chaudhary
 
PDF
Chrome extensions
Ahmad Tahhan
 
PPTX
Materiales de Madera
Duoc
 
PPTX
Google chrome operating system
kondalarao7
 
PPT
Diapositivas de la madera.ppt1
Jhoely Perez
 
PPTX
Propiedades de la madera
jaic61
 
PPTX
Todo sobre la madera.
Princesita Violeta
 
PPT
La ConstruccióN Con Madera
Jorge Marulanda
 
Google chrome
Melissa Brisbin
 
Chrome Extensions
Pavel Klimiankou
 
HTML5 and Google Chrome - DevFest09
mihaiionescu
 
Google chrome os
akoyena
 
Chrome O.S.
Sukaant Chaudhary
 
Chrome extensions
Ahmad Tahhan
 
Materiales de Madera
Duoc
 
Google chrome operating system
kondalarao7
 
Diapositivas de la madera.ppt1
Jhoely Perez
 
Propiedades de la madera
jaic61
 
Todo sobre la madera.
Princesita Violeta
 
La ConstruccióN Con Madera
Jorge Marulanda
 
Ad

Similar to Google Chrome Extensions - DevFest09 (20)

PPTX
Chrome Apps & Extensions
Varun Raj
 
PPTX
Web browser extension development
alecsrusu
 
PPTX
Google chrome extension
Johnny Kingdom
 
PPTX
Chrome Extension Step by step Guide .pptx
geekhouse.io
 
PPTX
J query ppt
Kavi Kumar
 
PPTX
HTML 5
Rajan Pal
 
PDF
An Introduction to Django Web Framework
David Gibbons
 
PDF
Web works hol
momoahmedabad
 
PDF
Firefox OS Workshop @ Serbia & Montenegro - Training
Jan Jongboom
 
PPTX
Chrome extension 2014.08.03
louisasea666
 
PDF
Chrome Extensions for Web Hackers
Mark Wubben
 
PDF
Browser Extensions for Web Hackers
Mark Wubben
 
PPTX
Chris O'Brien - Modern SharePoint development: techniques for moving code off...
Chris O'Brien
 
PPT
Google Chronicles: Analytics And Chrome
Sarah Dutkiewicz
 
PPTX
221c82d4-5428-4047-8558-0467b34083e8.pptx
kurapativyshnavi3
 
PDF
orcreatehappyusers
tutorialsruby
 
PDF
orcreatehappyusers
tutorialsruby
 
PDF
Build an AI/ML-driven image archive processing workflow: Image archive, analy...
wesley chun
 
PPT
Expert guide for PHP
Steve Fort
 
Chrome Apps & Extensions
Varun Raj
 
Web browser extension development
alecsrusu
 
Google chrome extension
Johnny Kingdom
 
Chrome Extension Step by step Guide .pptx
geekhouse.io
 
J query ppt
Kavi Kumar
 
HTML 5
Rajan Pal
 
An Introduction to Django Web Framework
David Gibbons
 
Web works hol
momoahmedabad
 
Firefox OS Workshop @ Serbia & Montenegro - Training
Jan Jongboom
 
Chrome extension 2014.08.03
louisasea666
 
Chrome Extensions for Web Hackers
Mark Wubben
 
Browser Extensions for Web Hackers
Mark Wubben
 
Chris O'Brien - Modern SharePoint development: techniques for moving code off...
Chris O'Brien
 
Google Chronicles: Analytics And Chrome
Sarah Dutkiewicz
 
221c82d4-5428-4047-8558-0467b34083e8.pptx
kurapativyshnavi3
 
orcreatehappyusers
tutorialsruby
 
orcreatehappyusers
tutorialsruby
 
Build an AI/ML-driven image archive processing workflow: Image archive, analy...
wesley chun
 
Expert guide for PHP
Steve Fort
 
Ad

Recently uploaded (20)

PDF
Women in Automation Presents: Reinventing Yourself — Bold Career Pivots That ...
DianaGray10
 
PDF
Empowering Cloud Providers with Apache CloudStack and Stackbill
ShapeBlue
 
PPTX
Lecture 5 - Agentic AI and model context protocol.pptx
Dr. LAM Yat-fai (林日辉)
 
PDF
State-Dependent Conformal Perception Bounds for Neuro-Symbolic Verification
Ivan Ruchkin
 
PDF
CloudStack GPU Integration - Rohit Yadav
ShapeBlue
 
PDF
HR agent at Mediq: Lessons learned on Agent Builder & Maestro by Tacstone Tec...
UiPathCommunity
 
PDF
Novus-Safe Pro: Brochure-What is Novus Safe Pro?.pdf
Novus Hi-Tech
 
PDF
Alpha Altcoin Setup : TIA - 19th July 2025
CIFDAQ
 
PDF
The Past, Present & Future of Kenya's Digital Transformation
Moses Kemibaro
 
PDF
NewMind AI Journal - Weekly Chronicles - July'25 Week II
NewMind AI
 
PDF
Bitcoin+ Escalando sin concesiones - Parte 1
Fernando Paredes García
 
PDF
NewMind AI Weekly Chronicles – July’25, Week III
NewMind AI
 
PDF
Apache CloudStack 201: Let's Design & Build an IaaS Cloud
ShapeBlue
 
PPTX
Earn Agentblazer Status with Slack Community Patna.pptx
SanjeetMishra29
 
PDF
Human-centred design in online workplace learning and relationship to engagem...
Tracy Tang
 
PDF
Market Insight : ETH Dominance Returns
CIFDAQ
 
PDF
Trading Volume Explained by CIFDAQ- Secret Of Market Trends
CIFDAQ
 
PDF
CIFDAQ'S Token Spotlight for 16th July 2025 - ALGORAND
CIFDAQ
 
PDF
Building Resilience with Digital Twins : Lessons from Korea
SANGHEE SHIN
 
PPTX
AVL ( audio, visuals or led ), technology.
Rajeshwri Panchal
 
Women in Automation Presents: Reinventing Yourself — Bold Career Pivots That ...
DianaGray10
 
Empowering Cloud Providers with Apache CloudStack and Stackbill
ShapeBlue
 
Lecture 5 - Agentic AI and model context protocol.pptx
Dr. LAM Yat-fai (林日辉)
 
State-Dependent Conformal Perception Bounds for Neuro-Symbolic Verification
Ivan Ruchkin
 
CloudStack GPU Integration - Rohit Yadav
ShapeBlue
 
HR agent at Mediq: Lessons learned on Agent Builder & Maestro by Tacstone Tec...
UiPathCommunity
 
Novus-Safe Pro: Brochure-What is Novus Safe Pro?.pdf
Novus Hi-Tech
 
Alpha Altcoin Setup : TIA - 19th July 2025
CIFDAQ
 
The Past, Present & Future of Kenya's Digital Transformation
Moses Kemibaro
 
NewMind AI Journal - Weekly Chronicles - July'25 Week II
NewMind AI
 
Bitcoin+ Escalando sin concesiones - Parte 1
Fernando Paredes García
 
NewMind AI Weekly Chronicles – July’25, Week III
NewMind AI
 
Apache CloudStack 201: Let's Design & Build an IaaS Cloud
ShapeBlue
 
Earn Agentblazer Status with Slack Community Patna.pptx
SanjeetMishra29
 
Human-centred design in online workplace learning and relationship to engagem...
Tracy Tang
 
Market Insight : ETH Dominance Returns
CIFDAQ
 
Trading Volume Explained by CIFDAQ- Secret Of Market Trends
CIFDAQ
 
CIFDAQ'S Token Spotlight for 16th July 2025 - ALGORAND
CIFDAQ
 
Building Resilience with Digital Twins : Lessons from Korea
SANGHEE SHIN
 
AVL ( audio, visuals or led ), technology.
Rajeshwri Panchal
 

Google Chrome Extensions - DevFest09

  • 3. Developing Google Chrome Extensions Mihai Ionescu Developer Advocate, Google
  • 4. Agenda • Introduction to Extensions o What Extensions Are o Why You Should Work on Extensions o When the Extension System Ships • How to Build Extensions o Technical Overview o Step-by-Step Example • Key Takeaways • Q&A
  • 6. What Extensions Are • Programs that enhance Google Chrome's functionality • Written in HTML, CSS, and JavaScript • Integrated using a simple API • Developed iteratively
  • 7. What Extensions Are • Installed instantly • Update automatically • Transparent about their capabilities • Run in separate processes
  • 8. Demo: Gmail Checker Shows how many unread messages are in your inbox.
  • 9. Demo: Subscribe to a Feed Displays a subscription button when a page has an available feed.
  • 10. Demo: Generate QR Codes Turns URLs and other text into QR codes to make them easy to transfer to mobile devices.
  • 11. Why You Should Work on Extensions • Part of an Important Platform • Persistent Presence • Source of Web Traffic • Easy and Fun
  • 12. When the Extension System Ships • Chrome Dev Channel – available now • Chrome Beta Channel – later this quarter, with a gallery • Chrome Stable Channel – soon after
  • 13. How to Build Extensions
  • 14. Structure of an Extension Compressed directory containing: – manifest file (manifest.json) And one or more of these components: – Browser Action or Page Action – Content Script – Background Page – Other files (HTML, JS, etc.)
  • 15. Extension Communication • Internal: • External: – Cross-origin XHR (requires permission)
  • 16. Overview of the Extension API chrome is the top level object and exposes: • chrome.extension.* • chrome.browserAction.* • chrome.pageAction.* • chrome.bookmarks.* • chrome.tabs.* • chrome.windows.*
  • 17. Other APIs Extensions can also use: • Standard JavaScript and DOM APIs • XMLHttpRequest • HTML 5 APIs • Webkit APIs • V8 APIs • Bundled JS APIs libraries
  • 18. Step-by-step Example: Chritter + A Twitter Toolbar
  • 19. Step One Add Browser Action UI manifest.json: {   "name": "Chritter",   "description": "A BrowserAction shows public tweets.",   "icons": { "16": "icon16.png",              "32": "icon32.png" },   "browser_action": {     "default_title": "Chritter",     "default_icon": "browserActionIcon.png",   },   "version": "0.0.1" }
  • 20. Step Two Display public tweets timeline in a tab manifest.json: "browser_action" : { "popup": popup.html },   "permissions": [     "tabs",     "http://twitter.com/*"   ] popup.html:   <a href="javascript:chrome.tabs.create(   {url:'http://twitter.com/public_timeline'});")>   Twitter</a>
  • 21. Step Three Retrieve public tweets with XHR and display in popup popup.html:   // fetch public timeline from the server.    xhrRequest(     "http://twitter.com/statuses/public_timeline.json",     gotTweets); ....   tweets = JSON.parse(req.responseText); ....   for(i in tweets) {     user = tweets[i].user;     name = user.screen_name;     image_url = user.profile_image_url;  }
  • 22. Step Four Refactor code to use background processing manifest.json:   "background_page": "background.html" background.html:   // fetch tweets and update badge.   incoming = JSON.parse(req.responseText);   unread = unread + incoming.length;   chrome.browserAction.setBadgeText({text:""+unread});   chrome.browserAction.setBadgeBackgroundColor(     {color:[255,0,0,255]}); popup.html:   // get data from background page.   bg = chrome.extension.getBackgroundPage();   for (i in bg.tweets) {     user = bg.tweets[i].user;
  • 23. Step Five Authorize with Twitter and fetch private timeline manifest.json:   "content_scripts": [{       "js": ["authDone.js"],        "matches": ["http://twitter.com/oauth/authorize"]    }] authDone.js:   // injected content script looks for oauth_pin    pin = document.getElementById("oauth_pin");   // send the pin to the extension   port = chrome.extension.connect();   port.postMessage({"success": true, "pin": pin}); background.html:   // extension receives auth pin and logs into Twitter   chrome.self.onConnect.addListener(function(port) {     port.onMessage.addListener(function(data) {       oauthRequest("http://twitter.com/oauth/access_token",                    {"oauth_verifier": data.pin}, gotAccessToken);
  • 24. Key Takeaways • Part of fast growing platform with global reach • Permanent presence in the browser • Small learning curve • Low maintenance needs • Easy to distribute
  • 25. Developer Resources • Documentation http://code.google.com/chrome/extensions • Blog http://blog.chromium.org • Discussion group http://groups.google.com/group/chromium-extensions
  • 26. Q&A