| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| 11 | 11 |
| 12 #include "base/memory/weak_ptr.h" | 12 #include "base/memory/weak_ptr.h" |
| 13 #include "chrome/browser/profiles/profile.h" | 13 #include "chrome/browser/profiles/profile.h" |
| 14 #include "ipc/ipc_message.h" | 14 #include "ipc/ipc_message.h" |
| 15 #include "googleurl/src/gurl.h" | 15 #include "googleurl/src/gurl.h" |
| 16 | 16 |
| 17 class ChromeRenderMessageFilter; | 17 class ChromeRenderMessageFilter; |
| 18 class Extension; | |
| 19 class ExtensionFunction; | 18 class ExtensionFunction; |
| 20 class ExtensionWindowController; | 19 class ExtensionWindowController; |
| 21 class ExtensionInfoMap; | 20 class ExtensionInfoMap; |
| 22 class Profile; | 21 class Profile; |
| 23 struct ExtensionHostMsg_Request_Params; | 22 struct ExtensionHostMsg_Request_Params; |
| 24 | 23 |
| 25 namespace content { | 24 namespace content { |
| 26 class RenderViewHost; | 25 class RenderViewHost; |
| 27 class WebContents; | 26 class WebContents; |
| 28 } | 27 } |
| 29 | 28 |
| 30 namespace extensions { | 29 namespace extensions { |
| 30 class Extension; |
| 31 class ExtensionAPI; | 31 class ExtensionAPI; |
| 32 class ProcessMap; | 32 class ProcessMap; |
| 33 } | 33 } |
| 34 | 34 |
| 35 // A factory function for creating new ExtensionFunction instances. | 35 // A factory function for creating new ExtensionFunction instances. |
| 36 typedef ExtensionFunction* (*ExtensionFunctionFactory)(); | 36 typedef ExtensionFunction* (*ExtensionFunctionFactory)(); |
| 37 | 37 |
| 38 // ExtensionFunctionDispatcher receives requests to execute functions from | 38 // ExtensionFunctionDispatcher receives requests to execute functions from |
| 39 // Chrome extensions running in a RenderViewHost and dispatches them to the | 39 // Chrome extensions running in a RenderViewHost and dispatches them to the |
| 40 // appropriate handler. It lives entirely on the UI thread. | 40 // appropriate handler. It lives entirely on the UI thread. |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 97 ~ExtensionFunctionDispatcher(); | 97 ~ExtensionFunctionDispatcher(); |
| 98 | 98 |
| 99 Delegate* delegate() { return delegate_; } | 99 Delegate* delegate() { return delegate_; } |
| 100 | 100 |
| 101 // Message handlers. | 101 // Message handlers. |
| 102 void Dispatch(const ExtensionHostMsg_Request_Params& params, | 102 void Dispatch(const ExtensionHostMsg_Request_Params& params, |
| 103 content::RenderViewHost* sender); | 103 content::RenderViewHost* sender); |
| 104 | 104 |
| 105 // Called when an ExtensionFunction is done executing, after it has sent | 105 // Called when an ExtensionFunction is done executing, after it has sent |
| 106 // a response (if any) to the extension. | 106 // a response (if any) to the extension. |
| 107 void OnExtensionFunctionCompleted(const Extension* extension); | 107 void OnExtensionFunctionCompleted(const extensions::Extension* extension); |
| 108 | 108 |
| 109 // The profile that this dispatcher is associated with. | 109 // The profile that this dispatcher is associated with. |
| 110 Profile* profile() { return profile_; } | 110 Profile* profile() { return profile_; } |
| 111 | 111 |
| 112 private: | 112 private: |
| 113 // Helper to create an ExtensionFunction to handle the function given by | 113 // Helper to create an ExtensionFunction to handle the function given by |
| 114 // |params|. Can be called on any thread. | 114 // |params|. Can be called on any thread. |
| 115 // Does not set subclass properties, or include_incognito. | 115 // Does not set subclass properties, or include_incognito. |
| 116 static ExtensionFunction* CreateExtensionFunction( | 116 static ExtensionFunction* CreateExtensionFunction( |
| 117 const ExtensionHostMsg_Request_Params& params, | 117 const ExtensionHostMsg_Request_Params& params, |
| 118 const Extension* extension, | 118 const extensions::Extension* extension, |
| 119 int requesting_process_id, | 119 int requesting_process_id, |
| 120 const extensions::ProcessMap& process_map, | 120 const extensions::ProcessMap& process_map, |
| 121 extensions::ExtensionAPI* api, | 121 extensions::ExtensionAPI* api, |
| 122 void* profile, | 122 void* profile, |
| 123 IPC::Message::Sender* ipc_sender, | 123 IPC::Message::Sender* ipc_sender, |
| 124 int routing_id); | 124 int routing_id); |
| 125 | 125 |
| 126 // Helper to send an access denied error to the requesting renderer. Can be | 126 // Helper to send an access denied error to the requesting renderer. Can be |
| 127 // called on any thread. | 127 // called on any thread. |
| 128 static void SendAccessDenied(IPC::Message::Sender* ipc_sender, | 128 static void SendAccessDenied(IPC::Message::Sender* ipc_sender, |
| 129 int routing_id, | 129 int routing_id, |
| 130 int request_id); | 130 int request_id); |
| 131 | 131 |
| 132 Profile* profile_; | 132 Profile* profile_; |
| 133 | 133 |
| 134 Delegate* delegate_; | 134 Delegate* delegate_; |
| 135 }; | 135 }; |
| 136 | 136 |
| 137 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_FUNCTION_DISPATCHER_H_ | 137 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_FUNCTION_DISPATCHER_H_ |
| OLD | NEW |