Chromium Code Reviews| 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 EXTENSIONS_BROWSER_EXTENSION_FUNCTION_DISPATCHER_H_ | 5 #ifndef EXTENSIONS_BROWSER_EXTENSION_FUNCTION_DISPATCHER_H_ |
| 6 #define EXTENSIONS_BROWSER_EXTENSION_FUNCTION_DISPATCHER_H_ | 6 #define EXTENSIONS_BROWSER_EXTENSION_FUNCTION_DISPATCHER_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 83 // functions that must be handled on the IO-thread. | 83 // functions that must be handled on the IO-thread. |
| 84 static void DispatchOnIOThread( | 84 static void DispatchOnIOThread( |
| 85 InfoMap* extension_info_map, | 85 InfoMap* extension_info_map, |
| 86 void* profile_id, | 86 void* profile_id, |
| 87 int render_process_id, | 87 int render_process_id, |
| 88 base::WeakPtr<IOThreadExtensionMessageFilter> ipc_sender, | 88 base::WeakPtr<IOThreadExtensionMessageFilter> ipc_sender, |
| 89 int routing_id, | 89 int routing_id, |
| 90 const ExtensionHostMsg_Request_Params& params); | 90 const ExtensionHostMsg_Request_Params& params); |
| 91 | 91 |
| 92 // Public constructor. Callers must ensure that: | 92 // Public constructor. Callers must ensure that: |
| 93 // - |delegate| outlives this object. | |
| 94 // - This object outlives any RenderViewHost's passed to created | 93 // - This object outlives any RenderViewHost's passed to created |
| 95 // ExtensionFunctions. | 94 // ExtensionFunctions. |
| 96 ExtensionFunctionDispatcher(content::BrowserContext* browser_context, | 95 ExtensionFunctionDispatcher(content::BrowserContext* browser_context); |
|
not at google - send to devlin
2015/06/10 18:37:49
explicit
Devlin
2015/06/10 20:59:20
Done.
| |
| 97 Delegate* delegate); | |
| 98 | |
| 99 ~ExtensionFunctionDispatcher(); | 96 ~ExtensionFunctionDispatcher(); |
| 100 | 97 |
| 101 Delegate* delegate() { return delegate_; } | |
| 102 | |
| 103 // Message handlers. | 98 // Message handlers. |
| 104 // The response is sent to the corresponding render view in an | 99 // The response is sent to the corresponding render view in an |
| 105 // ExtensionMsg_Response message. | 100 // ExtensionMsg_Response message. |
| 106 // TODO (jam): convert all callers to use RenderFrameHost. | 101 // TODO (jam): convert all callers to use RenderFrameHost. |
| 107 void Dispatch(const ExtensionHostMsg_Request_Params& params, | 102 void Dispatch(const ExtensionHostMsg_Request_Params& params, |
| 108 content::RenderViewHost* render_view_host); | 103 content::RenderViewHost* render_view_host); |
| 109 | 104 |
| 110 // Called when an ExtensionFunction is done executing, after it has sent | 105 // Called when an ExtensionFunction is done executing, after it has sent |
| 111 // a response (if any) to the extension. | 106 // a response (if any) to the extension. |
| 112 void OnExtensionFunctionCompleted(const Extension* extension); | 107 void OnExtensionFunctionCompleted(const Extension* extension); |
| 113 | 108 |
| 109 // See the Delegate class for documentation on these methods. | |
| 110 // TODO(devlin): None of these belong here. We should kill | |
| 111 // ExtensionFunctionDispatcher::Delegate. | |
| 112 WindowController* GetExtensionWindowController() const; | |
| 113 content::WebContents* GetAssociatedWebContents() const; | |
| 114 content::WebContents* GetVisibleWebContents() const; | |
| 115 | |
| 114 // The BrowserContext that this dispatcher is associated with. | 116 // The BrowserContext that this dispatcher is associated with. |
| 115 content::BrowserContext* browser_context() { return browser_context_; } | 117 content::BrowserContext* browser_context() { return browser_context_; } |
| 116 | 118 |
| 119 void set_delegate(Delegate* delegate) { delegate_ = delegate; } | |
| 120 | |
| 117 private: | 121 private: |
| 118 // For a given RenderViewHost instance, UIThreadResponseCallbackWrapper | 122 // For a given RenderViewHost instance, UIThreadResponseCallbackWrapper |
| 119 // creates ExtensionFunction::ResponseCallback instances which send responses | 123 // creates ExtensionFunction::ResponseCallback instances which send responses |
| 120 // to the corresponding render view in ExtensionMsg_Response messages. | 124 // to the corresponding render view in ExtensionMsg_Response messages. |
| 121 // This class tracks the lifespan of the RenderViewHost instance, and will be | 125 // This class tracks the lifespan of the RenderViewHost instance, and will be |
| 122 // destroyed automatically when it goes away. | 126 // destroyed automatically when it goes away. |
| 123 class UIThreadResponseCallbackWrapper; | 127 class UIThreadResponseCallbackWrapper; |
| 124 | 128 |
| 125 // Helper to check whether an ExtensionFunction has the required permissions. | 129 // Helper to check whether an ExtensionFunction has the required permissions. |
| 126 // This should be called after the function is fully initialized. | 130 // This should be called after the function is fully initialized. |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 163 // instance goes away, the corresponding entry in this map (if exists) will be | 167 // instance goes away, the corresponding entry in this map (if exists) will be |
| 164 // removed. | 168 // removed. |
| 165 typedef std::map<content::RenderViewHost*, UIThreadResponseCallbackWrapper*> | 169 typedef std::map<content::RenderViewHost*, UIThreadResponseCallbackWrapper*> |
| 166 UIThreadResponseCallbackWrapperMap; | 170 UIThreadResponseCallbackWrapperMap; |
| 167 UIThreadResponseCallbackWrapperMap ui_thread_response_callback_wrappers_; | 171 UIThreadResponseCallbackWrapperMap ui_thread_response_callback_wrappers_; |
| 168 }; | 172 }; |
| 169 | 173 |
| 170 } // namespace extensions | 174 } // namespace extensions |
| 171 | 175 |
| 172 #endif // EXTENSIONS_BROWSER_EXTENSION_FUNCTION_DISPATCHER_H_ | 176 #endif // EXTENSIONS_BROWSER_EXTENSION_FUNCTION_DISPATCHER_H_ |
| OLD | NEW |