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

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

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

Powered by Google App Engine
This is Rietveld 408576698