Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(33)

Side by Side Diff: go-back-with-backspace/background.js

Issue 2351743003: Inject automatically on install etc., add mime types, and fix nits. (Closed)
Patch Set: Review responses Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « go-back-with-backspace/_locales/en/messages.json ('k') | go-back-with-backspace/build-zip.sh » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 Google Inc. All rights reserved. 1 // Copyright 2016 Google Inc. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // Put up an informative message on first install. 5 // Inject the content scripts into all open tabs on first install or update.
6 chrome.runtime.onInstalled.addListener(function(details) { 6 chrome.runtime.onInstalled.addListener(function(details) {
7 if (details.reason == "install") { 7 if (details.reason == 'install' || details.reason === 'update')
8 chrome.tabs.create({url: "pages/installed.html"}); 8 injectContentScripts();
9 }
10 }); 9 });
10
11 // Inject the content scripts into all open tabs when this extension is
12 // re-enabled.
13 chrome.management.onEnabled.addListener(function(info) {
14 if (info.id === chrome.runtime.id)
15 injectContentScripts();
16 });
17
18 // Listen for messages from the content script, so an old version can detect
19 // the loss of connection and disable itself when the extension has been
20 // updated, disabled, or uninstalled.
21 chrome.runtime.onMessage.addListener(function(message, from, reply) {
22 reply();
23 });
24
25 // Inject the content scripts into every open tab, on every window.
26 function injectContentScripts() {
27 var scripts = chrome.runtime.getManifest().content_scripts[0].js;
28
29 chrome.tabs.query({}, function(tabs) {
30 tabs.forEach(function(tab) {
31 scripts.forEach(function(script) {
32 // This will produce an error if extensions are prohibited on the
33 // tab (e.g., chrome:// pages), but we can ignore it.
34 chrome.tabs.executeScript(tab.id,
35 {
36 file: script,
37 allFrames: true,
38 runAt: 'document_start'
39 });
40 });
41 });
42 });
43 }
OLDNEW
« no previous file with comments | « go-back-with-backspace/_locales/en/messages.json ('k') | go-back-with-backspace/build-zip.sh » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698