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

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

Issue 10913243: extensions: Add ExtensionView interface. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: weak Created 8 years, 2 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | chrome/browser/extensions/extension_host.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) 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_HOST_H_ 5 #ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_HOST_H_
6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_HOST_H_ 6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_HOST_H_
7 7
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/logging.h" 11 #include "base/logging.h"
12 #include "base/memory/scoped_ptr.h" 12 #include "base/memory/scoped_ptr.h"
13 #include "base/perftimer.h" 13 #include "base/perftimer.h"
14 #include "chrome/browser/extensions/extension_function_dispatcher.h" 14 #include "chrome/browser/extensions/extension_function_dispatcher.h"
15 #include "chrome/common/view_type.h" 15 #include "chrome/common/view_type.h"
16 #include "content/public/browser/javascript_dialogs.h" 16 #include "content/public/browser/javascript_dialogs.h"
17 #include "content/public/browser/notification_observer.h" 17 #include "content/public/browser/notification_observer.h"
18 #include "content/public/browser/notification_registrar.h" 18 #include "content/public/browser/notification_registrar.h"
19 #include "content/public/browser/web_contents_delegate.h" 19 #include "content/public/browser/web_contents_delegate.h"
20 #include "content/public/browser/web_contents_observer.h" 20 #include "content/public/browser/web_contents_observer.h"
21 21
22 #if defined(TOOLKIT_VIEWS)
23 #include "chrome/browser/ui/views/extensions/extension_view_views.h"
24 #elif defined(OS_MACOSX)
25 #include "chrome/browser/ui/cocoa/extensions/extension_view_mac.h"
26 #elif defined(TOOLKIT_GTK)
27 #include "chrome/browser/ui/gtk/extensions/extension_view_gtk.h"
28 #elif defined(OS_ANDROID)
29 #include "chrome/browser/ui/android/extensions/extension_view_android.h"
30 #endif
31
32 class Browser; 22 class Browser;
23 class ExtensionView;
33 class PrefsTabHelper; 24 class PrefsTabHelper;
34 25
35 namespace content { 26 namespace content {
36 class RenderProcessHost; 27 class RenderProcessHost;
37 class RenderWidgetHostView; 28 class RenderWidgetHostView;
38 class SiteInstance; 29 class SiteInstance;
39 class WebIntentsDispatcher; 30 class WebIntentsDispatcher;
40 } 31 }
41 32
42 namespace extensions { 33 namespace extensions {
43 class Extension; 34 class Extension;
44 class WindowController; 35 class WindowController;
45 36
46 // This class is the browser component of an extension component's RenderView. 37 // This class is the browser component of an extension component's RenderView.
47 // It handles setting up the renderer process, if needed, with special 38 // It handles setting up the renderer process, if needed, with special
48 // privileges available to extensions. It may have a view to be shown in the 39 // privileges available to extensions. It may have a view to be shown in the
49 // browser UI, or it may be hidden. 40 // browser UI, or it may be hidden.
50 class ExtensionHost : public content::WebContentsDelegate, 41 class ExtensionHost : public content::WebContentsDelegate,
51 public content::WebContentsObserver, 42 public content::WebContentsObserver,
52 public ExtensionFunctionDispatcher::Delegate, 43 public ExtensionFunctionDispatcher::Delegate,
53 public content::NotificationObserver { 44 public content::NotificationObserver {
54 public: 45 public:
55 class ProcessCreationQueue; 46 class ProcessCreationQueue;
56 47
57 #if defined(TOOLKIT_VIEWS)
58 typedef ExtensionViewViews PlatformExtensionView;
59 #elif defined(OS_MACOSX)
60 typedef ExtensionViewMac PlatformExtensionView;
61 #elif defined(TOOLKIT_GTK)
62 typedef ExtensionViewGtk PlatformExtensionView;
63 #elif defined(OS_ANDROID)
64 // Android does not support extensions.
65 typedef ExtensionViewAndroid PlatformExtensionView;
66 #endif
67
68 ExtensionHost(const Extension* extension, 48 ExtensionHost(const Extension* extension,
69 content::SiteInstance* site_instance, 49 content::SiteInstance* site_instance,
70 const GURL& url, chrome::ViewType host_type); 50 const GURL& url,
51 chrome::ViewType host_type);
71 virtual ~ExtensionHost(); 52 virtual ~ExtensionHost();
72 53
73 #if defined(TOOLKIT_VIEWS) 54 void SetExtensionView(ExtensionView* view);
74 void set_view(PlatformExtensionView* view) { view_.reset(view); }
75 #endif
76 55
77 const PlatformExtensionView* view() const { 56 const ExtensionView* GetExtensionView() const;
78 #if defined(OS_ANDROID) 57 ExtensionView* GetExtensionView();
79 NOTREACHED();
80 #endif
81 return view_.get();
82 }
83
84 PlatformExtensionView* view() {
85 #if defined(OS_ANDROID)
86 NOTREACHED();
87 #endif
88 return view_.get();
89 }
90 58
91 // Create an ExtensionView and tie it to this host and |browser|. Note NULL 59 // Create an ExtensionView and tie it to this host and |browser|. Note NULL
92 // is a valid argument for |browser|. Extension views may be bound to 60 // is a valid argument for |browser|. Extension views may be bound to
93 // tab-contents hosted in ExternalTabContainer objects, which do not 61 // tab-contents hosted in ExternalTabContainer objects, which do not
94 // instantiate Browser objects. 62 // instantiate Browser objects.
95 void CreateView(Browser* browser); 63 void CreateView(Browser* browser);
96 64
97 const Extension* extension() const { return extension_; } 65 const Extension* extension() const { return extension_; }
98 const std::string& extension_id() const { return extension_id_; } 66 const std::string& extension_id() const { return extension_id_; }
99 content::WebContents* host_contents() const { return host_contents_.get(); } 67 content::WebContents* host_contents() const { return host_contents_.get(); }
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
201 169
202 // Handles keyboard events that were not handled by HandleKeyboardEvent(). 170 // Handles keyboard events that were not handled by HandleKeyboardEvent().
203 // Platform specific implementation may override this method to handle the 171 // Platform specific implementation may override this method to handle the
204 // event in platform specific way. 172 // event in platform specific way.
205 virtual void UnhandledKeyboardEvent( 173 virtual void UnhandledKeyboardEvent(
206 content::WebContents* source, 174 content::WebContents* source,
207 const content::NativeWebKeyboardEvent& event); 175 const content::NativeWebKeyboardEvent& event);
208 176
209 // Returns true if we're hosting a background page. 177 // Returns true if we're hosting a background page.
210 // This isn't valid until CreateRenderView is called. 178 // This isn't valid until CreateRenderView is called.
211 bool is_background_page() const { return !view(); } 179 bool is_background_page() const { return !GetExtensionView(); }
212 180
213 // The extension that we're hosting in this view. 181 // The extension that we're hosting in this view.
214 const Extension* extension_; 182 const Extension* extension_;
215 183
216 // Id of extension that we're hosting in this view. 184 // Id of extension that we're hosting in this view.
217 const std::string extension_id_; 185 const std::string extension_id_;
218 186
219 // The profile that this host is tied to. 187 // The profile that this host is tied to.
220 Profile* profile_; 188 Profile* profile_;
221 189
222 // Optional view that shows the rendered content in the UI. 190 // Optional view that shows the rendered content in the UI.
223 scoped_ptr<PlatformExtensionView> view_; 191 scoped_ptr<ExtensionView> extension_view_;
224 192
225 // Used to create dialog boxes. 193 // Used to create dialog boxes.
226 // It must outlive host_contents_ as host_contents_ will access it 194 // It must outlive host_contents_ as host_contents_ will access it
227 // during destruction. 195 // during destruction.
228 scoped_ptr<content::JavaScriptDialogCreator> dialog_creator_; 196 scoped_ptr<content::JavaScriptDialogCreator> dialog_creator_;
229 197
230 // The host for our HTML content. 198 // The host for our HTML content.
231 scoped_ptr<content::WebContents> host_contents_; 199 scoped_ptr<content::WebContents> host_contents_;
232 200
233 // Helpers that take care of extra functionality for our host contents. 201 // Helpers that take care of extra functionality for our host contents.
(...skipping 25 matching lines...) Expand all
259 227
260 // Used to measure how long it's been since the host was created. 228 // Used to measure how long it's been since the host was created.
261 PerfTimer since_created_; 229 PerfTimer since_created_;
262 230
263 DISALLOW_COPY_AND_ASSIGN(ExtensionHost); 231 DISALLOW_COPY_AND_ASSIGN(ExtensionHost);
264 }; 232 };
265 233
266 } // namespace extensions 234 } // namespace extensions
267 235
268 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_HOST_H_ 236 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_HOST_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/extensions/extension_host.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698