What are Extensions ?• Small software programs• Modify and enhance functionality of Chrome browser• Implement using Web Technologies• Also use to build packaged apps• Have little to no user interface• Don’t need to depend on content from the web
The Manifest File(manifest.json) manifest.json
Asynchronous vs.• Synchronous APIs Most methods in the chrome.* are asynchronous• they return immediately, without waiting for the operation to finish.• If you need to know the outcome of that operation, then you pass a callback function into the method.• That callback is executed later (potentially much later), sometime after chrome.tabs.create(object createProperties, the method returns. Heres an example of function callback) the signature for an asynchronous method:
Asynchronous vs.• Synchronousare synchronous. Other chrome.* methods• Synchronous methods never have a callback because they dont return until theyve completed all their work.• Often, synchronous methods have a return type. Consider the• DOMWindow chrome.extension.getBackgroundPage() chrome.extensions.getBackgroundPage() method:
Communication• betweenwithin an extension often The HTML pages Pages need to communicate.• Because all of an extensions pages execute in same process on the same thread, the pages can make direct function calls to each other.• The HTML pages within an extension often need to communicate.• Because all of an extensions pages execute in same process on the same thread, the pages can make direct function calls to each
Saving data &• Incognito data using the HTML5 Extensions can save mode web storage API (such as localStorage)• Or by making server requests that result in saving data.• Whenever you want to save something, first consider whether its from a window thats in incognito mode.• By default, extensions dont run in incognito windows, and packaged apps do.• You need to consider what a user expects
Saving data &• Incognito modethe window Incognito mode promises that will leave no tracks.• When dealing with data from incognito windows, do your best to honor this promise.• For example, if your extension normally saves browsing history to the cloud, dont save history from incognito windows.• On the other hand, you can store your extensions settings
Saving data & Incognito modeIf a piece of data might showwhere a userhas been on the web or whatthe user has done,dont store it if its from anincognito window.
JSON – built 2 structuresA collection of name/value pairs. In variouslanguages, this is realized asan object, record, struct, dictionary, hash table,keyed list, or associative array.An ordered list of values. In most languages,this is realizedas an array, vector, list, or sequence.
Browser UIChanging the Google Chrome chromeBrowser Actions Add icons to the toolbar (extensions only)Desktop Notify users of important eventsNotificationsOmnibox Add a keyword to the address barOption Pages Let users customize your extensionOverride Pages Implement your own version of standard browser pages such as the New Tab pagePage Actions Add temporary icons inside the address bar (extensions only)
Browser InteractionInteracting with Google in otherwaysBookmarks Create, organize, and otherwise manipulate the users bookmarksCookies Explore and modify the browsers cookie systemEvents Detect when something interesting happensHistory Interact with the browsers record of visited pagesTabs Create, modify, and rearrange tabs in the browserWindows Create, modify, and rearrange windows in the browser
Implementation (cont.)Implementing the innards of yourextensionInternationalizati Deal with language and localeonMessage Passing Communicate from a content script to its parent extension, or vice versaOptional Modify your extensions permissionsPermissionsNPAPI Plugins Load native binary code
FinishingFinishing and distributing yourextensionAutoupdating Update extensions automaticallyHosting Host extensions on Google servers or your ownOther Distribute extensions on your networkDeployment or with other softwareOptionsPaging Create a .crx file so you can distribute your extension
Create and Load an extension1. Create a folder somewhere on your computer to contain your extensions code.2. Inside your extensions folder, create a text file called manifest.json, and put this in it
Create and Load an extension3. Copy this icon to the same folder: http://www.box.com/s/6418basa92a0lyckshix4. Load the extension: Bring up the extensions management page by clicking the wrench icon and choosing Tools > Extensions. If Developer mode has a + by it, click the + to add developer information to the page. The + changes to a -, and more buttons and information appear. Click the Load unpacked extension button. A file dialog appears.
Create and Load an extensionIf your extension is valid, its icon appears next tothe address bar, and information about theextension appears in the extensions page, as thefollowing screenshot shows
Add code to the extensionhttp://www.box.com/s/82e9lh yvh8ri6o8cs61e
Add code to the extensionReturn to the extensionsmanagement page,and click the Reload button toload the newversion of the extension Click the extensions icon. A popup should appear that displays the contents of popup.html
Extensions for ChromeContains extensions for Chrome, whichchange how the browser behaves and, in alimited way, how it looksIf your extension seems more like a websitethan a small browser add-on, consider making ita packaged app. Packaged apps areimplemented as extensions that have theadditional ability to present an app-like interface
Uploading and PublishingTo publish apps to the Chrome Web Store, youfirst use theChrome Developer Dashboard to upload yourapp and specifyhow its listing should look. Then you can publishit either to theworld at large or to a few trusted testers.
Uploading and Publishing9 STEPs : Publishing your app STEP Choose a developer account 1: STEP Create a ZIP file 2: STEP Upload the app 3: STEP Specify the payment system 4: STEP Get app constants 5:
Uploading and Publishing9 STEPs : Publishing your app (cont.) STEP Finish the app 6: STEP Provide store content 7: STEP Pay the developer signup fee 8: STEP Publish the app 9:
SpeedChrome has taken it a step further.Chrome is the ultimate in fastbrowsing. With Internet connectionsgetting faster and faster, a browsershould be able to keep up with thepace of rendering images andcontent, which is what Google havemanaged to do perfectly.
SimplicityChrome on the other hand hasarranged everything in an organizedmanner, meaning the focus remainsentirely on what it should be –browsing the Internet.
ExtensionsThe extension support in Chrome hasbeen done fantastically. The ease ofinstalling new plugins means norestart is needed, and the browserspeed doesn’t suffer when lots ofextensions are installed. Thefunctional support for add-ons meansfull support for Grease Monkeyscripts too, which is a great addedbonus.