Google Chrome æ¡å¼µãã¨ã¯ãã
2009å¹´12æ8æ¥*1(æ¥æ¬æéã§ã¯12/9æ)ãæ¡å¼µæ©è½ãæå¹(é¤ãOSX)㪠Google Chrome ãã¼ã¿çããªãªã¼ã¹ããã¾ãããåæã«ãã¤ãã¤éçºãç¶ãã¦ããã¯ã¦ãªããã¯ãã¼ã¯ Google Chrome æ¡å¼µãã¼ã¿çãå ¬éããã®ã§ãè¯ãã£ãã使ã£ã¦ã¿ã¦ãã ãã :D
ã¨ããããã§ãGoogle Chrome æ¡å¼µãä½ã£ã¦ã¿ãã®ã§ããããã®æã«åèã«ããè³æãããã¥ã¡ã³ããã¾ã¨ãã¦ã¿ã¾ããã
Google Chrome æ¡å¼µAPIããã¥ã¡ã³ã
åºæ¬çã«ä¸ã®URLã§å¿
è¦ãªAPIã®ããã¥ã¡ã³ãã¯ã¾ã¨ãããã¦ãã¾ããã¾ããã¼ã¸ä¸å¤®ä¸ã®ãDoc versionsãã§ãã©ã¦ã¶ã®ãã¼ã¸ã§ã³ã«æ²¿ã£ãããã¥ã¡ã³ããå
¬éããã¦ãã®ã§ãbetaåãã®ããã¥ã¡ã³ããªã etentions/beta ãèªãã¨è¯ãã§ãããããªããç¾å¨ã®ãã¼ã¿ã§å®è£
ããã¦ããæ¡å¼µAPIã¯ããã°ãã£ãã¯ã¹ä»¥å¤ã¯æ£å¼çã¨å¤æ´ã¯ãªãäºå®ã¿ããã§ãã
ã¾ããAPI ã®ååãå¼æ°ãæ¸ããã JSON ãããã¾ããä¸ææ experimental ãªå®é¨ä¸ã®APIã使ã£ã¦ããããæã
確èªãã¦ãã¾ããã
ãªãã£ã·ã£ã«ãµã¤ã
ãã®è¾ºãããè¦ã¦ãã¾ãããç¹ã« chromium extentions ã°ã«ã¼ã㯠Google ã®ä¸ã®äººãã ãããè¿çããããã®ã§ãæ¡å¼µAPIãæåã«å¯¾ããçåãããã°æããã¨è¯ãã§ãããã
- http://chrome.blogspot.com/
- Google Chrome ããã°
- http://groups.google.co.jp/group/chromium-extensions
- chromium extensions ã°ã«ã¼ãã§ããæ´»çºã«ããã¨ãããã¦ãã¾ãã
æ¥æ¬èªããã¥ã¡ã³ã
id:os0x ããã gihyo.jp ã«ã¦é£è¼ããã¦ãã Google Chrome æ¡å¼µè¨äºãé常ã«åèã«ãªãã¾ããå¾ã ã«æ©è½ã追å ãã¦ãã課ç¨ããã°ãããã§ããä»ã¯ Toolstrips ãã*2ãããªãã®ã§ãã¾ãåããªãç®æãããã¾ãããåºæ¬çãªç®æã¯ç¾å¨ã®APIã§ãã ããã使ããããå¿ èªã§ããã¡ããã©æ¡å¼µãä½ããã¨æã£ãã¿ã¤ãã³ã°ã§è¨äºã®é£è¼ãå§ã¾ã£ãã®ã§ããã®è¨äºããªãã£ãããã¾ããã©ããªã£ã¦ããäºããâ¦ãid:os0x ããã®ã¯ã¦ãªãã¤ã¢ãªã¼æ¥è¨ãªã©ãåèã«ãªããos0x ããã«ã¯è¶³ãåãã¦å¯ããªãæ¥ã ã§ãã
git ã¬ãã¸ããª
chromium ã® git ã§ã®ã½ã¼ã¹ã³ã¼ãå ¬éãè¡ãããããå®éã®æåãææ¡ããããããã git grep APIå ãªã©ã§ç´æ¥ã½ã¼ã¹è¿½ã£ããã¦ãã¾ããã以ä¸ã« git ã§ã® chromium ã®å©ç¨ãæ¸ããã¦ãã¾ãã
ã²ãªå½¢ä½æ
chrome-extention-statrter ã¨ããã¸ã§ãã¬ã¼ã¿ã§ã²ãªå½¢ãä½ãã¾ããã
- http://subtech.g.hatena.ne.jp/secondlife/20090925/1253863388 (ç¾å¨ gems.github.com ããã¾ãè¦ããªããã)
ãã®ã¸ã§ãã¬ã¼ã¿ãä½æããã¨åæã« Rakefile ãã§ããããã®ã§
rake package
ã§æ¡å¼µã® .crx ããã±ã¼ã¸ãä½æãã¦ãã¾ããã¾ã crx ããã±ã¼ã¸ã®ä½æã«ã¯ãid:Constellation ããä½ã®ã³ãã³ãã©ã¤ã³ãã chrome ããã±ã¼ã¸ãä½æã§ãã crxmake ã使ã£ã¦ãã¾ãã便å©ï¼
Chrome æ¡å¼µéçºç¨ã®ãã·ã§ã¼ãã«ããã¨å¼æ°
æ¡å¼µãéçºããã¨ãã«ã¯ãGoogle Chrome ã®ã·ã§ã¼ãã«ãããæå®ãã以ä¸ã®å¼æ°ãæå®ãã¦éçºããã¦ãã¾ããã
chrome.exe --enable-logging --purge-memory-button --load-extension="C:\chrome\bookmark-googlechrome-extension\src" --user-data-dir="C:\tmp\chrome_dev_data"
- --purge-momery-button
- æ¡å¼µãã¡ã¢ãªã¼ãªã¼ã¯ããªããã®ç¢ºèªã®ãããShift+Esc 㧠Chrome å°ç¨ã®ã¿ã¹ã¯ããã¼ã¸ã£ãèµ·åãã¦ãã§ãã¯ãã¦ãã¾ãã
- --load-extension
- éçºãã¦ããæ¡å¼µã®å®ã½ã¼ã¹ã³ã¼ããå¼æ°ã¨ãã¦æ¸¡ãã¨ããã®æ¡å¼µãèªã¿è¾¼ãã ç¶æ 㧠Chrome ãç«ã¡ä¸ããã¾ããChrome ã®æ¡å¼µæ©è½ã®ç»é¢ã§ã®æ¡å¼µã®åèªè¾¼ã disable/enable åã¯åèªè¾¼ããã¦ãªãã±ã¼ã¹ã background page ã browser action ã§å¤çºããããããªã«ãã¨ãã©ã¦ã¶åèµ·åããªããéçºãã¦ããã®ã§ããã®ãããªå ´å便å©ã§ãã
- --user-data-dir
background ãã¼ã¸ã§ãç¹å®ãã¼ã¸ãéã
æ¡å¼µéçºã§ã¯ãããã©ã¦ã¶ãåèµ·åããããã以ä¸ã®ãããªæãã§æ¯åãã©ã¦ã¶èµ·åæã«ç¹å®ãã¼ã¸ãéã㦠test ã®å®è¡ããpopup ã¦ã£ã³ãã¦ã®ãããã°(popup ã¦ã£ã³ãã¦ã¯ãã¿ãã¨ãã¦éããªãã¨é常ã«éçºãã«ããã§ã)ãè¡ã£ã¦ãã¾ããã
/* setTimeout(function() { var url = 'http://www.hatena.ne.jp/'; url = '/background/popup.html?debug=1&url=' + encodeURIComponent(url); chrome.tabs.create({ url: url, }); }, 10); setTimeout(function() { chrome.windows.create({url:'../tests/test.html'}); // test ãéãã¦å®è¡ãã }, 10); */
å©ç¨ãã¦ããã©ã¤ãã©ãª
JavaScript ã®çµã¿è¾¼ã¿ã¯ã©ã¹ã® prototype ã® toJSON ãæ±æããªãã©ã¤ãã©ãª(æ±æããã©ã¤ãã©ãªãå©ç¨ããã¨ãJSON ã®æåã«å½±é¿ãåºãå¯è½æ§ãããã¾ã)ãªããåºæ¬ã©ããªã©ã¤ãã©ãªã§ãå©ç¨ã§ããã¨æãã¾ãããã¹ã¦ã®ç®æã HTML + JS ã§æ§ç¯ããã¦ããã®ã§ãã»ã¨ãã©ã®JSã©ã¤ãã©ãªãå©ç¨å¯è½ãªã®ã§ãã
ã¯ã¦ãªããã¯ãã¼ã¯ chrome æ¡å¼µã§ã¯ä»¥ä¸ã®ã©ã¤ãã©ãªãå©ç¨ãã¦ãã¾ãããããç¨åº¦ã®è¦æ¨¡ã«ãªãã¾ã§ã¯ã©ã¤ãã©ãªã使ããéçºããæ¹ãã·ã³ãã«ã«ã¾ã¨ã¾ã£ã¦è¯ãã¨æãã¾ãã
- jQuery ã® extend, Ajax ã®æåå¤æ´ãå ããç©
- http://subtech.g.hatena.ne.jp/secondlife/20091015/1255591536
- 以ä¸ã®ã³ã¼ãã®ããã¼ã®ãããã«ã³ã¼ããããã¾ãã
- jsdeferred + jsdeffererd-webdatabase
- http://subtech.g.hatena.ne.jp/secondlife/20091008/1255003922
- æ¡å¼µä¸ãã SQL (Web SQL Database) ãå©ç¨ããããããã® SQL ç¨ã® ORãããã¼å©ç¨ãã¦ãã¾ã
Google Chrome æ¡å¼µã®å ¨ä½çãªææ³
Chrome ã®æ¡å¼µAPIã¯ãFirefox æ¡å¼µã«æ¯ã¹ã§ããã¨ã¯æ ¼æ®µã«å°ãªãã®ã§ãããã·ã³ãã«ã«ã³ã³ãã¯ãã«ã¾ã¨ã¾ã£ã¦ãããHTML + JavaScript ã®ç¥èããããã°ããã«éçºã«åããããããã¨ã大ããªé
åã§ãããå¦ç¿ã³ã¹ããé常ã«ä½ãã§ã*3ã
ã¾ã UI ãæ¡å¼µããã¯æä½éãããã1æ¡å¼µã«ä»ã1ã¢ã¤ã³ã³ (BrowserAction/PageAction ã©ã¡ããä¸ã¤ã ã) ã®ã¿ã®å®è£
ããã§ããªãã¨ããå²ãåãå æ¸ããä¹±é㪠UI ãåºãªãã¨ããç¹ã§ã¯è©ä¾¡ã§ããã§ãããã
ãããç¾ç¶ã§ã¯å対ã«äºãã°ã©ã®æ¡å¼µãæä½ãéç¥ã«ã¢ã¤ã³ã³ã表示ããããããã®é åãçµæ§åºãããããã¨ãã° Firefox ã§ããã¹ãã¼ã¿ã¹ãã¼ã«ã·ã³ãã«ãªå°ããã¢ã¤ã³ã³ã ã表示ããã¡ãã¥ã¼ãæ¡å¼µãããã¨ã§è¡ãããããªå®è£
ã§ãã¢ã¤ã³ã³ãå¿
è¦ã¨ãªãããã¼ã«ãã¼ã«ã¢ã¤ã³ã³ã表示ãããããããããããã¾ãã
ä»æ¥ã®æ¡å¼µã®ã£ã©ãªã¼ãè¦ãã¨ãããã¯ãã¼ã¯ã¬ããã¬ãã«ã§äºè¶³ããæ©è½ã BrowserAction ã§ããããå®è£
ãã¦ãã£ããããã®ã§ããã®è¾ºã®æ¡å¼µã¯å¾ã
ã«ä½¿ãããªããªãããããªãããªã¼ã¨æã£ã¦ã¾ãã
ä»ã«ã BrowserAction ã®ãããã¢ããã¦ã£ã³ãã¦ãæ¡å¼µAPIçµç±ã§éããªãã£ãããã¦*4ããã¼ãã¼ãæ´¾ã«ã¯çµæ§ã¤ããã£ãããã¾ãããã 次ã®æ¬¡ã®æ£å¼ç(M5, ç¾å¨ã®æ£å¼çã¯M3)ãããã§ã¯ããå¿
è¦ã¨ãããã¦ããæ©è½ã¯APIã«ãããã¾ããããæ´ç·´ããã¦ãããããªã®ã§æå¾
ãã¦ãã¾ãã
ã¨ããããã§ãé常ã«ç°¡åã«æ¡å¼µéçºãã§ããã®ã§ããã¼ã¿ãªãªã¼ã¹ã§ API ãå¤ããå¿é ãã»ã¨ãã©ç¡ããªã£ãä»ããã£ããçãããä½ã£ã¦ã¿ã¦ã¯ãããã§ããããï¼
*1:ãããç´ºéããç¾ããããã¬æ±ã¢ãã¦ã³ãµã¼ã«å ã å®ã決å®ããæ¥ã§ãï¼ï¼
*2:以åã® dev çã§å®è£ ããã¦ããããã¼ã«ãã¼çãªUIã§ãããã°ã£ããåé¤ããã¾ãããToolstrips ããã©ããã£ã¦ãããããâ¦ã
*3:Firefox ã JetPack ã§ç°¡åã«æ¡å¼µãä½æã§ãããã©ãããã©ã¼ã ãç¨æãã¦ããã¨ããã§ãã
*4:http://groups.google.co.jp/group/chromium-extensions/browse_thread/thread/be147238af6d3029/17d9ff73f1aa7af0#17d9ff73f1aa7af0 ã§ææ¡ã¯ãã¦ããã¾ãããå®è£ ã¯ä»ã®ã¨ãããããªããããªæãã§ã