2. 그 ¶
- Plug-in extension program고 게 . 기 기 .. =ㅂ= 그 .json 간고 CSS HTML. DOM 구 고 . 그 간 긁 HTML element Naver Plug-in 까 .
4.1. 꼭 고 각 ¶
- Chrome extention overview
- Overview
- Tutorial (getstarted) with fileset(manifest.json,.js,.html)
- manifest.json attribute.
- Contents policy security. 기 꼭
- Overview
4.2.1. 기기 ¶
개 API 금 고 code developer . index 과 .
Tutorial 과 .
그 거 게
Chrome 경( ) -> 구 -> 그 -> 개 Check -> 그 그 .
4.2.2. 기 ¶
flickr permission 긁 그 . 구 HTML CSS. AJAX, Javascript (AJAX 겠 ) 구. json . 군.
Wikipedia JSON : http://ko.wikipedia.org/wiki/JSON
게 국. 간 고 그 javascript구 . xml web 과기 web 고 . 거 .
Wikipedia Ajax : http://ko.wikipedia.org/wiki/Ajax
Ajax 기 고기 (A Asyncronous) HTML과 CSS DOM 구 XML, json Ajax 기 기 .
기까 .
.
- : manifest.json menifest.json update . json element , . 그 .
4.2.2.1. ¶
- popup.js
// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. var req = new XMLHttpRequest(); req.open( "GET", "http://api.flickr.com/services/rest/?" + "method=flickr.photos.search&" + "api_key=90485e931f687a9b9c2a66bf58a3861a&" + "text=hello%20world&" + "safe_search=1&" + // 1 is "safe" "content_type=1&" + // 1 is "photos only" "sort=relevance&" + // another good one is "interestingness-desc" "per_page=20", true); req.onload = showPhotos; req.send(null); function showPhotos() { var photos = req.responseXML.getElementsByTagName("photo"); for (var i = 0, photo; photo = photos[i]; i++) { var img = document.createElement("image"); img.src = constructImageURL(photo); document.body.appendChild(img); } } // See: http://www.flickr.com/services/api/misc.urls.html function constructImageURL(photo) { return "http://farm" + photo.getAttribute("farm") + ".static.flickr.com/" + photo.getAttribute("server") + "/" + photo.getAttribute("id") + "_" + photo.getAttribute("secret") + "_s.jpg"; }
- popup.html
<!doctype html> <html> <head> <title>Getting Started Extension's Popup</title> <style> body { min-width:357px; overflow-x:hidden; } img { margin:5px; border:2px solid black; vertical-align:middle; width:75px; height:75px; } </style> <!-- JavaScript and HTML must be in separate files for security. --> <script src="popup.js"></script> </head> <body> </body> </html>
- manifest.json
{ "name": "My First Extension", "version": "1.0", "manifest_version": 2, "description": "The first extension that I made.", "browser_action": { "default_icon": "icon.png", "default_popup": "popup.html" }, "permissions": [ "http://api.flickr.com/" ] }
4.2.3.1. 기 구 ¶
- window.open body .
- index.html
<html> <head> <script language="javascript"> <!-- function na_open_window(name, url, left, top, width, height, toolbar, menubar, statusbar, scrollbar, resizable) { toolbar_str = toolbar ? 'yes' : 'no'; menubar_str = menubar ? 'yes' : 'no'; statusbar_str = statusbar ? 'yes' : 'no'; scrollbar_str = scrollbar ? 'yes' : 'no'; resizable_str = resizable ? 'yes' : 'no'; window.open(url, name, 'left='+left+',top='+top+',width='+width+',height='+height +',toolbar='+toolbar_str+',menubar=' +menubar_str+',status='+statusbar_str+',scrollbars='+scrollbar_str +',resizable='+resizable_str); } // --> </script> </head> <body ondblclick = "na_open_window('win', 'popup.html', 50, 100, 100, 30, 0, 0, 0, 0, 0)"> </body> </html>
- na-open_window status_bar 기 popup 고 . 0 false까.
- javascript document.body.ondblclick = .
- popup.html
<html> Hello World! </html>
4.2.4.1. History extension ¶
- 격과 공. 구 공 Sample .
{ "name" : "BrowsingData API: Basics", "version" : "1.1", "description" : "A trivial usage example.", "permissions": [ "browsingData" ], "browser_action": { "default_icon": "icon.png", "default_popup": "popup.html" //게 그 popup . browser_action default_popup action icon popup . }, "manifest_version": 2 }
4.2.4.2. Contents policy security ¶
- .
- : http://code.google.com/chrome/extensions/contentSecurityPolicy.html
- inline script cross script attack 기 html과 contents 고 . 규 inline javascript .js .
<div OnClick="func()">
html 그 inline attach 기 document element document.addEventListener event function 결게 . 거 . 각 .