15821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Copyright (c) 2011 The Chromium Authors. All rights reserved. 25821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be 35821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// found in the LICENSE file. 45821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 55d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)// When the extension is installed or upgraded ... 65d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)chrome.runtime.onInstalled.addListener(function() { 75d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // Replace all rules ... 85d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) chrome.declarativeContent.onPageChanged.removeRules(undefined, function() { 95d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // With a new rule ... 105d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) chrome.declarativeContent.onPageChanged.addRules([ 115d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) { 125d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // That fires when a page's URL contains a 'g' ... 135d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) conditions: [ 145d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) new chrome.declarativeContent.PageStateMatcher({ 155d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) pageUrl: { urlContains: 'g' }, 165d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) }) 175d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) ], 185d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // And shows the extension's page action. 195d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) actions: [ new chrome.declarativeContent.ShowPageAction() ] 205d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) } 215d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) ]); 225d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) }); 235d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)}); 24