Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(341)

Side by Side Diff: chrome/browser/extensions/extension_function_dispatcher.h

Issue 1627024: Add ExtensionFunctionDispatcher::Delegate::GetAssociatedTabContents (Closed)
Patch Set: cr changes Created 10 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 "base/ref_counted.h" 12 #include "base/ref_counted.h"
13 #include "gfx/native_widget_types.h" 13 #include "gfx/native_widget_types.h"
14 #include "googleurl/src/gurl.h" 14 #include "googleurl/src/gurl.h"
15 15
16 class Browser; 16 class Browser;
17 class Extension; 17 class Extension;
18 class ExtensionDOMUI; 18 class ExtensionDOMUI;
19 class ExtensionFunction; 19 class ExtensionFunction;
20 class ExtensionHost; 20 class ExtensionHost;
21 class Profile; 21 class Profile;
22 class RenderViewHost; 22 class RenderViewHost;
23 class RenderViewHostDelegate; 23 class RenderViewHostDelegate;
24 class TabContents;
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 // Returns the browser that this delegate is associated with, if any. 37 // Returns the browser that this delegate is associated with, if any.
37 // Returns NULL otherwise. 38 // Returns NULL otherwise.
38 virtual Browser* GetBrowser() const = 0; 39 virtual Browser* GetBrowser() const = 0;
39 40
40 // Returns the native view for this extension view, if any. This may be NULL 41 // Returns the native view for this extension view, if any. This may be NULL
41 // if the view is not visible. 42 // if the view is not visible.
42 virtual gfx::NativeView GetNativeViewOfHost() = 0; 43 virtual gfx::NativeView GetNativeViewOfHost() = 0;
43 44
44 // Typically, the window is assumed to be the window associated with the 45 // Typically, the window is assumed to be the window associated with the
45 // result of GetBrowser(). Implementations may override this behavior with 46 // result of GetBrowser(). Implementations may override this behavior with
46 // this method. 47 // this method.
47 virtual gfx::NativeWindow GetCustomFrameNativeWindow() { 48 virtual gfx::NativeWindow GetCustomFrameNativeWindow() {
48 return NULL; 49 return NULL;
49 } 50 }
50 51
52 // Asks the delegate for any relevant TabContents associated with this
53 // context. For example, the TabContents in which an infobar or
54 // chrome-extension://<id> URL are being shown. Callers must check for a
55 // NULL return value (as in the case of a background page).
56 virtual TabContents* associated_tab_contents() = 0;
57
51 protected: 58 protected:
52 virtual ~Delegate() {} 59 virtual ~Delegate() {}
53 }; 60 };
54 61
55 // The peer object allows us to notify ExtensionFunctions when we are 62 // The peer object allows us to notify ExtensionFunctions when we are
56 // destroyed. 63 // destroyed.
57 // TODO: this should use WeakPtr 64 // TODO: this should use WeakPtr
58 struct Peer : public base::RefCounted<Peer> { 65 struct Peer : public base::RefCounted<Peer> {
59 explicit Peer(ExtensionFunctionDispatcher* dispatcher) 66 explicit Peer(ExtensionFunctionDispatcher* dispatcher)
60 : dispatcher_(dispatcher) {} 67 : dispatcher_(dispatcher) {}
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 149
143 // AutomationExtensionFunction requires access to the RenderViewHost 150 // AutomationExtensionFunction requires access to the RenderViewHost
144 // associated with us. We make it a friend rather than exposing the 151 // associated with us. We make it a friend rather than exposing the
145 // RenderViewHost as a public method as we wouldn't want everyone to 152 // RenderViewHost as a public method as we wouldn't want everyone to
146 // start assuming a 1:1 relationship between us and RenderViewHost, 153 // start assuming a 1:1 relationship between us and RenderViewHost,
147 // whereas AutomationExtensionFunction is by necessity "tight" with us. 154 // whereas AutomationExtensionFunction is by necessity "tight" with us.
148 friend class AutomationExtensionFunction; 155 friend class AutomationExtensionFunction;
149 }; 156 };
150 157
151 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_FUNCTION_DISPATCHER_H_ 158 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_FUNCTION_DISPATCHER_H_
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_dom_ui.h ('k') | chrome/browser/extensions/extension_host.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698