SlideShare ist ein Scribd-Unternehmen logo
1 von 27
Downloaden Sie, um offline zu lesen
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

Weitere ähnliche Inhalte

Was ist angesagt?

Was ist angesagt? (20)

Google Chrome DevTools features overview
Google Chrome DevTools features overviewGoogle Chrome DevTools features overview
Google Chrome DevTools features overview
 
Server Side Programming
Server Side ProgrammingServer Side Programming
Server Side Programming
 
Intro to Wordpress
Intro to WordpressIntro to Wordpress
Intro to Wordpress
 
Building Advanced XSS Vectors
Building Advanced XSS VectorsBuilding Advanced XSS Vectors
Building Advanced XSS Vectors
 
HTTP Request Header and HTTP Status Code
HTTP Request Header and HTTP Status CodeHTTP Request Header and HTTP Status Code
HTTP Request Header and HTTP Status Code
 
Push Notification
Push NotificationPush Notification
Push Notification
 
Content Management System
Content Management SystemContent Management System
Content Management System
 
PHP.ppt
PHP.pptPHP.ppt
PHP.ppt
 
Cookies and sessions
Cookies and sessionsCookies and sessions
Cookies and sessions
 
Web Development In 2018
Web Development In 2018Web Development In 2018
Web Development In 2018
 
Using Chrome Dev Tools
Using Chrome Dev ToolsUsing Chrome Dev Tools
Using Chrome Dev Tools
 
How to use_000webhost
How to use_000webhostHow to use_000webhost
How to use_000webhost
 
Introduction to Html5
Introduction to Html5Introduction to Html5
Introduction to Html5
 
Security Testing using ZAP in SFDC
Security Testing using ZAP in SFDCSecurity Testing using ZAP in SFDC
Security Testing using ZAP in SFDC
 
CSS
CSSCSS
CSS
 
SOAP--Simple Object Access Protocol
SOAP--Simple Object Access ProtocolSOAP--Simple Object Access Protocol
SOAP--Simple Object Access Protocol
 
Moodle Intro Power Point
Moodle Intro Power PointMoodle Intro Power Point
Moodle Intro Power Point
 
Introduction of Progressive Web App
Introduction of Progressive Web AppIntroduction of Progressive Web App
Introduction of Progressive Web App
 
Installation xampp and WordPress on localhost
Installation xampp and WordPress on localhostInstallation xampp and WordPress on localhost
Installation xampp and WordPress on localhost
 
Node.js Express Framework
Node.js Express FrameworkNode.js Express Framework
Node.js Express Framework
 

Andere mochten auch

Google chrome operating system
Google chrome operating systemGoogle chrome operating system
Google chrome operating system
kondalarao7
 
Diapositivas de la madera.ppt1
Diapositivas de la madera.ppt1Diapositivas de la madera.ppt1
Diapositivas de la madera.ppt1
Jhoely Perez
 
Propiedades de la madera
Propiedades de la maderaPropiedades de la madera
Propiedades de la madera
jaic61
 

Andere mochten auch (12)

Google chrome
Google chromeGoogle chrome
Google chrome
 
Chrome Extensions
Chrome ExtensionsChrome Extensions
Chrome Extensions
 
HTML5 and Google Chrome - DevFest09
HTML5 and Google Chrome - DevFest09HTML5 and Google Chrome - DevFest09
HTML5 and Google Chrome - DevFest09
 
Google chrome os
Google chrome osGoogle chrome os
Google chrome os
 
Chrome O.S.
Chrome O.S.Chrome O.S.
Chrome O.S.
 
Chrome extensions
Chrome extensions Chrome extensions
Chrome extensions
 
Materiales de Madera
Materiales de MaderaMateriales de Madera
Materiales de Madera
 
Google chrome operating system
Google chrome operating systemGoogle chrome operating system
Google chrome operating system
 
Diapositivas de la madera.ppt1
Diapositivas de la madera.ppt1Diapositivas de la madera.ppt1
Diapositivas de la madera.ppt1
 
Propiedades de la madera
Propiedades de la maderaPropiedades de la madera
Propiedades de la madera
 
Todo sobre la madera.
Todo sobre la madera. Todo sobre la madera.
Todo sobre la madera.
 
La ConstruccióN Con Madera
La ConstruccióN Con MaderaLa ConstruccióN Con Madera
La ConstruccióN Con Madera
 

Ähnlich wie Google Chrome Extensions - DevFest09

Chrome Apps & Extensions
Chrome Apps & ExtensionsChrome Apps & Extensions
Chrome Apps & Extensions
Varun Raj
 
Web browser extension development
Web browser extension developmentWeb browser extension development
Web browser extension development
alecsrusu
 
Firefox OS Workshop @ Serbia & Montenegro - Training
Firefox OS Workshop @ Serbia & Montenegro - TrainingFirefox OS Workshop @ Serbia & Montenegro - Training
Firefox OS Workshop @ Serbia & Montenegro - Training
Jan Jongboom
 

Ähnlich wie Google Chrome Extensions - DevFest09 (20)

Develop Chrome Extension
Develop Chrome ExtensionDevelop Chrome Extension
Develop Chrome Extension
 
Chrome Apps & Extensions
Chrome Apps & ExtensionsChrome Apps & Extensions
Chrome Apps & Extensions
 
Web browser extension development
Web browser extension developmentWeb browser extension development
Web browser extension development
 
Chrome Extension Step by step Guide .pptx
Chrome Extension Step by step Guide .pptxChrome Extension Step by step Guide .pptx
Chrome Extension Step by step Guide .pptx
 
J query ppt
J query pptJ query ppt
J query ppt
 
CGI by rj
CGI by rjCGI by rj
CGI by rj
 
HTML 5
HTML 5HTML 5
HTML 5
 
An Introduction to Django Web Framework
An Introduction to Django Web FrameworkAn Introduction to Django Web Framework
An Introduction to Django Web Framework
 
Web works hol
Web works holWeb works hol
Web works hol
 
Firefox OS Workshop @ Serbia & Montenegro - Training
Firefox OS Workshop @ Serbia & Montenegro - TrainingFirefox OS Workshop @ Serbia & Montenegro - Training
Firefox OS Workshop @ Serbia & Montenegro - Training
 
Chrome extension 2014.08.03
Chrome extension 2014.08.03Chrome extension 2014.08.03
Chrome extension 2014.08.03
 
Chrome Extensions for Web Hackers
Chrome Extensions for Web HackersChrome Extensions for Web Hackers
Chrome Extensions for Web Hackers
 
Browser Extensions for Web Hackers
Browser Extensions for Web HackersBrowser Extensions for Web Hackers
Browser Extensions for Web Hackers
 
Chris O'Brien - Modern SharePoint development: techniques for moving code off...
Chris O'Brien - Modern SharePoint development: techniques for moving code off...Chris O'Brien - Modern SharePoint development: techniques for moving code off...
Chris O'Brien - Modern SharePoint development: techniques for moving code off...
 
Google Chronicles: Analytics And Chrome
Google Chronicles: Analytics And ChromeGoogle Chronicles: Analytics And Chrome
Google Chronicles: Analytics And Chrome
 
orcreatehappyusers
orcreatehappyusersorcreatehappyusers
orcreatehappyusers
 
orcreatehappyusers
orcreatehappyusersorcreatehappyusers
orcreatehappyusers
 
Build an AI/ML-driven image archive processing workflow: Image archive, analy...
Build an AI/ML-driven image archive processing workflow: Image archive, analy...Build an AI/ML-driven image archive processing workflow: Image archive, analy...
Build an AI/ML-driven image archive processing workflow: Image archive, analy...
 
Expert guide for PHP
Expert guide for PHPExpert guide for PHP
Expert guide for PHP
 
Orange is the new blue: How to port Chrome Extension to Firefox Extension
Orange is the new blue: How to port Chrome Extension to Firefox ExtensionOrange is the new blue: How to port Chrome Extension to Firefox Extension
Orange is the new blue: How to port Chrome Extension to Firefox Extension
 

Kürzlich hochgeladen

Kürzlich hochgeladen (20)

Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of Brazil
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 

Google Chrome Extensions - DevFest09

  • 1.
  • 2.
  • 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