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 CHROME_BROWSER_EXTENSIONS_ACTIVE_SCRIPT_CONTROLLER_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_ACTIVE_SCRIPT_CONTROLLER_H_ |
6 #define CHROME_BROWSER_EXTENSIONS_ACTIVE_SCRIPT_CONTROLLER_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_ACTIVE_SCRIPT_CONTROLLER_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <set> | 9 #include <set> |
10 #include <string> | 10 #include <string> |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
51 // extension. | 51 // extension. |
52 void OnActiveTabPermissionGranted(const Extension* extension); | 52 void OnActiveTabPermissionGranted(const Extension* extension); |
53 | 53 |
54 // Notifies the ActiveScriptController of detected ad injection. | 54 // Notifies the ActiveScriptController of detected ad injection. |
55 void OnAdInjectionDetected(const std::set<std::string>& ad_injectors); | 55 void OnAdInjectionDetected(const std::set<std::string>& ad_injectors); |
56 | 56 |
57 // Adds the visible origin to |extension|'s active permissions, granting | 57 // Adds the visible origin to |extension|'s active permissions, granting |
58 // |extension| permission to always run script injections on the origin. | 58 // |extension| permission to always run script injections on the origin. |
59 void AlwaysRunOnVisibleOrigin(const Extension* extension); | 59 void AlwaysRunOnVisibleOrigin(const Extension* extension); |
60 | 60 |
| 61 // Notifies the ActiveScriptController that the action for |extension| has |
| 62 // been clicked, running any pending tasks that were previously shelved. |
| 63 void OnClicked(const Extension* extension); |
| 64 |
61 // Returns true if there is an active script injection action for |extension|. | 65 // Returns true if there is an active script injection action for |extension|. |
62 bool HasActiveScriptAction(const Extension* extension); | 66 bool HasActiveScriptAction(const Extension* extension); |
63 | 67 |
64 // LocationBarControllerProvider implementation. | 68 // LocationBarControllerProvider implementation. |
65 virtual ExtensionAction* GetActionForExtension( | 69 virtual ExtensionAction* GetActionForExtension( |
66 const Extension* extension) OVERRIDE; | 70 const Extension* extension) OVERRIDE; |
67 virtual ExtensionAction::ShowAction OnClicked( | |
68 const Extension* extension) OVERRIDE; | |
69 virtual void OnNavigated() OVERRIDE; | 71 virtual void OnNavigated() OVERRIDE; |
70 virtual void OnExtensionUnloaded(const Extension* extension) OVERRIDE; | 72 virtual void OnExtensionUnloaded(const Extension* extension) OVERRIDE; |
71 | 73 |
72 #if defined(UNIT_TEST) | 74 #if defined(UNIT_TEST) |
73 // Only used in tests. | 75 // Only used in tests. |
74 PermissionsData::AccessType RequiresUserConsentForScriptInjectionForTesting( | 76 PermissionsData::AccessType RequiresUserConsentForScriptInjectionForTesting( |
75 const Extension* extension, | 77 const Extension* extension, |
76 UserScript::InjectionType type) { | 78 UserScript::InjectionType type) { |
77 return RequiresUserConsentForScriptInjection(extension, type); | 79 return RequiresUserConsentForScriptInjection(extension, type); |
78 } | 80 } |
(...skipping 12 matching lines...) Expand all Loading... |
91 // via RequestScriptInjection(). | 93 // via RequestScriptInjection(). |
92 PermissionsData::AccessType RequiresUserConsentForScriptInjection( | 94 PermissionsData::AccessType RequiresUserConsentForScriptInjection( |
93 const Extension* extension, | 95 const Extension* extension, |
94 UserScript::InjectionType type); | 96 UserScript::InjectionType type); |
95 | 97 |
96 // |callback|. The only assumption that can be made about when (or if) | 98 // |callback|. The only assumption that can be made about when (or if) |
97 // |callback| is run is that, if it is run, it will run on the current page. | 99 // |callback| is run is that, if it is run, it will run on the current page. |
98 void RequestScriptInjection(const Extension* extension, | 100 void RequestScriptInjection(const Extension* extension, |
99 const base::Closure& callback); | 101 const base::Closure& callback); |
100 | 102 |
101 // Register a request for a script injection, to be executed by running | |
102 // Runs any pending injections for the corresponding extension. | 103 // Runs any pending injections for the corresponding extension. |
103 void RunPendingForExtension(const Extension* extension); | 104 void RunPendingForExtension(const Extension* extension); |
104 | 105 |
105 // Handle the RequestScriptInjectionPermission message. | 106 // Handle the RequestScriptInjectionPermission message. |
106 void OnRequestScriptInjectionPermission( | 107 void OnRequestScriptInjectionPermission( |
107 const std::string& extension_id, | 108 const std::string& extension_id, |
108 UserScript::InjectionType script_type, | 109 UserScript::InjectionType script_type, |
109 int64 request_id); | 110 int64 request_id); |
110 | 111 |
111 // Grants permission for the given request to run. | 112 // Grants permission for the given request to run. |
(...skipping 24 matching lines...) Expand all Loading... |
136 // that get generated for extensions that haven't declared anything. | 137 // that get generated for extensions that haven't declared anything. |
137 typedef std::map<std::string, linked_ptr<ExtensionAction> > ActiveScriptMap; | 138 typedef std::map<std::string, linked_ptr<ExtensionAction> > ActiveScriptMap; |
138 ActiveScriptMap active_script_actions_; | 139 ActiveScriptMap active_script_actions_; |
139 | 140 |
140 DISALLOW_COPY_AND_ASSIGN(ActiveScriptController); | 141 DISALLOW_COPY_AND_ASSIGN(ActiveScriptController); |
141 }; | 142 }; |
142 | 143 |
143 } // namespace extensions | 144 } // namespace extensions |
144 | 145 |
145 #endif // CHROME_BROWSER_EXTENSIONS_ACTIVE_SCRIPT_CONTROLLER_H_ | 146 #endif // CHROME_BROWSER_EXTENSIONS_ACTIVE_SCRIPT_CONTROLLER_H_ |
OLD | NEW |