chrome extension reload management

常駐時間が長くなるとメモリー利用がかなり大きくなって行くので・・・
オートリロード(エクステンションをリロード、初期化)したいなと思ったのですが
方法は、以下の通り。ですが、タイミングが難しい。定期的にでもなく。

毎日PCをシャットダウンするかchromeをシャットダウンして利用していただいている方には不要な機能なので
とりあえず、自動ではなくて、手動で、リロードボタンだけ置いても良いのですが、
普通に問題なく利用されている場合には、何か問題あるのかと無用な心配させてしまうかもしれないので

manifest.jsonにmanagementを追加

“permissions”: [
   "management"
 ],

myextension idに idを入れてください。getAllもあります。

chrome.management.get(‘myextension id’, function( info ){
   console.log(info);
 });

こんな内容を取得出来ます。

Object
description: “”
enabled: true
homepageUrl: “”
hostPermissions: Array[1]
0: “http://*/*”
length: 1
__proto__: Array[0]
icons: Array[3]
0: Object
1: Object
2: Object
length: 3
__proto__: Array[0]
id: “myextension id”
installType: “development”
isApp: false
mayDisable: true
name: “open with”
offlineEnabled: false
optionsUrl: “”
permissions: Array[2]
0: “contextMenus”
1: “management”
length: 2
__proto__: Array[0]
version: “0.1.0”
__proto__: Object

リロードは、setEnabledで実装します。

chrome.management.setEnabled(“myid”, false, function(){
 chrome.management.setEnabled(“myid”, true, function(){
   // reloaded
 });
});

managementのイヤなところは、setEnabled , uninstallとlaunchAppだけですが、他のアプリも操作出来てしまうというところですね
自分だけリロード出来れば十分なのですが。

This entry was posted on 日曜日, 11月 4th, 2012 at 12:34 PM and is filed under Chrome Extention, Javascript. You can follow any responses to this entry through the RSS 2.0 feed. Both comments and pings are currently closed.

Unityによるゲームを公開しております iOS/Android
https://itunes.apple.com/jp/app/lost-knight-3d-action/id900917032
https://play.google.com/store/apps/details?id=com.groundroad.runknight

各種開発支援・機能開発等小さいお仕事などもお請けしております。
unity開発支援, PHPシステム開発, javascript/html5 フロント開発, titanium mobileアプリ開発
お気軽にお問い合わせください
大崎・五反田近郊での対面でのお打ち合わせはいつでも可能です。