OLD | NEW |
---|---|
(Empty) | |
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 CHROME_BROWSER_EXTENSIONS_ACTIVE_SCRIPT_CONTROLLER_H_ | |
6 #define CHROME_BROWSER_EXTENSIONS_ACTIVE_SCRIPT_CONTROLLER_H_ | |
7 | |
8 #include <map> | |
9 #include <set> | |
10 #include <string> | |
11 | |
12 #include "base/compiler_specific.h" | |
13 #include "base/memory/linked_ptr.h" | |
14 #include "chrome/browser/extensions/location_bar_controller_provider.h" | |
15 | |
16 namespace content { | |
17 class WebContents; | |
18 } | |
19 | |
20 class ExtensionAction; | |
21 | |
22 namespace extensions { | |
23 class Extension; | |
24 | |
25 // The provider for ExtensionActions corresponding to scripts which are actively | |
26 // running or need permission. | |
27 class ActiveScriptController : public LocationBarControllerProvider { | |
not at google - send to devlin
2014/05/08 20:47:09
"Controller" is not an accurate term at this point
Devlin
2014/05/08 23:01:00
Added a TODO, per offline conversation.
| |
28 public: | |
29 explicit ActiveScriptController(content::WebContents* web_contents); | |
30 virtual ~ActiveScriptController(); | |
31 | |
32 // Notify the ActiveScriptController that an extension is running a script. | |
33 // TODO(rdevlin.cronin): Soon, this should be ask the user for permission, | |
34 // rather than simply notifying them. | |
35 void NotifyScriptExecuting(const std::string& extension_id, int page_id); | |
not at google - send to devlin
2014/05/08 20:47:09
it would be a more convenient interface to pass th
Devlin
2014/05/08 23:01:00
Since this is forwarded via IPC, it doesn't make s
| |
36 | |
37 // Returns true if there is an entry for the given |extension_id|. | |
38 bool HasActionForExtensionId(const std::string& extension_id); | |
not at google - send to devlin
2014/05/08 20:47:09
ditto
Devlin
2014/05/08 23:01:00
Moot.
| |
39 | |
40 // LocationBarControllerProvider implementation. | |
41 virtual ExtensionAction* GetActionForExtension( | |
42 const Extension* extension) OVERRIDE; | |
43 virtual LocationBarController::Action OnClicked( | |
44 const Extension* extension) OVERRIDE; | |
45 virtual void OnNavigated() OVERRIDE; | |
46 | |
47 private: | |
48 // The associated WebContents. | |
49 content::WebContents* web_contents_; | |
50 | |
51 // Whether or not the ActiveScriptController is enabled (corresponding to the | |
52 // kActiveScriptEnforcement switch). If it is not, it acts as an empty shell, | |
53 // always allowing scripts to run and never displaying actions. | |
54 bool enabled_; | |
55 | |
56 // The extensions that have called ExecuteScript on the current frame. | |
57 std::set<std::string> extensions_executing_scripts_; | |
58 | |
59 // Script badges that have been generated for extensions. This is both those | |
60 // with actions already declared that are copied and normalised, and actions | |
61 // that get generated for extensions that haven't declared anything. | |
62 typedef std::map<std::string, linked_ptr<ExtensionAction> > ActiveScriptMap; | |
63 ActiveScriptMap active_script_actions_; | |
64 | |
65 DISALLOW_COPY_AND_ASSIGN(ActiveScriptController); | |
66 }; | |
67 | |
68 } // namespace extensions | |
69 | |
70 #endif // CHROME_BROWSER_EXTENSIONS_ACTIVE_SCRIPT_CONTROLLER_H_ | |
OLD | NEW |