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

Unified Diff: content/browser/browser_plugin/browser_plugin_host.h

Issue 10377170: Browser Plugin: browser process side changes (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Updated according to creis@ Created 8 years, 7 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: content/browser/browser_plugin/browser_plugin_host.h
diff --git a/content/browser/browser_plugin/browser_plugin_host.h b/content/browser/browser_plugin/browser_plugin_host.h
new file mode 100644
index 0000000000000000000000000000000000000000..189535a71a57a36965e6f4342642a796dd1816fc
--- /dev/null
+++ b/content/browser/browser_plugin/browser_plugin_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 CONTENT_BROWSER_BROWSER_PLUGIN_BROWSER_PLUGIN_HOST_H__
+#define CONTENT_BROWSER_BROWSER_PLUGIN_BROWSER_PLUGIN_HOST_H__
+#pragma once
+
+#include <map>
+#include <set>
+
+#include "content/public/browser/notification_registrar.h"
+#include "content/public/browser/notification_observer.h"
+#include "content/public/browser/web_contents_delegate.h"
+#include "content/public/browser/web_contents_observer.h"
+#include "googleurl/src/gurl.h"
+#include "ppapi/c/pp_instance.h"
+#include "ui/gfx/size.h"
+
+class WebContentsImpl;
+
+namespace content {
+
+// The primary purpose of BrowserPluginHost is to allow an embedder
+// to manage the lifetime of its guests. It cleans up its guests
+// on navigation, crashes, and "hides" guests when it hides.
+// For the guest, BrowserPluginHost keeps track of its embedder,
+// its BrowserPlugin instance ID, and some initialization state
+// such as initial size and URL.
+class BrowserPluginHost: public WebContentsObserver,
+ public NotificationObserver,
+ public WebContentsDelegate {
+ public:
+ BrowserPluginHost(WebContentsImpl* web_contents);
Charlie Reis 2012/05/18 20:35:24 Please add a comment saying which web_contents thi
Fady Samuel 2012/05/21 14:30:17 Both. I added a comment to say that WebContentsImp
+
+ virtual ~BrowserPluginHost();
+
+ // Get a guest BrowserPluginHost by its container ID specified
+ // in BrowserPlugin.
+ BrowserPluginHost* GetGuestByContainerID(int container_id);
+
+ // Associate a guest with its container instance ID.
+ void RegisterContainerInstance(
+ int container_id,
+ BrowserPluginHost* observer);
+
+ // An embedder BrowserPluginHost keeps track of
+ // its guests so that if it navigates away, its associated RenderView
+ // crashes or it is hidden, it takes appropriate action on the guest.
+ void AddGuest(WebContentsImpl* guest, int64 frame_id);
+
+ // This removes a guest from an embedder's guest list.
+ // TODO(fsamuel): Use this when deleting guest after they crash.
+ // ToT plugin crash handling seems to be broken in this case and so I can't
+ // test this scenario at the moment. Delete this comment once fixed.
+ void RemoveGuest(WebContentsImpl* guest);
+
+ WebContentsImpl* embedder() const { return embedder_; }
+ void set_embedder(WebContentsImpl* embedder) { embedder_ = embedder; }
+ int instance_id() const { return instance_id_; }
+ void set_instance_id(int instance_id) { instance_id_ = instance_id; }
+ const GURL& url() const { return url_; }
+ void set_url(const GURL& url) { url_ = url; }
Charlie Reis 2012/05/18 20:35:24 Please remove url_, since this isn't used in the p
Fady Samuel 2012/05/21 14:30:17 Done.
Fady Samuel 2012/05/21 14:30:17 Done.
+ const gfx::Size& initial_size() const { return initial_size_; }
+ void set_initial_size(const gfx::Size& size) { initial_size_ = size; }
+ RenderViewHost* pending_render_view_host() const {
+ return pending_render_view_host_;
+ }
+
+ void OnCrossProcessNavigation(RenderViewHost* dest_rvh);
Charlie Reis 2012/05/18 20:35:24 Add TODO to remove, referencing OnMapInstance. Al
Fady Samuel 2012/05/21 14:30:17 Done.
+
+ void NavigateGuestFromEmbedder(RenderViewHost* render_view_host,
+ int container_instance_id,
+ long long frame_id,
+ const std::string& src,
+ const gfx::Size& size);
+
+ void OnMapInstance(int container_instance_id, PP_Instance instance);
+
+ // WebContentObserver implementation.
+ virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
+ virtual void DidCommitProvisionalLoadForFrame(
Charlie Reis 2012/05/18 20:35:24 Add TODO to remove, referencing OnMapInstance.
Fady Samuel 2012/05/21 14:30:17 Unrelated. We discussed this offline. This is used
+ int64 frame_id,
+ bool is_main_frame,
+ const GURL& url,
+ PageTransition transition_type,
+ RenderViewHost* render_view_host) OVERRIDE;
+ virtual void RenderViewDeleted(RenderViewHost* render_view_host) OVERRIDE;
+ virtual void RenderViewGone(base::TerminationStatus status) OVERRIDE;
+ virtual void WebContentsDestroyed(WebContents* web_contents) OVERRIDE;
+
+ private:
+ typedef std::map<WebContentsImpl*, int64> GuestMap;
+ typedef std::map<int, BrowserPluginHost*> ContainerInstanceMap;
+
+ void OnNavigateFromGuest(PP_Instance instance,
+ const std::string& src);
+
+ void OnConnectToChannel(const IPC::ChannelHandle& handle);
+
+ void DestroyGuests();
+
+ // NotificationObserver method override.
+ virtual void Observe(int type,
+ const NotificationSource& source,
+ const NotificationDetails& details) OVERRIDE;
+
+ // A scoped container for notification registries.
+ NotificationRegistrar registrar_;
+ WebContentsImpl* embedder_;
+ // An identifier that uniquely identifies a browser plugin container
+ // within an embedder.
+ int instance_id_;
+ GURL url_;
+ gfx::Size initial_size_;
+ GuestMap guests_;
+ ContainerInstanceMap guests_by_container_id_;
+ RenderViewHost* pending_render_view_host_;
Charlie Reis 2012/05/18 20:35:24 Add TODO to remove, referencing OnMapInstance. We
Fady Samuel 2012/05/21 14:30:17 Done.
+};
+
+} // namespace content
+
+#endif // CONTENT_BROWSER_BROWSER_PLUGIN_BROWSER_PLUGIN_HOST_H_

Powered by Google App Engine
This is Rietveld 408576698