1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 /** 6 * @filedescription Initializes the extension's background page. 7 */ 8 9 var nav = new NavigationCollector(); 10 11 var eventList = ['onBeforeNavigate', 'onCreatedNavigationTarget', 12 'onCommitted', 'onCompleted', 'onDOMContentLoaded', 13 'onErrorOccurred', 'onReferenceFragmentUpdated', 'onTabReplaced', 14 'onHistoryStateUpdated']; 15 16 eventList.forEach(function(e) { 17 chrome.webNavigation[e].addListener(function(data) { 18 if (typeof data) 19 console.log(chrome.i18n.getMessage('inHandler'), e, data); 20 else 21 console.error(chrome.i18n.getMessage('inHandlerError'), e); 22 }); 23 }); 24 25 // Reset the navigation state on startup. We only want to collect data within a 26 // session. 27 chrome.runtime.onStartup.addListener(function() { 28 nav.resetDataStorage(); 29 }); 30