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

Side by Side Diff: content/browser/browser_plugin/browser_plugin_host.h

Issue 10555029: Browser Plugin: Move to old directories (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 6 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | content/browser/browser_plugin/browser_plugin_host.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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 CONTENT_BROWSER_BROWSER_PLUGIN_BROWSER_PLUGIN_HOST_H__
6 #define CONTENT_BROWSER_BROWSER_PLUGIN_BROWSER_PLUGIN_HOST_H__
7 #pragma once
8
9 #include <map>
10
11 #include "content/public/browser/notification_observer.h"
12 #include "content/public/browser/notification_registrar.h"
13 #include "content/public/browser/web_contents_delegate.h"
14 #include "content/public/browser/web_contents_observer.h"
15 #include "ppapi/c/pp_instance.h"
16 #include "ui/gfx/size.h"
17
18 class WebContentsImpl;
19
20 namespace content {
21
22 class RenderProcessHost;
23
24 // A BrowserPluginHost object is used by both embedders and guests.
25 // The primary purpose of BrowserPluginHost is to allow an embedder
26 // to manage the lifetime of its guests. It cleans up its guests
27 // on navigation, crashes, and "hides" guests when it hides.
28 // For the guest, BrowserPluginHost keeps track of its embedder,
29 // and its BrowserPlugin instance ID.
30 class BrowserPluginHost : public WebContentsObserver,
31 public NotificationObserver,
32 public WebContentsDelegate {
33 public:
34 // BrowserPluginHost is owned by a WebContentsImpl. Here it takes in its
35 // owner. The owner can be either a guest or embedder WebContents.
36 explicit BrowserPluginHost(WebContentsImpl* web_contents);
37
38 virtual ~BrowserPluginHost();
39
40 void ConnectEmbedderToChannel(RenderViewHost* render_view_host,
41 const IPC::ChannelHandle& handle);
42
43 // This is called on the first navigation of the browser plugin. It creates
44 // a new WebContentsImpl for the guest, associates it with its embedder, sets
45 // its size and navigates it to the src URL.
46 void NavigateGuestFromEmbedder(RenderViewHost* render_view_host,
47 int container_instance_id,
48 long long frame_id,
49 const std::string& src);
50
51 RenderProcessHost* embedder_render_process_host() const {
52 return embedder_render_process_host_;
53 }
54 int instance_id() const { return instance_id_; }
55
56 private:
57 typedef std::map<WebContentsImpl*, int64> GuestMap;
58 typedef std::map<int, BrowserPluginHost*> ContainerInstanceMap;
59
60 // Get a guest BrowserPluginHost by its container ID specified
61 // in BrowserPlugin.
62 BrowserPluginHost* GetGuestByContainerID(int container_id);
63
64 // Associate a guest with its container instance ID.
65 void RegisterContainerInstance(
66 int container_id,
67 BrowserPluginHost* observer);
68
69 // An embedder BrowserPluginHost keeps track of
70 // its guests so that if it navigates away, its associated RenderView
71 // crashes or it is hidden, it takes appropriate action on the guest.
72 void AddGuest(WebContentsImpl* guest, int64 frame_id);
73
74 // This removes a guest from an embedder's guest list.
75 // TODO(fsamuel): Use this when deleting guest after they crash.
76 // ToT plugin crash handling seems to be broken in this case and so I can't
77 // test this scenario at the moment. Delete this comment once fixed.
78 void RemoveGuest(WebContentsImpl* guest);
79
80 void set_embedder_render_process_host(
81 RenderProcessHost* embedder_render_process_host) {
82 embedder_render_process_host_ = embedder_render_process_host;
83 }
84 void set_instance_id(int instance_id) { instance_id_ = instance_id; }
85
86 void OnNavigateFromGuest(PP_Instance instance,
87 const std::string& src);
88
89 void DestroyGuests();
90
91 // WebContentsDelegate implementation.
92 virtual bool TakeFocus(bool reverse) OVERRIDE;
93
94 // WebContentObserver implementation.
95 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
96 // Used to monitor frame navigation to cleanup guests when a frame navigates
97 // away from the browser plugin it's hosting.
98 virtual void DidCommitProvisionalLoadForFrame(
99 int64 frame_id,
100 bool is_main_frame,
101 const GURL& url,
102 PageTransition transition_type,
103 RenderViewHost* render_view_host) OVERRIDE;
104 virtual void RenderViewDeleted(RenderViewHost* render_view_host) OVERRIDE;
105 virtual void RenderViewGone(base::TerminationStatus status) OVERRIDE;
106 virtual void WebContentsDestroyed(WebContents* web_contents) OVERRIDE;
107
108 // NotificationObserver method override.
109 virtual void Observe(int type,
110 const NotificationSource& source,
111 const NotificationDetails& details) OVERRIDE;
112
113 // A scoped container for notification registries.
114 NotificationRegistrar registrar_;
115 RenderProcessHost* embedder_render_process_host_;
116 std::string embedder_channel_name_;
117 // An identifier that uniquely identifies a browser plugin container
118 // within an embedder.
119 int instance_id_;
120 gfx::Size initial_size_;
121 GuestMap guests_;
122 ContainerInstanceMap guests_by_container_id_;
123
124 DISALLOW_COPY_AND_ASSIGN(BrowserPluginHost);
125 };
126
127 } // namespace content
128
129 #endif // CONTENT_BROWSER_BROWSER_PLUGIN_BROWSER_PLUGIN_HOST_H_
OLDNEW
« no previous file with comments | « no previous file | content/browser/browser_plugin/browser_plugin_host.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698