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

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

Issue 11117011: Keep browser process alive while there are platform apps with background pages running. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Delegated Created 8 years, 1 month 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
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
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 45
46 // 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.
47 // It handles setting up the renderer process, if needed, with special 47 // 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 48 // privileges available to extensions. It may have a view to be shown in the
49 // browser UI, or it may be hidden. 49 // browser UI, or it may be hidden.
50 class ExtensionHost : public content::WebContentsDelegate, 50 class ExtensionHost : public content::WebContentsDelegate,
51 public content::WebContentsObserver, 51 public content::WebContentsObserver,
52 public ExtensionFunctionDispatcher::Delegate, 52 public ExtensionFunctionDispatcher::Delegate,
53 public content::NotificationObserver { 53 public content::NotificationObserver {
54 public: 54 public:
55 // Any behavior that is different for different types of background hosts
56 // should go in ExtensionHost::Delegate. ExtensionHost::Delegate is not
57 // abstract, this class provides the default behavior.
58 class Delegate {
Yoyo Zhou 2012/10/30 01:35:22 As we discussed, this delegate feels like more com
benwells 2012/10/30 02:55:23 I agree with your comments. I don't like passing t
Aaron Boodman 2012/10/30 05:30:08 This sounds like a good plan to me!
59 public:
60 Delegate() {}
61 virtual ~Delegate() {}
62
63 // True if the browser process should be kept alive while this extension
64 // host is active.
65 virtual bool KeepsBrowserProcessAlive();
66 };
67
55 class ProcessCreationQueue; 68 class ProcessCreationQueue;
56 69
57 #if defined(TOOLKIT_VIEWS) 70 #if defined(TOOLKIT_VIEWS)
58 typedef ExtensionViewViews PlatformExtensionView; 71 typedef ExtensionViewViews PlatformExtensionView;
59 #elif defined(OS_MACOSX) 72 #elif defined(OS_MACOSX)
60 typedef ExtensionViewMac PlatformExtensionView; 73 typedef ExtensionViewMac PlatformExtensionView;
61 #elif defined(TOOLKIT_GTK) 74 #elif defined(TOOLKIT_GTK)
62 typedef ExtensionViewGtk PlatformExtensionView; 75 typedef ExtensionViewGtk PlatformExtensionView;
63 #elif defined(OS_ANDROID) 76 #elif defined(OS_ANDROID)
64 // Android does not support extensions. 77 // Android does not support extensions.
65 typedef ExtensionViewAndroid PlatformExtensionView; 78 typedef ExtensionViewAndroid PlatformExtensionView;
66 #endif 79 #endif
67 80
81 // The ExtensionHost will take ownership of |delegate|.
68 ExtensionHost(const Extension* extension, 82 ExtensionHost(const Extension* extension,
83 Delegate* delegate,
69 content::SiteInstance* site_instance, 84 content::SiteInstance* site_instance,
70 const GURL& url, chrome::ViewType host_type); 85 const GURL& url, chrome::ViewType host_type);
71 virtual ~ExtensionHost(); 86 virtual ~ExtensionHost();
72 87
73 #if defined(TOOLKIT_VIEWS) 88 #if defined(TOOLKIT_VIEWS)
74 void set_view(PlatformExtensionView* view) { view_.reset(view); } 89 void set_view(PlatformExtensionView* view) { view_.reset(view); }
75 #endif 90 #endif
76 91
77 const PlatformExtensionView* view() const { 92 const PlatformExtensionView* view() const {
78 #if defined(OS_ANDROID) 93 #if defined(OS_ANDROID)
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
212 227
213 // The extension that we're hosting in this view. 228 // The extension that we're hosting in this view.
214 const Extension* extension_; 229 const Extension* extension_;
215 230
216 // Id of extension that we're hosting in this view. 231 // Id of extension that we're hosting in this view.
217 const std::string extension_id_; 232 const std::string extension_id_;
218 233
219 // The profile that this host is tied to. 234 // The profile that this host is tied to.
220 Profile* profile_; 235 Profile* profile_;
221 236
237 // The delegate for this host.
238 scoped_ptr<Delegate> delegate_;
239
222 // Optional view that shows the rendered content in the UI. 240 // Optional view that shows the rendered content in the UI.
223 scoped_ptr<PlatformExtensionView> view_; 241 scoped_ptr<PlatformExtensionView> view_;
224 242
225 // Used to create dialog boxes. 243 // Used to create dialog boxes.
226 // It must outlive host_contents_ as host_contents_ will access it 244 // It must outlive host_contents_ as host_contents_ will access it
227 // during destruction. 245 // during destruction.
228 scoped_ptr<content::JavaScriptDialogCreator> dialog_creator_; 246 scoped_ptr<content::JavaScriptDialogCreator> dialog_creator_;
229 247
230 // The host for our HTML content. 248 // The host for our HTML content.
231 scoped_ptr<content::WebContents> host_contents_; 249 scoped_ptr<content::WebContents> host_contents_;
(...skipping 24 matching lines...) Expand all
256 274
257 // Used to measure how long it's been since the host was created. 275 // Used to measure how long it's been since the host was created.
258 PerfTimer since_created_; 276 PerfTimer since_created_;
259 277
260 DISALLOW_COPY_AND_ASSIGN(ExtensionHost); 278 DISALLOW_COPY_AND_ASSIGN(ExtensionHost);
261 }; 279 };
262 280
263 } // namespace extensions 281 } // namespace extensions
264 282
265 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_HOST_H_ 283 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_HOST_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698