1// Copyright 2014 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#ifndef EXTENSIONS_BROWSER_SCRIPT_EXECUTION_OBSERVER_H_ 6#define EXTENSIONS_BROWSER_SCRIPT_EXECUTION_OBSERVER_H_ 7 8#include <map> 9#include <set> 10#include <string> 11 12class GURL; 13 14namespace content { 15class WebContents; 16} 17 18namespace extensions { 19 20// Observer base class for classes that need to be notified when content 21// scripts and/or tabs.executeScript calls run on a page. 22class ScriptExecutionObserver { 23 public: 24 // Map of extensions IDs to the executing script paths. 25 typedef std::map<std::string, std::set<std::string> > ExecutingScriptsMap; 26 27 // Called when script(s) have executed on a page. 28 // 29 // |executing_scripts_map| contains all extensions that are executing 30 // scripts, mapped to the paths for those scripts. This may be an empty set 31 // if the script has no path associated with it (e.g. in the case of 32 // tabs.executeScript). 33 virtual void OnScriptsExecuted( 34 const content::WebContents* web_contents, 35 const ExecutingScriptsMap& executing_scripts_map, 36 const GURL& on_url) = 0; 37 38 protected: 39 virtual ~ScriptExecutionObserver(); 40}; 41 42} // namespace extensions 43 44#endif // EXTENSIONS_BROWSER_SCRIPT_EXECUTION_OBSERVER_H_ 45