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

Unified Diff: chrome/browser/extensions/platform_app_host.h

Issue 10119003: Pull shell window stuff out of ExtensionHost and put in ShellWindow (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 8 years, 8 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 side-by-side diff with in-line comments
Download patch
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..4302c2a6b05a4ab525b6cc89162f4ac07ab5b8cb
--- /dev/null
+++ b/chrome/browser/extensions/platform_app_host.h
@@ -0,0 +1,136 @@
+// 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/base_extension_host.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 BaseExtensionHost,
+ public content::WebContentsDelegate,
+ public content::WebContentsObserver,
+ public ExtensionFunctionDispatcher::Delegate,
+ public content::NotificationObserver {
+ public:
+ PlatformAppHost(Profile* profile,
+ const Extension* extension,
+ const GURL& url);
+
+ virtual ~PlatformAppHost();
+
+ const Extension* extension() const { return extension_; }
+ const std::string& extension_id() const { return extension_id_; }
+ virtual content::WebContents* host_contents() const OVERRIDE;
+ virtual content::RenderViewHost* render_view_host() const OVERRIDE;
+ virtual content::RenderProcessHost* render_process_host() const OVERRIDE;
+
+ Profile* profile() const { return profile_; }
+
+ virtual content::ViewType extension_host_type() const OVERRIDE;
+
+ // 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 RenderViewCreated(
+ content::RenderViewHost* render_view_host) 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 extension that we're hosting in this view.
+ const Extension* extension_;
Aaron Boodman 2012/04/18 21:33:22 Seems that you do not need to store extension_ or
+
+ // Id of extension that we're hosting in this view.
+ const std::string extension_id_;
+
+ // 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_;
+
+ // 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_;
+
+ 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_

Powered by Google App Engine
This is Rietveld 408576698