Chromium Code Reviews| Index: chrome/browser/extensions/platform_app_host.h |
| diff --git a/chrome/browser/extensions/platform_app_host.h b/chrome/browser/extensions/platform_app_host.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..dcb82c4908f43e792eeffae24242d0ef540ad057 |
| --- /dev/null |
| +++ b/chrome/browser/extensions/platform_app_host.h |
| @@ -0,0 +1,123 @@ |
| +// Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef CHROME_BROWSER_EXTENSIONS_PLATFORM_APP_HOST_H_ |
| +#define CHROME_BROWSER_EXTENSIONS_PLATFORM_APP_HOST_H_ |
| +#pragma once |
| + |
| +#include <string> |
| +#include <vector> |
| + |
| +// TODO(benwells): review includes and forward decls |
| +#include "base/logging.h" |
| +#include "base/memory/scoped_ptr.h" |
| +#include "base/perftimer.h" |
| +#include "chrome/browser/extensions/extension_function_dispatcher.h" |
| +#include "content/public/browser/notification_observer.h" |
| +#include "content/public/browser/notification_registrar.h" |
| +#include "content/public/browser/web_contents_delegate.h" |
| +#include "content/public/browser/web_contents_observer.h" |
| +#include "content/public/common/view_type.h" |
| + |
| +class Browser; |
| +class Extension; |
| +class PrefsTabHelper; |
| + |
| +namespace content { |
| +class RenderProcessHost; |
| +class RenderWidgetHostView; |
| +class SiteInstance; |
| +} |
| + |
| +// This class is the browser component of a platform app's RenderView. |
| +// It handles setting up the renderer process, if needed. |
| +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
|
| + public content::WebContentsObserver, |
| + public ExtensionFunctionDispatcher::Delegate, |
| + public content::NotificationObserver { |
| + public: |
| + PlatformAppHost(Profile* profile, |
| + const GURL& url); |
| + |
| + virtual ~PlatformAppHost(); |
| + |
| + content::WebContents* host_contents() const { return host_contents_.get(); } |
| + content::RenderViewHost* render_view_host() const { |
| + return render_view_host_; |
| + } |
| + content::RenderProcessHost* render_process_host() const; |
| + |
| + Profile* profile() const { return profile_; } |
|
benwells
2012/04/19 09:03:55
Profile can probably go too.
|
| + |
| + // ExtensionFunctionDispatcher::Delegate |
| + virtual content::WebContents* GetAssociatedWebContents() const OVERRIDE; |
| + void SetAssociatedWebContents(content::WebContents* web_contents); |
| + |
| + // Prepares to initializes our RenderViewHost by creating its RenderView and |
| + // navigating to this host's url. Uses host_view for the RenderViewHost's view |
| + // (can be NULL). This happens immediately, unlike ExtensionHost. |
| + virtual void CreateRenderViewSoon() OVERRIDE; |
| + |
| + // content::WebContentsObserver |
| + virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; |
| + virtual void RenderViewDeleted( |
| + content::RenderViewHost* render_view_host) OVERRIDE; |
| + virtual void DidStopLoading() OVERRIDE; |
| + |
| + // content::WebContentsDelegate |
| + virtual void CloseContents(content::WebContents* contents) OVERRIDE; |
| + virtual bool ShouldSuppressDialogs() OVERRIDE; |
| + |
| + // content::NotificationObserver |
| + virtual void Observe(int type, |
| + const content::NotificationSource& source, |
| + const content::NotificationDetails& details) OVERRIDE; |
| + |
| + private: |
| + // Closes this host (results in deletion). |
| + void Close(); |
| + |
| + // ExtensionFunctionDispatcher::Delegate |
| + virtual Browser* GetBrowser() OVERRIDE; |
| + |
| + // Message handlers. |
| + void OnRequest(const ExtensionHostMsg_Request_Params& params); |
| + |
| + // The profile that this host is tied to. |
| + Profile* profile_; |
| + |
| + // The host for our HTML content. |
| + scoped_ptr<content::WebContents> host_contents_; |
| + |
| + // Helpers that take care of extra functionality for our host contents. |
| + scoped_ptr<PrefsTabHelper> prefs_tab_helper_; |
|
benwells
2012/04/19 09:03:55
I'm not sure yet what the PrefsTabHelper does. May
|
| + |
| + // A weak pointer to the current or pending RenderViewHost. We don't access |
| + // this through the host_contents because we want to deal with the pending |
| + // host, so we can send messages to it before it finishes loading. |
| + content::RenderViewHost* render_view_host_; |
| + |
| + // Whether the RenderWidget has reported that it has stopped loading. |
| + bool did_stop_loading_; |
| + |
| + // The original URL of the page being hosted. |
| + GURL initial_url_; |
|
benwells
2012/04/19 09:03:55
This doesn't need to be stored here.
|
| + |
| + content::NotificationRegistrar registrar_; |
| + |
| + ExtensionFunctionDispatcher extension_function_dispatcher_; |
| + |
| + // The relevant WebContents associated with this PlatformAppHost, if any. |
| + content::WebContents* associated_web_contents_; |
| + |
| + // A SiteInstance for grouping render processes for this app together. |
| + scoped_refptr<content::SiteInstance> site_instance_; |
| + |
| + // Used to measure how long it's been since the host was created. |
| + PerfTimer since_created_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(PlatformAppHost); |
| +}; |
| + |
| +#endif // CHROME_BROWSER_EXTENSIONS_PLATFORM_APP_HOST_H_ |