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

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

Issue 160276: mole expand/collapse API (Closed)
Patch Set: fixed a couple of crashers Created 11 years, 4 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
« no previous file with comments | « chrome/browser/browser.cc ('k') | chrome/browser/extensions/extension_function_dispatcher.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "googleurl/src/gurl.h" 13 #include "googleurl/src/gurl.h"
14 14
15 class Browser; 15 class Browser;
16 class ExtensionFunction; 16 class ExtensionFunction;
17 class ExtensionHost;
17 class Profile; 18 class Profile;
18 class RenderViewHost; 19 class RenderViewHost;
19 class RenderViewHostDelegate; 20 class RenderViewHostDelegate;
20 21
21 // A factory function for creating new ExtensionFunction instances. 22 // A factory function for creating new ExtensionFunction instances.
22 typedef ExtensionFunction* (*ExtensionFunctionFactory)(); 23 typedef ExtensionFunction* (*ExtensionFunctionFactory)();
23 24
24 // ExtensionFunctionDispatcher receives requests to execute functions from 25 // ExtensionFunctionDispatcher receives requests to execute functions from
25 // Chromium extensions running in a RenderViewHost and dispatches them to the 26 // Chromium extensions running in a RenderViewHost and dispatches them to the
26 // appropriate handler. It lives entirely on the UI thread. 27 // appropriate handler. It lives entirely on the UI thread.
27 class ExtensionFunctionDispatcher { 28 class ExtensionFunctionDispatcher {
28 public: 29 public:
29 class Delegate { 30 class Delegate {
30 public: 31 public:
31 virtual Browser* GetBrowser() = 0; 32 virtual Browser* GetBrowser() = 0;
33 virtual ExtensionHost* GetExtensionHost() { return NULL; }
32 }; 34 };
33 35
34 // The peer object allows us to notify ExtensionFunctions when we are 36 // The peer object allows us to notify ExtensionFunctions when we are
35 // destroyed. 37 // destroyed.
36 struct Peer : public base::RefCounted<Peer> { 38 struct Peer : public base::RefCounted<Peer> {
37 Peer(ExtensionFunctionDispatcher* dispatcher) : dispatcher_(dispatcher) {} 39 Peer(ExtensionFunctionDispatcher* dispatcher) : dispatcher_(dispatcher) {}
38 ExtensionFunctionDispatcher* dispatcher_; 40 ExtensionFunctionDispatcher* dispatcher_;
39 }; 41 };
40 42
41 // Gets a list of all known extension function names. 43 // Gets a list of all known extension function names.
(...skipping 19 matching lines...) Expand all
61 void HandleRequest(const std::string& name, const std::string& args, 63 void HandleRequest(const std::string& name, const std::string& args,
62 int request_id, bool has_callback); 64 int request_id, bool has_callback);
63 65
64 // Send a response to a function. 66 // Send a response to a function.
65 void SendResponse(ExtensionFunction* api, bool success); 67 void SendResponse(ExtensionFunction* api, bool success);
66 68
67 // Gets the browser extension functions should operate relative to. For 69 // Gets the browser extension functions should operate relative to. For
68 // example, for positioning windows, or alert boxes, or creating tabs. 70 // example, for positioning windows, or alert boxes, or creating tabs.
69 Browser* GetBrowser(); 71 Browser* GetBrowser();
70 72
73 // Gets the ExtensionHost associated with this object. In the case of
74 // tab hosted extension pages, this will return NULL.
75 ExtensionHost* GetExtensionHost();
76
71 // Handle a malformed message. Possibly the result of an attack, so kill 77 // Handle a malformed message. Possibly the result of an attack, so kill
72 // the renderer. 78 // the renderer.
73 void HandleBadMessage(ExtensionFunction* api); 79 void HandleBadMessage(ExtensionFunction* api);
74 80
75 // Gets the URL for the view we're displaying. 81 // Gets the URL for the view we're displaying.
76 const GURL& url() { return url_; } 82 const GURL& url() { return url_; }
77 83
78 // Gets the ID for this extension. 84 // Gets the ID for this extension.
79 const std::string extension_id() { return url_.host(); } 85 const std::string extension_id() { return url_.host(); }
80 86
(...skipping 14 matching lines...) Expand all
95 101
96 // AutomationExtensionFunction requires access to the RenderViewHost 102 // AutomationExtensionFunction requires access to the RenderViewHost
97 // associated with us. We make it a friend rather than exposing the 103 // associated with us. We make it a friend rather than exposing the
98 // RenderViewHost as a public method as we wouldn't want everyone to 104 // RenderViewHost as a public method as we wouldn't want everyone to
99 // start assuming a 1:1 relationship between us and RenderViewHost, 105 // start assuming a 1:1 relationship between us and RenderViewHost,
100 // whereas AutomationExtensionFunction is by necessity "tight" with us. 106 // whereas AutomationExtensionFunction is by necessity "tight" with us.
101 friend class AutomationExtensionFunction; 107 friend class AutomationExtensionFunction;
102 }; 108 };
103 109
104 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_FUNCTION_DISPATCHER_H_ 110 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_FUNCTION_DISPATCHER_H_
OLDNEW
« no previous file with comments | « chrome/browser/browser.cc ('k') | chrome/browser/extensions/extension_function_dispatcher.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698