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

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

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