Skip to content

Commit

Permalink
Changes onInstalled event listener to action.onClicked (#971)
Browse files Browse the repository at this point in the history
* Changes onInstalled event listener to action.onClicked

* Update sandbox.html

* Update sandbox.html
  • Loading branch information
IanStanion-google authored Jun 30, 2023
1 parent 7e06728 commit 307da41
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
7 changes: 4 additions & 3 deletions api-samples/sandbox/sandbox/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@
"version": "1.0.3",
"manifest_version": 3,
"background": {
"service_worker": "service-worker.js"
},
"service_worker": "service-worker.js"
},
"icons": {
"128": "icon_128.png"
},
"sandbox": {
"pages": ["sandbox.html"]
}
},
"action": {}
}
8 changes: 4 additions & 4 deletions api-samples/sandbox/sandbox/sandbox.html
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,11 @@ <h1>Welcome back</h1>
// Set up message event handler:
window.addEventListener('message', function (event) {
const command = event.data.command;
let template = templates[event.data.templateName],
const template = templates[event.data.templateName],
result = 'invalid request';

// if we don't know the templateName requested, return an error message
if (!template) {
result = 'Unknown template: ' + event.data.templateName;
} else {
if (template) {
switch (command) {
case 'render':
result = template(event.data.context);
Expand All @@ -75,6 +73,8 @@ <h1>Welcome back</h1>
// result = template(event.data.context);
// break;
}
} else {
result = 'Unknown template: ' + event.data.templateName;
}
event.source.postMessage({ result: result }, event.origin);
});
Expand Down
2 changes: 1 addition & 1 deletion api-samples/sandbox/sandbox/service-worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
* @see http://developer.chrome.com/docs/extensions/reference/runtime
* @see http://developer.chrome.com/docs/extensions/reference/tabs
*/
chrome.runtime.onInstalled.addListener(() => {
chrome.action.onClicked.addListener(() => {
chrome.tabs.create({
url: 'mainpage.html'
});
Expand Down

0 comments on commit 307da41

Please sign in to comment.