OLD | NEW |
---|---|
(Empty) | |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef CHROME_BROWSER_EXTENSIONS_PLATFORM_APP_HOST_H_ | |
6 #define CHROME_BROWSER_EXTENSIONS_PLATFORM_APP_HOST_H_ | |
7 #pragma once | |
8 | |
9 #include <string> | |
10 #include <vector> | |
11 | |
12 // TODO(benwells): review includes and forward decls | |
13 #include "base/logging.h" | |
14 #include "base/memory/scoped_ptr.h" | |
15 #include "base/perftimer.h" | |
16 #include "chrome/browser/extensions/extension_function_dispatcher.h" | |
17 #include "content/public/browser/notification_observer.h" | |
18 #include "content/public/browser/notification_registrar.h" | |
19 #include "content/public/browser/web_contents_delegate.h" | |
20 #include "content/public/browser/web_contents_observer.h" | |
21 #include "content/public/common/view_type.h" | |
22 | |
23 class Browser; | |
24 class Extension; | |
25 class PrefsTabHelper; | |
26 | |
27 namespace content { | |
28 class RenderProcessHost; | |
29 class RenderWidgetHostView; | |
30 class SiteInstance; | |
31 } | |
32 | |
33 // This class is the browser component of a platform app's RenderView. | |
34 // It handles setting up the renderer process, if needed. | |
35 class PlatformAppHost : public content::WebContentsDelegate, | |
Aaron Boodman
2012/04/20 07:05:53
Are you sure you don't want to just combine this w
benwells
2012/04/24 08:35:32
Yes that sounds like a great approach. I misunders
| |
36 public content::WebContentsObserver, | |
37 public ExtensionFunctionDispatcher::Delegate, | |
38 public content::NotificationObserver { | |
39 public: | |
40 PlatformAppHost(Profile* profile, | |
41 const GURL& url); | |
42 | |
43 virtual ~PlatformAppHost(); | |
44 | |
45 content::WebContents* host_contents() const { return host_contents_.get(); } | |
46 content::RenderViewHost* render_view_host() const { | |
47 return render_view_host_; | |
48 } | |
49 content::RenderProcessHost* render_process_host() const; | |
50 | |
51 Profile* profile() const { return profile_; } | |
benwells
2012/04/19 09:03:55
Profile can probably go too.
| |
52 | |
53 // ExtensionFunctionDispatcher::Delegate | |
54 virtual content::WebContents* GetAssociatedWebContents() const OVERRIDE; | |
55 void SetAssociatedWebContents(content::WebContents* web_contents); | |
56 | |
57 // Prepares to initializes our RenderViewHost by creating its RenderView and | |
58 // navigating to this host's url. Uses host_view for the RenderViewHost's view | |
59 // (can be NULL). This happens immediately, unlike ExtensionHost. | |
60 virtual void CreateRenderViewSoon() OVERRIDE; | |
61 | |
62 // content::WebContentsObserver | |
63 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; | |
64 virtual void RenderViewDeleted( | |
65 content::RenderViewHost* render_view_host) OVERRIDE; | |
66 virtual void DidStopLoading() OVERRIDE; | |
67 | |
68 // content::WebContentsDelegate | |
69 virtual void CloseContents(content::WebContents* contents) OVERRIDE; | |
70 virtual bool ShouldSuppressDialogs() OVERRIDE; | |
71 | |
72 // content::NotificationObserver | |
73 virtual void Observe(int type, | |
74 const content::NotificationSource& source, | |
75 const content::NotificationDetails& details) OVERRIDE; | |
76 | |
77 private: | |
78 // Closes this host (results in deletion). | |
79 void Close(); | |
80 | |
81 // ExtensionFunctionDispatcher::Delegate | |
82 virtual Browser* GetBrowser() OVERRIDE; | |
83 | |
84 // Message handlers. | |
85 void OnRequest(const ExtensionHostMsg_Request_Params& params); | |
86 | |
87 // The profile that this host is tied to. | |
88 Profile* profile_; | |
89 | |
90 // The host for our HTML content. | |
91 scoped_ptr<content::WebContents> host_contents_; | |
92 | |
93 // Helpers that take care of extra functionality for our host contents. | |
94 scoped_ptr<PrefsTabHelper> prefs_tab_helper_; | |
benwells
2012/04/19 09:03:55
I'm not sure yet what the PrefsTabHelper does. May
| |
95 | |
96 // A weak pointer to the current or pending RenderViewHost. We don't access | |
97 // this through the host_contents because we want to deal with the pending | |
98 // host, so we can send messages to it before it finishes loading. | |
99 content::RenderViewHost* render_view_host_; | |
100 | |
101 // Whether the RenderWidget has reported that it has stopped loading. | |
102 bool did_stop_loading_; | |
103 | |
104 // The original URL of the page being hosted. | |
105 GURL initial_url_; | |
benwells
2012/04/19 09:03:55
This doesn't need to be stored here.
| |
106 | |
107 content::NotificationRegistrar registrar_; | |
108 | |
109 ExtensionFunctionDispatcher extension_function_dispatcher_; | |
110 | |
111 // The relevant WebContents associated with this PlatformAppHost, if any. | |
112 content::WebContents* associated_web_contents_; | |
113 | |
114 // A SiteInstance for grouping render processes for this app together. | |
115 scoped_refptr<content::SiteInstance> site_instance_; | |
116 | |
117 // Used to measure how long it's been since the host was created. | |
118 PerfTimer since_created_; | |
119 | |
120 DISALLOW_COPY_AND_ASSIGN(PlatformAppHost); | |
121 }; | |
122 | |
123 #endif // CHROME_BROWSER_EXTENSIONS_PLATFORM_APP_HOST_H_ | |
OLD | NEW |