summaryrefslogtreecommitdiffstats
path: root/extensions/browser/script_execution_observer.h
blob: 4204f137bd83cf1fca7a65730db6940c6d9dc3d8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef EXTENSIONS_BROWSER_SCRIPT_EXECUTION_OBSERVER_H_
#define EXTENSIONS_BROWSER_SCRIPT_EXECUTION_OBSERVER_H_

#include <map>
#include <set>
#include <string>

class GURL;

namespace content {
class WebContents;
}

namespace extensions {

// Observer base class for classes that need to be notified when content
// scripts and/or tabs.executeScript calls run on a page.
class ScriptExecutionObserver {
 public:
  // Map of extensions IDs to the executing script paths.
  typedef std::map<std::string, std::set<std::string> > ExecutingScriptsMap;

  // Called when script(s) have executed on a page.
  //
  // |executing_scripts_map| contains all extensions that are executing
  // scripts, mapped to the paths for those scripts. The paths may be an empty
  // set if the script has no path associated with it (e.g. in the case of
  // tabs.executeScript), but there will still be an entry for the extension.
  virtual void OnScriptsExecuted(
      const content::WebContents* web_contents,
      const ExecutingScriptsMap& executing_scripts_map,
      const GURL& on_url) = 0;

 protected:
  virtual ~ScriptExecutionObserver();
};

}  // namespace extensions

#endif  // EXTENSIONS_BROWSER_SCRIPT_EXECUTION_OBSERVER_H_