| 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 Browser; | 17 class Browser; |
| 18 class ChromeRenderMessageFilter; | 18 class ChromeRenderMessageFilter; |
| 19 class Extension; | 19 class Extension; |
| 20 class ExtensionFunction; | 20 class ExtensionFunction; |
| 21 class Profile; | 21 class Profile; |
| 22 class RenderViewHost; | |
| 23 struct ExtensionHostMsg_Request_Params; | 22 struct ExtensionHostMsg_Request_Params; |
| 24 | 23 |
| 25 namespace content { | 24 namespace content { |
| 25 class RenderViewHost; |
| 26 class WebContents; | 26 class WebContents; |
| 27 } | 27 } |
| 28 | 28 |
| 29 namespace extensions { | 29 namespace extensions { |
| 30 class ProcessMap; | 30 class ProcessMap; |
| 31 } | 31 } |
| 32 | 32 |
| 33 // A factory function for creating new ExtensionFunction instances. | 33 // A factory function for creating new ExtensionFunction instances. |
| 34 typedef ExtensionFunction* (*ExtensionFunctionFactory)(); | 34 typedef ExtensionFunction* (*ExtensionFunctionFactory)(); |
| 35 | 35 |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 91 // - This object outlives any RenderViewHost's passed to created | 91 // - This object outlives any RenderViewHost's passed to created |
| 92 // ExtensionFunctions. | 92 // ExtensionFunctions. |
| 93 ExtensionFunctionDispatcher(Profile* profile, Delegate* delegate); | 93 ExtensionFunctionDispatcher(Profile* profile, Delegate* delegate); |
| 94 | 94 |
| 95 ~ExtensionFunctionDispatcher(); | 95 ~ExtensionFunctionDispatcher(); |
| 96 | 96 |
| 97 Delegate* delegate() { return delegate_; } | 97 Delegate* delegate() { return delegate_; } |
| 98 | 98 |
| 99 // Message handlers. | 99 // Message handlers. |
| 100 void Dispatch(const ExtensionHostMsg_Request_Params& params, | 100 void Dispatch(const ExtensionHostMsg_Request_Params& params, |
| 101 RenderViewHost* sender); | 101 content::RenderViewHost* sender); |
| 102 | 102 |
| 103 // Called when an ExtensionFunction is done executing, after it has sent | 103 // Called when an ExtensionFunction is done executing, after it has sent |
| 104 // a response (if any) to the extension. | 104 // a response (if any) to the extension. |
| 105 void OnExtensionFunctionCompleted(const Extension* extension); | 105 void OnExtensionFunctionCompleted(const Extension* extension); |
| 106 | 106 |
| 107 // Returns the current browser. Callers should generally prefer | 107 // Returns the current browser. Callers should generally prefer |
| 108 // ExtensionFunction::GetCurrentBrowser() over this method, as that one | 108 // ExtensionFunction::GetCurrentBrowser() over this method, as that one |
| 109 // provides the correct value for |include_incognito|. | 109 // provides the correct value for |include_incognito|. |
| 110 // | 110 // |
| 111 // See the comments for ExtensionFunction::GetCurrentBrowser() for more | 111 // See the comments for ExtensionFunction::GetCurrentBrowser() for more |
| 112 // details. | 112 // details. |
| 113 Browser* GetCurrentBrowser(RenderViewHost* render_view_host, | 113 Browser* GetCurrentBrowser(content::RenderViewHost* render_view_host, |
| 114 bool include_incognito); | 114 bool include_incognito); |
| 115 | 115 |
| 116 // The profile that this dispatcher is associated with. | 116 // The profile that this dispatcher is associated with. |
| 117 Profile* profile() { return profile_; } | 117 Profile* profile() { return profile_; } |
| 118 | 118 |
| 119 private: | 119 private: |
| 120 // Helper to create an ExtensionFunction to handle the function given by | 120 // Helper to create an ExtensionFunction to handle the function given by |
| 121 // |params|. Can be called on any thread. | 121 // |params|. Can be called on any thread. |
| 122 // Does not set subclass properties, or include_incognito. | 122 // Does not set subclass properties, or include_incognito. |
| 123 static ExtensionFunction* CreateExtensionFunction( | 123 static ExtensionFunction* CreateExtensionFunction( |
| (...skipping 10 matching lines...) Expand all Loading... |
| 134 static void SendAccessDenied(IPC::Message::Sender* ipc_sender, | 134 static void SendAccessDenied(IPC::Message::Sender* ipc_sender, |
| 135 int routing_id, | 135 int routing_id, |
| 136 int request_id); | 136 int request_id); |
| 137 | 137 |
| 138 Profile* profile_; | 138 Profile* profile_; |
| 139 | 139 |
| 140 Delegate* delegate_; | 140 Delegate* delegate_; |
| 141 }; | 141 }; |
| 142 | 142 |
| 143 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_FUNCTION_DISPATCHER_H_ | 143 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_FUNCTION_DISPATCHER_H_ |
| OLD | NEW |