In this chapter you will learn about Google Chrome Extensions, which are a useful way to add functionality to the Google Chrome web browser. We will first take a quick look at some popular Google Chrome Extensions and the technologies that are used to code Chrome Extensions. Then, you will learn how to create your own Hello World style Chrome Extensionbut only after we describe the features and abilities of Chrome Extensions. Finally, you will learn about publishing Chrome Extensions on the Chrome Web Store (formerly the Google Chrome Extensions Gallery).
This chapter assumes you have some experience writing simple web pages using technologies such as HTML, CSS, and JavaScript. That said, lets get started!
What Are Google Chrome Extensions?
Google Chrome Extensions are browser extensions for the Google Chrome web browser. Browser extensions are programs that run within the context (security sandbox) of a web browser. They help to provide new functionality(ies) by combining existing features of the web browser and make it possible for users to do many things at once!
Note
At the time of this writing, Google Chrome Extensions are only supported on the desktop versions of the Google Chrome web browser.
Support for Browser Extensions
The Google Chrome web browser started supporting browser extensions in its fourth version, which was released in 2010. It is also possible to create extensions for browsers such as Safari, Mozilla Firefox, and Opera. Extensions created for the Google Chrome web browser are compatible with the Opera web browser, ever since Opera shifted to the Chromiums extension model (after Opera dropped its own Presto engine, in favor of the WebKit engine used by the Google Chrome web browser, from the Chromium project).
Developing extensions for the Safari web browser has a similar learning curve to that of the Google Chrome web browser, and developing extensions for both is easy because it does not require you to learn any newer technologies (only existing web technologies are used). But developing extensions for the Firefox web browser is comparatively difficult as it involves the use of technologies apart from web technologies, such as XUL, XPCOM, etc. (you can read more about these at https://en.wikipedia.org/wiki/Add-on_(Mozilla)#Extension_technologies ). This book only covers development of extensions on the Google Chrome web browser.
Note
The Chrome Web Store is an online marketplace where users can browse for Chrome apps, extensions, and themes. The store helps users find, purchase, and install content on the Chrome browser.
Extensions Are Not Plug-ins
An important point to note is that browser extensions are different from browser plug-ins . While browser extensions are sandboxed within the host web browser (software), plug-ins are not. Here, a sandbox can be thought of as a software container allowing the execution of web technologies, and at the same time providing access to the features of browsers, such as tabs, history, buttons, popups, etc.
In addition to this, extensions add new functionality(ies) to browsers by combining existing features that are already available on browsers (in case of Chrome Extensions, this is done using the API provided by the Extensions framework). Plug-ins, however, provide new functionality(ies) by providing support for particular media types to browsers. In the former case, the example could be an extension that allows users to save all the opened tabs that are not in incognito mode, to the local storage. For the latter case, the example could be a plug-in that allows reading and rendering of PDF files on the browser.
Also note that there is another kind of web application that developers can create for the Chrome browser. These applications are known as Google Chrome Apps . From a developments standpoint, Google Chrome Apps are somewhere in between Google Chrome Extensions and browser plug-ins.
This book does not discuss developing Google Chrome Apps, as it only targets the development of Google Chrome Extensions. But keep in mind that developing Chrome Apps is very similar to developing extensions for the Chrome browser. If you want to know more about Google Chrome Apps, you can visit the following URLs:
https://en.wikipedia.org/wiki/Google_Chrome_Apps
https://developer.chrome.com/apps/about_apps
http://stackoverflow.com/questions/tagged/google-chrome-app
Extensions and Plug-ins
To get a complete list of the extensions installed (added) on your Chrome web browser, tab over to the URL chrome://extensions , as shown in Figure . This page (known as the Extensions Management page) is used to manage extensions in the Chrome browser.
Figure 1-1.
Viewing the Google Chrome Extensions
Note
The item in Figure (i.e. Google Docs) is not an extension. Instead, it is a Google Chrome App. Bothapps, and extensionsare listed on the same page in the Chrome browser ( chrome://extensions ), known as the Extensions Management page . Additionally, apps are also listed on the page located at the URL chrome://apps .
Consider pinning this tab (right-click on the tab and then choose the Pin Tab optionsee Figure ), as it will be used quite often during the course of this book.
Figure 1-2.
Pinning the chrome://extensions tab
Note
Sandboxing is a technique frequently used to test and/or execute unverified programs (which may contain viruses or other malignant code) so that they cant harm the host software.
Similarly, to get a complete list of the plug-ins running on your Chrome web browser, tab over to the URL chrome://plugins (shown in Figure ).
Figure 1-3.
Viewing the Google Chrome plug-ins
Well-known browser plug-ins include the Adobe Flash Player, the Chrome PDF Viewer, the QuickTime Player, and the Java plug-in.
Notable Examples
As of February 2010, around 2,000 extensions were available on the Chrome Web Store ( http://en.wikipedia.org/wiki/Google_Chrome_Extensions#cite_note-4 ). But surprisingly, as of September 2014, more than 30,000 extensions were available on the Chrome Web Store!
Note
The terms browser and web browser are used interchangeably throughout this book. Note that they both refer to the same thing, i.e., the desktop versions of the web browser.
Google Chrome users heavily rely on extensions for increasing their productivity at work, enhancing their ability to access the data (already available) on the web, and for getting the most out of their favorite web browser. The following list provides some popular Google Chrome Extensions that are available for free installation from the Chrome Web Store . Note that the usage statistics provided are as of March 2016: