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

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

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