presented by…. group 2 1. programming language 2introduction

88
Presented by…. Group 2 1 CHROME EXTENSION

Upload: marlene-dalton

Post on 24-Dec-2015

223 views

Category:

Documents


2 download

TRANSCRIPT

Page 1: Presented by…. Group 2 1. Programming language 2Introduction

Presented by…. Group 2 1

CHROME EXTENSION

Page 2: Presented by…. Group 2 1. Programming language 2Introduction

Programming language

2

Introduction

Page 3: Presented by…. Group 2 1. Programming language 2Introduction

Introduction

• What is Google Chrome?

3

– Google Chrome is a freeware web browser• Developed by – Google Inc.

• Operating System– Windows, Linux, Mac , Android

• Latest Version– V. 19.0.1055.1 (Dev.)

Page 4: Presented by…. Group 2 1. Programming language 2Introduction

Introduction

• What is Chrome Extension?

4

– Google Chrome Extensions are applications that run inside the Chrome browser and provide additional functionality, integration with third party websites or services, and customized browsing experiences.

– http://code.google.com/chrome/extensions/index.html

Page 5: Presented by…. Group 2 1. Programming language 2Introduction

Programming language

5

Form of Chrome Extension

Page 6: Presented by…. Group 2 1. Programming language 2Introduction

Extension UIs

• Browser Actions– Use browser actions to put icons in the main

Google Chrome toolbar, to the right of the address bar. In addition to its icon, a browser action can also have a tooltip, a badge, and a popup.

6

Page 7: Presented by…. Group 2 1. Programming language 2Introduction

Extension UIs

• Page Actions– Use page actions to put icons inside the address

bar.

7

Page 8: Presented by…. Group 2 1. Programming language 2Introduction

Packaged App UIs

• Packaged App UIs– A packaged app usually presents its main

functionality using an HTML page that's bundled into the app.

8

Page 9: Presented by…. Group 2 1. Programming language 2Introduction

Programming language

9

Install Chrome Extension

Page 10: Presented by…. Group 2 1. Programming language 2Introduction

Install Chrome Extension

• How install Chrome Extension

10

Page 11: Presented by…. Group 2 1. Programming language 2Introduction

Install Chrome Extension

• Chrome Extension Page

11

Page 12: Presented by…. Group 2 1. Programming language 2Introduction

Install Chrome Extension

• Chrome Extension Store

12

Page 13: Presented by…. Group 2 1. Programming language 2Introduction

Programming language

13

Build Chrome Extension

Page 14: Presented by…. Group 2 1. Programming language 2Introduction

Programming language

14

Programming Language

Page 15: Presented by…. Group 2 1. Programming language 2Introduction

Programming language

• Language & Technique:– Java script: • runs inside web page.

– XmlHttpRequest: • talks to a server.

– Cookies, Local Storage or HTML 5 Database:• persist some data

– HTML and Cascading Style Sheets (CSS) : • displays a nicely design web page.

15

Page 16: Presented by…. Group 2 1. Programming language 2Introduction

Programming language

16

Files in Chrome Extension

Page 17: Presented by…. Group 2 1. Programming language 2Introduction

Files

17

manifest.jsonjs Files

Related Files

Html Files

Page 18: Presented by…. Group 2 1. Programming language 2Introduction

Files

Files

18

Files

EnTH

CH

Page 19: Presented by…. Group 2 1. Programming language 2Introduction

Files

• Each extension has the following files:– A manifest file– One or more HTML files – One or more JavaScript files (Optional)– Any other files extension needs (Optional)• For example, image files, css files

19

Page 20: Presented by…. Group 2 1. Programming language 2Introduction

Manifest file

• The manifest file, called manifest.json JSON-format (JavaScript Object Notation)• Giving information about the extension, such

as the most important files and the capabilities that the extension might use.

20

Page 21: Presented by…. Group 2 1. Programming language 2Introduction

Manifest file: Fields• The following code shows the supported

manifest fields • Manifest fields consist of 4 types which are

– 1. Required field– 2. Recommended Field– 3. Action Field– 4. Other Field

21

Page 22: Presented by…. Group 2 1. Programming language 2Introduction

Manifest file: Fields

22

Page 23: Presented by…. Group 2 1. Programming language 2Introduction

Manifest file: Fields

23

Page 24: Presented by…. Group 2 1. Programming language 2Introduction

Manifest file: Fields

24

Page 25: Presented by…. Group 2 1. Programming language 2Introduction

Manifest file: Fields

25

Page 26: Presented by…. Group 2 1. Programming language 2Introduction

Programming language

26

First Baby Extension

Page 27: Presented by…. Group 2 1. Programming language 2Introduction

Programming language

27

Architecture

Page 28: Presented by…. Group 2 1. Programming language 2Introduction

Architecture of Chrome Extension

• There are three type of architecture that run on Chrome extension which are– UI pages– The background page– Content scripts

28

Page 29: Presented by…. Group 2 1. Programming language 2Introduction

Architecture of Chrome Extension

• UI pages is ordinary HTML pages that display the extension's UI.

• For example, a browser action can have a popup, which is implemented by an HTML file.

29

Page 30: Presented by…. Group 2 1. Programming language 2Introduction

Architecture of Chrome Extension

• The background page is an invisible page that holds the main logic of the extension

• It is written HTML, Javascript, CSS and the file structure. For example, tabs, browser, bookmarks, events, history, window, etc.

30

Page 31: Presented by…. Group 2 1. Programming language 2Introduction

Architecture of Chrome Extension

• Content scripts are JavaScript files by using the standard Document Object Model (DOM), they can read details of the web pages the browser visits, or make changes to them.

• For example, finding unlinked URLs in web pages and convert them into hyperlinks

31

Page 32: Presented by…. Group 2 1. Programming language 2Introduction

Programming language

32

Using APIs

Page 33: Presented by…. Group 2 1. Programming language 2Introduction

APIs in Chrome Extension

• There are two types of APIs that’s used in Chrome Extension– Chrome's APIs– Other APIs

33

Page 34: Presented by…. Group 2 1. Programming language 2Introduction

APIs in Chrome Extension

• Chrome's APIs• Google Chrome provides APIs such as

chrome.bookmarks.* and chrome.tab.* so that extensions can interact with the browser.

• Two types of Chrome's APIs• Supported APIs which now supported in Chrome APIs • Experimental APIs which will become supported APIs in

future releases of Chrome

34

Page 35: Presented by…. Group 2 1. Programming language 2Introduction

APIs in Chrome Extension

• Other APIs such as• Standard JavaScript APIs• XMLHttpRequest• HTML5 and other emerging APIs• WebKit APIs• V8 APIs, such as JSON• APIs in bundled libraries

35

Page 36: Presented by…. Group 2 1. Programming language 2Introduction

Programming language

36

Developer’s Guide

Page 37: Presented by…. Group 2 1. Programming language 2Introduction

Developer's Guide

• 1. Changing the Google Chrome.• 2. Browser Interaction.• 3. Implementation• 4. Finishing(Deployment)

37

Page 38: Presented by…. Group 2 1. Programming language 2Introduction

Developer's Guide

• 1. Changing the Google Chrome.• 1.1 Browser Actions• 1.2 Context Menus• 1.3 Desktop Notifications• 1.4 Omnibox• 1.5 Options Pages• 1.6 Override Pages• 1.7 Page Action

38

Page 39: Presented by…. Group 2 1. Programming language 2Introduction

1.Changing the Google Chrome.

39

• 1.1 Browser Actions

Page 40: Presented by…. Group 2 1. Programming language 2Introduction

Developer's Guide• 1.2 Context Menus

40

Page 41: Presented by…. Group 2 1. Programming language 2Introduction

Developer's Guide• 1.3 Desktop Notifications

41

Page 42: Presented by…. Group 2 1. Programming language 2Introduction

Developer's Guide• 1.4 Omnibox

42

Page 43: Presented by…. Group 2 1. Programming language 2Introduction

Developer's Guide• 1.5 Options Pages

• To allow users to customize the behavior of your extension, you may wish to provide an options page.

43

Page 44: Presented by…. Group 2 1. Programming language 2Introduction

Developer's Guide• 1.6 Override Pages

44

Page 45: Presented by…. Group 2 1. Programming language 2Introduction

Developer's Guide• 1.7 Page Action

45

Page 46: Presented by…. Group 2 1. Programming language 2Introduction

Developer's Guide

• 2. Browser Interaction.• 2.1 Bookmarks• 2.2 Cookies• 2.3 Events• 2.4 History• 2.5 Management• 2.6 Tabs• 2.7 Windows

46

Page 47: Presented by…. Group 2 1. Programming language 2Introduction

2. Browser Interaction.• 2.1 Bookmarks

47

Page 48: Presented by…. Group 2 1. Programming language 2Introduction

2. Browser Interaction.• 2.2 Cookies

48

Page 49: Presented by…. Group 2 1. Programming language 2Introduction

2. Browser Interaction.• 2.3 Events

– An Event is an object that allows you to be notified when something interesting happens.

49

Page 50: Presented by…. Group 2 1. Programming language 2Introduction

2. Browser Interaction.• 2.4 History

50

Page 51: Presented by…. Group 2 1. Programming language 2Introduction

2. Browser Interaction.• 2.5 Management

51

Page 52: Presented by…. Group 2 1. Programming language 2Introduction

2. Browser Interaction.• 2.6 Tabs

– Use the chrome.tabs module to interact with the browser's tab system. You can use this module to create, modify, and rearrange tabs in the browser.

52

Page 53: Presented by…. Group 2 1. Programming language 2Introduction

2. Browser Interaction.• 2.7 Windows

– Use the chrome.windows module to interact with browser windows. You can use this module to create, modify, and rearrange windows in the browser.

53

Page 54: Presented by…. Group 2 1. Programming language 2Introduction

Developer's Guide

• 3.Implementation• 3.1 Background Page• 3.2 Content Scripts• 3.3 Cross-Origin XHR• 3.4 Message Passing

54

Page 55: Presented by…. Group 2 1. Programming language 2Introduction

3.1 Background Page

Manifest.json

55

{ "name": "My extension", ... "background_page": "background.html", ... }

Background.html

Image.html

Page 56: Presented by…. Group 2 1. Programming language 2Introduction

3.1 Background Page(Cont.)

56

Background.html

Page 57: Presented by…. Group 2 1. Programming language 2Introduction

3.1 Background Page(Cont.)

57

Image.html

Page 58: Presented by…. Group 2 1. Programming language 2Introduction

3.2 Content ScriptsIf your content script's code should always be

injected, register it in the extension manifest using the content_scripts field

58

Page 59: Presented by…. Group 2 1. Programming language 2Introduction

3.2 Content Scripts(Cont.) If you want to inject the code only sometimes, use

the permissions field instead, as described in Programmatic injection.

59

Page 60: Presented by…. Group 2 1. Programming language 2Introduction

3.2 Content Scripts(Cont.)

• Example : Sandwich

60

Page 61: Presented by…. Group 2 1. Programming language 2Introduction

3.3 Cross-Origin XMLHttpRequest

61

Page 62: Presented by…. Group 2 1. Programming language 2Introduction

3.3 Cross-Origin XMLHttpRequest (Cont.)

62

Page 63: Presented by…. Group 2 1. Programming language 2Introduction

3.3 Cross-Origin XMLHttpRequest (Cont.)

• The readyState property holds the status of the XMLHttpRequest.

63

Page 64: Presented by…. Group 2 1. Programming language 2Introduction

3.3 Cross-Origin XMLHttpRequest (Cont.)

• Example : Demonstrates making cross domain requests from a content script by putting Twitter trends on Google News.

64

XMLHttpRequest

https://api.twitter.com/1/trends/daily.json?exclude=hashtags

API

JSON

Page 65: Presented by…. Group 2 1. Programming language 2Introduction

3.3 Cross-Origin XMLHttpRequest (Cont.)

65

JSON

UI

Page 66: Presented by…. Group 2 1. Programming language 2Introduction

3.4 Message Passing

66

• 3.4.1) Sample one-time requests• 3.4.2) Long-lived connections

Page 67: Presented by…. Group 2 1. Programming language 2Introduction

3.4.1 Sample one-time requests

67

contentscript.js Background.html

Hello

Goodbye

Page 68: Presented by…. Group 2 1. Programming language 2Introduction

3.4.1 Sample one-time requests(Cont.)

• Ex. Sending a message to the content script in the selected tab.

• Background.html Send Message to selected tab

68

Page 69: Presented by…. Group 2 1. Programming language 2Introduction

3.4.1 Sample one-time requests(Cont.)

69

• At Receiving

- Need to set up chrome.extension.onRequest

Page 70: Presented by…. Group 2 1. Programming language 2Introduction

3.4.2. Long-lived connections

70

contentscript.js Background.html

PORT

Page 71: Presented by…. Group 2 1. Programming language 2Introduction

3.4.2. Long-lived connections(Cont.)

• Contentscript.js

71

• Background.html

Page 72: Presented by…. Group 2 1. Programming language 2Introduction

4. Finishing(Deployment)

• 4.1 Hosting• 4.2 Other Deployment Options

72

Page 73: Presented by…. Group 2 1. Programming language 2Introduction

4.1 Hosting

• 4.1.1 Chrome Web Store• 4.1.2 Packaging

73

Page 74: Presented by…. Group 2 1. Programming language 2Introduction

4.1 Hosting (Cont.)

Chrome Web Store

74

Page 75: Presented by…. Group 2 1. Programming language 2Introduction

chrome://settings/packExtensionOverlay

.crx .pem

manifest.json

.html

.js

Packaging4.2 Packaging

75

Page 76: Presented by…. Group 2 1. Programming language 2Introduction

Private Key in .pem file

4.2 Packaging (Cont.) Private Key

76

Page 77: Presented by…. Group 2 1. Programming language 2Introduction

4.2 Packaging (Cont.)

77

chrome://settings/packExtensionOverlay

.crx

.pem

manifest.json

.html

.js

Updating

Page 78: Presented by…. Group 2 1. Programming language 2Introduction

Other Deployment Options

- installed automatically(external extension)- Using a preferences JSON file- Using the Windows registry (Windows only)

- Auto updating

78

Page 79: Presented by…. Group 2 1. Programming language 2Introduction

Programming language

79

Tools

Page 80: Presented by…. Group 2 1. Programming language 2Introduction

Developer Tools

80

MS Visual Studio

Dreamweaver

Notepad++Notepad

Edit Plus

Page 81: Presented by…. Group 2 1. Programming language 2Introduction

Debug Tools

81

Page 82: Presented by…. Group 2 1. Programming language 2Introduction

Debug Tools

82

Elements panel

Resources panel

Network panel

Script

Timeline

Profiles tool

Audits panel

Console

Page 83: Presented by…. Group 2 1. Programming language 2Introduction

Programming language

83

3 - Tiers

Page 84: Presented by…. Group 2 1. Programming language 2Introduction

3 - Tiers

Data Layer

Business Logic Layer

Presentation Layer UI Pages

Background Pages

Content Scripts

84

Page 85: Presented by…. Group 2 1. Programming language 2Introduction

3 Tiers(cont.)

Data Layer

Business Logic Layer

Presentation Layer

Chrome Extension

Web Service

Database

85

Page 86: Presented by…. Group 2 1. Programming language 2Introduction

Programming language

86

Final Term Project

Page 87: Presented by…. Group 2 1. Programming language 2Introduction

87

Page 88: Presented by…. Group 2 1. Programming language 2Introduction

Thank you

88