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_EXTENSION_ACTION_RUNNER_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_ACTION_RUNNER_H_ |
6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_ACTION_RUNNER_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_ACTION_RUNNER_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <map> | 10 #include <map> |
11 #include <set> | 11 #include <set> |
12 #include <string> | 12 #include <string> |
13 #include <vector> | 13 #include <vector> |
14 | 14 |
15 #include "base/callback.h" | 15 #include "base/callback.h" |
16 #include "base/compiler_specific.h" | 16 #include "base/compiler_specific.h" |
17 #include "base/macros.h" | 17 #include "base/macros.h" |
18 #include "base/scoped_observer.h" | 18 #include "base/scoped_observer.h" |
| 19 #include "chrome/browser/extensions/extension_action.h" |
19 #include "content/public/browser/web_contents_observer.h" | 20 #include "content/public/browser/web_contents_observer.h" |
20 #include "extensions/browser/blocked_action_type.h" | 21 #include "extensions/browser/blocked_action_type.h" |
21 #include "extensions/browser/extension_registry_observer.h" | 22 #include "extensions/browser/extension_registry_observer.h" |
22 #include "extensions/common/permissions/permissions_data.h" | 23 #include "extensions/common/permissions/permissions_data.h" |
23 #include "extensions/common/user_script.h" | 24 #include "extensions/common/user_script.h" |
24 | 25 |
25 namespace content { | 26 namespace content { |
26 class BrowserContext; | 27 class BrowserContext; |
27 class WebContents; | 28 class WebContents; |
28 } | 29 } |
29 | 30 |
30 namespace IPC { | 31 namespace IPC { |
31 class Message; | 32 class Message; |
32 } | 33 } |
33 | 34 |
34 class ExtensionAction; | |
35 | |
36 namespace extensions { | 35 namespace extensions { |
37 class Extension; | 36 class Extension; |
38 class ExtensionRegistry; | 37 class ExtensionRegistry; |
39 | 38 |
40 // The provider for ExtensionActions corresponding to scripts which are actively | 39 // The provider for ExtensionActions corresponding to scripts which are actively |
41 // running or need permission. | 40 // running or need permission. |
42 class ExtensionActionRunner : public content::WebContentsObserver, | 41 class ExtensionActionRunner : public content::WebContentsObserver, |
43 public ExtensionRegistryObserver { | 42 public ExtensionRegistryObserver { |
44 public: | 43 public: |
45 explicit ExtensionActionRunner(content::WebContents* web_contents); | 44 explicit ExtensionActionRunner(content::WebContents* web_contents); |
46 ~ExtensionActionRunner() override; | 45 ~ExtensionActionRunner() override; |
47 | 46 |
48 // Returns the ExtensionActionRunner for the given |web_contents|, or NULL | 47 // Returns the ExtensionActionRunner for the given |web_contents|, or null |
49 // if one does not exist. | 48 // if one does not exist. |
50 static ExtensionActionRunner* GetForWebContents( | 49 static ExtensionActionRunner* GetForWebContents( |
51 content::WebContents* web_contents); | 50 content::WebContents* web_contents); |
52 | 51 |
| 52 // Executes the action for the given |extension| and returns any further |
| 53 // action (like showing a popup) that should be taken. If |
| 54 // |grant_tab_permissions| is true, this will also grant activeTab to the |
| 55 // extension (so this should only be done if this is through a direct user |
| 56 // action). |
| 57 ExtensionAction::ShowAction RunAction(const Extension* extension, |
| 58 bool grant_tab_permissions); |
| 59 |
| 60 // Runs any actions that were blocked for the given |extension|. As a |
| 61 // requirement, this will grant activeTab permission to the extension. |
| 62 void RunBlockedActions(const Extension* extension); |
| 63 |
53 // Notifies the ExtensionActionRunner that an extension has been granted | 64 // Notifies the ExtensionActionRunner that an extension has been granted |
54 // active tab permissions. This will run any pending injections for that | 65 // active tab permissions. This will run any pending injections for that |
55 // extension. | 66 // extension. |
56 void OnActiveTabPermissionGranted(const Extension* extension); | 67 void OnActiveTabPermissionGranted(const Extension* extension); |
57 | 68 |
58 // Notifies the ExtensionActionRunner that the action for |extension| has | |
59 // been clicked, running any pending tasks that were previously shelved. | |
60 void OnClicked(const Extension* extension); | |
61 | |
62 // Called when a webRequest event for the given |extension| was blocked. | 69 // Called when a webRequest event for the given |extension| was blocked. |
63 void OnWebRequestBlocked(const Extension* extension); | 70 void OnWebRequestBlocked(const Extension* extension); |
64 | 71 |
65 // Returns a bitmask of BlockedActionType for the actions that have been | 72 // Returns a bitmask of BlockedActionType for the actions that have been |
66 // blocked for the given extension. | 73 // blocked for the given extension. |
67 int GetBlockedActions(const Extension* extension); | 74 int GetBlockedActions(const Extension* extension); |
68 | 75 |
69 // Returns true if the given |extension| has any blocked actions. | 76 // Returns true if the given |extension| has any blocked actions. |
70 bool WantsToRun(const Extension* extension); | 77 bool WantsToRun(const Extension* extension); |
71 | 78 |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
172 | 179 |
173 ScopedObserver<ExtensionRegistry, ExtensionRegistryObserver> | 180 ScopedObserver<ExtensionRegistry, ExtensionRegistryObserver> |
174 extension_registry_observer_; | 181 extension_registry_observer_; |
175 | 182 |
176 DISALLOW_COPY_AND_ASSIGN(ExtensionActionRunner); | 183 DISALLOW_COPY_AND_ASSIGN(ExtensionActionRunner); |
177 }; | 184 }; |
178 | 185 |
179 } // namespace extensions | 186 } // namespace extensions |
180 | 187 |
181 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_ACTION_RUNNER_H_ | 188 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_ACTION_RUNNER_H_ |
OLD | NEW |