| 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 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "base/memory/weak_ptr.h" | 11 #include "base/memory/weak_ptr.h" |
| 12 #include "chrome/browser/profiles/profile.h" | 12 #include "chrome/browser/profiles/profile.h" |
| 13 #include "ipc/ipc_sender.h" | 13 #include "ipc/ipc_sender.h" |
| 14 #include "googleurl/src/gurl.h" | 14 #include "googleurl/src/gurl.h" |
| 15 | 15 |
| 16 class ChromeRenderMessageFilter; | 16 class ChromeRenderMessageFilter; |
| 17 class ExtensionFunction; | 17 class ExtensionFunction; |
| 18 class ExtensionWindowController; | |
| 19 class ExtensionInfoMap; | 18 class ExtensionInfoMap; |
| 20 class Profile; | 19 class Profile; |
| 21 struct ExtensionHostMsg_Request_Params; | 20 struct ExtensionHostMsg_Request_Params; |
| 22 | 21 |
| 23 namespace content { | 22 namespace content { |
| 24 class RenderViewHost; | 23 class RenderViewHost; |
| 25 class WebContents; | 24 class WebContents; |
| 26 } | 25 } |
| 27 | 26 |
| 28 namespace extensions { | 27 namespace extensions { |
| 29 class Extension; | 28 class Extension; |
| 30 class ExtensionAPI; | 29 class ExtensionAPI; |
| 31 class ProcessMap; | 30 class ProcessMap; |
| 31 class WindowController; |
| 32 } | 32 } |
| 33 | 33 |
| 34 // A factory function for creating new ExtensionFunction instances. | 34 // A factory function for creating new ExtensionFunction instances. |
| 35 typedef ExtensionFunction* (*ExtensionFunctionFactory)(); | 35 typedef ExtensionFunction* (*ExtensionFunctionFactory)(); |
| 36 | 36 |
| 37 // ExtensionFunctionDispatcher receives requests to execute functions from | 37 // ExtensionFunctionDispatcher receives requests to execute functions from |
| 38 // Chrome extensions running in a RenderViewHost and dispatches them to the | 38 // Chrome extensions running in a RenderViewHost and dispatches them to the |
| 39 // appropriate handler. It lives entirely on the UI thread. | 39 // appropriate handler. It lives entirely on the UI thread. |
| 40 // | 40 // |
| 41 // ExtensionFunctionDispatcher should be a member of some class that hosts | 41 // ExtensionFunctionDispatcher should be a member of some class that hosts |
| 42 // RenderViewHosts and wants them to be able to display extension content. | 42 // RenderViewHosts and wants them to be able to display extension content. |
| 43 // This class should also implement ExtensionFunctionDispatcher::Delegate. | 43 // This class should also implement ExtensionFunctionDispatcher::Delegate. |
| 44 // | 44 // |
| 45 // Note that a single ExtensionFunctionDispatcher does *not* correspond to a | 45 // Note that a single ExtensionFunctionDispatcher does *not* correspond to a |
| 46 // single RVH, a single extension, or a single URL. This is by design so that | 46 // single RVH, a single extension, or a single URL. This is by design so that |
| 47 // we can gracefully handle cases like WebContents, where the RVH, extension, | 47 // we can gracefully handle cases like WebContents, where the RVH, extension, |
| 48 // and URL can all change over the lifetime of the tab. Instead, these items | 48 // and URL can all change over the lifetime of the tab. Instead, these items |
| 49 // are all passed into each request. | 49 // are all passed into each request. |
| 50 class ExtensionFunctionDispatcher | 50 class ExtensionFunctionDispatcher |
| 51 : public base::SupportsWeakPtr<ExtensionFunctionDispatcher> { | 51 : public base::SupportsWeakPtr<ExtensionFunctionDispatcher> { |
| 52 public: | 52 public: |
| 53 class Delegate { | 53 class Delegate { |
| 54 public: | 54 public: |
| 55 // Returns the ExtensionWindowController associated with this delegate, | 55 // Returns the extensions::WindowController associated with this delegate, |
| 56 // or NULL if no window is associated with the delegate. | 56 // or NULL if no window is associated with the delegate. |
| 57 virtual ExtensionWindowController* GetExtensionWindowController() const; | 57 virtual extensions::WindowController* GetExtensionWindowController() const; |
| 58 | 58 |
| 59 // Asks the delegate for any relevant WebContents associated with this | 59 // Asks the delegate for any relevant WebContents associated with this |
| 60 // context. For example, the WebbContents in which an infobar or | 60 // context. For example, the WebbContents in which an infobar or |
| 61 // chrome-extension://<id> URL are being shown. Callers must check for a | 61 // chrome-extension://<id> URL are being shown. Callers must check for a |
| 62 // NULL return value (as in the case of a background page). | 62 // NULL return value (as in the case of a background page). |
| 63 virtual content::WebContents* GetAssociatedWebContents() const; | 63 virtual content::WebContents* GetAssociatedWebContents() const; |
| 64 | 64 |
| 65 protected: | 65 protected: |
| 66 virtual ~Delegate() {} | 66 virtual ~Delegate() {} |
| 67 }; | 67 }; |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 127 static void SendAccessDenied(IPC::Sender* ipc_sender, | 127 static void SendAccessDenied(IPC::Sender* ipc_sender, |
| 128 int routing_id, | 128 int routing_id, |
| 129 int request_id); | 129 int request_id); |
| 130 | 130 |
| 131 Profile* profile_; | 131 Profile* profile_; |
| 132 | 132 |
| 133 Delegate* delegate_; | 133 Delegate* delegate_; |
| 134 }; | 134 }; |
| 135 | 135 |
| 136 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_FUNCTION_DISPATCHER_H_ | 136 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_FUNCTION_DISPATCHER_H_ |
| OLD | NEW |