OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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_FUNCTION_DISPATCHER_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_FUNCTION_DISPATCHER_H_ |
6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_FUNCTION_DISPATCHER_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_FUNCTION_DISPATCHER_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 #include <set> | 9 #include <set> |
10 #include <vector> | 10 #include <vector> |
11 | 11 |
| 12 #include "app/gfx/native_widget_types.h" |
12 #include "base/ref_counted.h" | 13 #include "base/ref_counted.h" |
13 #include "googleurl/src/gurl.h" | 14 #include "googleurl/src/gurl.h" |
14 | 15 |
15 class Browser; | 16 class Browser; |
16 class Extension; | 17 class Extension; |
17 class ExtensionDOMUI; | 18 class ExtensionDOMUI; |
18 class ExtensionFunction; | 19 class ExtensionFunction; |
19 class ExtensionHost; | 20 class ExtensionHost; |
20 class ExtensionPopupHost; | 21 class ExtensionPopupHost; |
21 class Profile; | 22 class Profile; |
22 class RenderViewHost; | 23 class RenderViewHost; |
23 class RenderViewHostDelegate; | 24 class RenderViewHostDelegate; |
24 class Value; | 25 class Value; |
25 | 26 |
26 // A factory function for creating new ExtensionFunction instances. | 27 // A factory function for creating new ExtensionFunction instances. |
27 typedef ExtensionFunction* (*ExtensionFunctionFactory)(); | 28 typedef ExtensionFunction* (*ExtensionFunctionFactory)(); |
28 | 29 |
29 // ExtensionFunctionDispatcher receives requests to execute functions from | 30 // ExtensionFunctionDispatcher receives requests to execute functions from |
30 // Chromium extensions running in a RenderViewHost and dispatches them to the | 31 // Chromium extensions running in a RenderViewHost and dispatches them to the |
31 // appropriate handler. It lives entirely on the UI thread. | 32 // appropriate handler. It lives entirely on the UI thread. |
32 class ExtensionFunctionDispatcher { | 33 class ExtensionFunctionDispatcher { |
33 public: | 34 public: |
34 class Delegate { | 35 class Delegate { |
35 public: | 36 public: |
36 virtual Browser* GetBrowser() = 0; | 37 virtual Browser* GetBrowser() const = 0; |
| 38 |
| 39 // Returns the gfx::NativeWindow that contains the view hosting the |
| 40 // environment in which the function dispatcher resides. |
| 41 virtual gfx::NativeWindow GetFrameNativeWindow(); |
| 42 |
37 virtual ExtensionHost* GetExtensionHost() { return NULL; } | 43 virtual ExtensionHost* GetExtensionHost() { return NULL; } |
38 virtual ExtensionDOMUI* GetExtensionDOMUI() { return NULL; } | 44 virtual ExtensionDOMUI* GetExtensionDOMUI() { return NULL; } |
39 }; | 45 }; |
40 | 46 |
41 // The peer object allows us to notify ExtensionFunctions when we are | 47 // The peer object allows us to notify ExtensionFunctions when we are |
42 // destroyed. | 48 // destroyed. |
43 // TODO: this should use WeakPtr | 49 // TODO: this should use WeakPtr |
44 struct Peer : public base::RefCounted<Peer> { | 50 struct Peer : public base::RefCounted<Peer> { |
45 explicit Peer(ExtensionFunctionDispatcher* dispatcher) | 51 explicit Peer(ExtensionFunctionDispatcher* dispatcher) |
46 : dispatcher_(dispatcher) {} | 52 : dispatcher_(dispatcher) {} |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
87 ExtensionPopupHost* GetPopupHost(); | 93 ExtensionPopupHost* GetPopupHost(); |
88 | 94 |
89 // Gets the ExtensionHost associated with this object. In the case of | 95 // Gets the ExtensionHost associated with this object. In the case of |
90 // tab hosted extension pages, this will return NULL. | 96 // tab hosted extension pages, this will return NULL. |
91 ExtensionHost* GetExtensionHost(); | 97 ExtensionHost* GetExtensionHost(); |
92 | 98 |
93 // Gets the ExtensionDOMUI associated with this object. In the case of | 99 // Gets the ExtensionDOMUI associated with this object. In the case of |
94 // non-tab-hosted extension pages, this will return NULL. | 100 // non-tab-hosted extension pages, this will return NULL. |
95 ExtensionDOMUI* GetExtensionDOMUI(); | 101 ExtensionDOMUI* GetExtensionDOMUI(); |
96 | 102 |
| 103 // Returns the gfx::NativeWindow that frames the view of the extension |
| 104 // containing the function dispatcher. This may return NULL. Refer to the |
| 105 // ExtensionFunctionDispatcher::Delegate::GetFrameNativeWindow() |
| 106 // implementation for an explanation. |
| 107 gfx::NativeWindow GetFrameNativeWindow(); |
| 108 |
97 // Gets the extension the function is being invoked by. This should not ever | 109 // Gets the extension the function is being invoked by. This should not ever |
98 // return NULL. | 110 // return NULL. |
99 Extension* GetExtension(); | 111 Extension* GetExtension(); |
100 | 112 |
101 // Handle a malformed message. Possibly the result of an attack, so kill | 113 // Handle a malformed message. Possibly the result of an attack, so kill |
102 // the renderer. | 114 // the renderer. |
103 void HandleBadMessage(ExtensionFunction* api); | 115 void HandleBadMessage(ExtensionFunction* api); |
104 | 116 |
105 // Gets the URL for the view we're displaying. | 117 // Gets the URL for the view we're displaying. |
106 const GURL& url() { return url_; } | 118 const GURL& url() { return url_; } |
(...skipping 18 matching lines...) Expand all Loading... |
125 | 137 |
126 // AutomationExtensionFunction requires access to the RenderViewHost | 138 // AutomationExtensionFunction requires access to the RenderViewHost |
127 // associated with us. We make it a friend rather than exposing the | 139 // associated with us. We make it a friend rather than exposing the |
128 // RenderViewHost as a public method as we wouldn't want everyone to | 140 // RenderViewHost as a public method as we wouldn't want everyone to |
129 // start assuming a 1:1 relationship between us and RenderViewHost, | 141 // start assuming a 1:1 relationship between us and RenderViewHost, |
130 // whereas AutomationExtensionFunction is by necessity "tight" with us. | 142 // whereas AutomationExtensionFunction is by necessity "tight" with us. |
131 friend class AutomationExtensionFunction; | 143 friend class AutomationExtensionFunction; |
132 }; | 144 }; |
133 | 145 |
134 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_FUNCTION_DISPATCHER_H_ | 146 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_FUNCTION_DISPATCHER_H_ |
OLD | NEW |