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