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

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

Issue 10412056: Browser Plugin: Remove MapInstance from BrowserPluginHost + More cross-process navigation work (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Removed commented out code 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CONTENT_BROWSER_BROWSER_PLUGIN_BROWSER_PLUGIN_HOST_H__ 5 #ifndef CONTENT_BROWSER_BROWSER_PLUGIN_BROWSER_PLUGIN_HOST_H__
6 #define CONTENT_BROWSER_BROWSER_PLUGIN_BROWSER_PLUGIN_HOST_H__ 6 #define CONTENT_BROWSER_BROWSER_PLUGIN_BROWSER_PLUGIN_HOST_H__
7 #pragma once 7 #pragma once
8 8
9 #include <map> 9 #include <map>
10 10
(...skipping 20 matching lines...) Expand all
31 class BrowserPluginHost : public WebContentsObserver, 31 class BrowserPluginHost : public WebContentsObserver,
32 public NotificationObserver, 32 public NotificationObserver,
33 public WebContentsDelegate { 33 public WebContentsDelegate {
34 public: 34 public:
35 // BrowserPluginHost is owned by a WebContentsImpl. Here it takes in its 35 // BrowserPluginHost is owned by a WebContentsImpl. Here it takes in its
36 // owner. The owner can be either a guest or embedder WebContents. 36 // owner. The owner can be either a guest or embedder WebContents.
37 explicit BrowserPluginHost(WebContentsImpl* web_contents); 37 explicit BrowserPluginHost(WebContentsImpl* web_contents);
38 38
39 virtual ~BrowserPluginHost(); 39 virtual ~BrowserPluginHost();
40 40
41 // TODO(fsamuel): Remove this once BrowserPluginHost_MapInstance
42 // is removed.
43 void OnPendingNavigation(RenderViewHost* dest_rvh);
44
45 void ConnectEmbedderToChannel(RenderViewHost* render_view_host, 41 void ConnectEmbedderToChannel(RenderViewHost* render_view_host,
46 const IPC::ChannelHandle& handle); 42 const IPC::ChannelHandle& handle);
47 43
48 // This is called on the first navigation of the browser plugin. It creates 44 // This is called on the first navigation of the browser plugin. It creates
49 // a new WebContentsImpl for the guest, associates it with its embedder, sets 45 // a new WebContentsImpl for the guest, associates it with its embedder, sets
50 // its size and navigates it to the src URL. 46 // its size and navigates it to the src URL.
51 void NavigateGuestFromEmbedder(RenderViewHost* render_view_host, 47 void NavigateGuestFromEmbedder(RenderViewHost* render_view_host,
52 int container_instance_id, 48 int container_instance_id,
53 long long frame_id, 49 long long frame_id,
54 const std::string& src, 50 const std::string& src,
55 const gfx::Size& size); 51 const gfx::Size& size);
56 52
57 RenderProcessHost* embedder_render_process_host() const { 53 RenderProcessHost* embedder_render_process_host() const {
58 return embedder_render_process_host_; 54 return embedder_render_process_host_;
59 } 55 }
56 int instance_id() const { return instance_id_; }
60 57
61 private: 58 private:
62 typedef std::map<WebContentsImpl*, int64> GuestMap; 59 typedef std::map<WebContentsImpl*, int64> GuestMap;
63 typedef std::map<int, BrowserPluginHost*> ContainerInstanceMap; 60 typedef std::map<int, BrowserPluginHost*> ContainerInstanceMap;
64 61
65 // Get a guest BrowserPluginHost by its container ID specified 62 // Get a guest BrowserPluginHost by its container ID specified
66 // in BrowserPlugin. 63 // in BrowserPlugin.
67 BrowserPluginHost* GetGuestByContainerID(int container_id); 64 BrowserPluginHost* GetGuestByContainerID(int container_id);
68 65
69 // Associate a guest with its container instance ID. 66 // Associate a guest with its container instance ID.
70 void RegisterContainerInstance( 67 void RegisterContainerInstance(
71 int container_id, 68 int container_id,
72 BrowserPluginHost* observer); 69 BrowserPluginHost* observer);
73 70
74 // An embedder BrowserPluginHost keeps track of 71 // An embedder BrowserPluginHost keeps track of
75 // its guests so that if it navigates away, its associated RenderView 72 // its guests so that if it navigates away, its associated RenderView
76 // crashes or it is hidden, it takes appropriate action on the guest. 73 // crashes or it is hidden, it takes appropriate action on the guest.
77 void AddGuest(WebContentsImpl* guest, int64 frame_id); 74 void AddGuest(WebContentsImpl* guest, int64 frame_id);
78 75
79 // This removes a guest from an embedder's guest list. 76 // This removes a guest from an embedder's guest list.
80 // TODO(fsamuel): Use this when deleting guest after they crash. 77 // TODO(fsamuel): Use this when deleting guest after they crash.
81 // ToT plugin crash handling seems to be broken in this case and so I can't 78 // ToT plugin crash handling seems to be broken in this case and so I can't
82 // test this scenario at the moment. Delete this comment once fixed. 79 // test this scenario at the moment. Delete this comment once fixed.
83 void RemoveGuest(WebContentsImpl* guest); 80 void RemoveGuest(WebContentsImpl* guest);
84 81
85 void set_embedder_render_process_host( 82 void set_embedder_render_process_host(
86 RenderProcessHost* embedder_render_process_host) { 83 RenderProcessHost* embedder_render_process_host) {
87 embedder_render_process_host_ = embedder_render_process_host; 84 embedder_render_process_host_ = embedder_render_process_host;
88 } 85 }
89 int instance_id() const { return instance_id_; }
90 void set_instance_id(int instance_id) { instance_id_ = instance_id; } 86 void set_instance_id(int instance_id) { instance_id_ = instance_id; }
91 const gfx::Size& initial_size() const { return initial_size_; } 87 const gfx::Size& initial_size() const { return initial_size_; }
92 void set_initial_size(const gfx::Size& size) { initial_size_ = size; } 88 void set_initial_size(const gfx::Size& size) { initial_size_ = size; }
93 RenderViewHost* pending_render_view_host() const {
94 return pending_render_view_host_;
95 }
96 89
97 void OnNavigateFromGuest(PP_Instance instance, 90 void OnNavigateFromGuest(PP_Instance instance,
98 const std::string& src); 91 const std::string& src);
99 92
100 void DestroyGuests(); 93 void DestroyGuests();
101 94
102 // TODO(fsamuel): Replace BrowserPluginHost_MapInstance with a message
103 // over the GuestToEmbedderChannel that tells the guest to size itself
104 // and begin compositing. Currently we use the guest's routing ID to look
105 // up the appropriate guest in
106 // BrowserPluginChannelManager::OnCompleteNavigation. In order to bypass the
107 // need to grab a routing ID from the browser process, we can instead pass the
108 // container instance ID to the guest on ViewMsg_New. The container instance
109 // ID and the embedder channel name can then be used together to uniquely
110 // identify a guest RenderViewImpl within a render process.
111 void OnMapInstance(int container_instance_id, PP_Instance instance);
112
113 // WebContentObserver implementation. 95 // WebContentObserver implementation.
114 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; 96 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
115 // Used to monitor frame navigation to cleanup guests when a frame navigates 97 // Used to monitor frame navigation to cleanup guests when a frame navigates
116 // away from the browser plugin it's hosting. 98 // away from the browser plugin it's hosting.
117 virtual void DidCommitProvisionalLoadForFrame( 99 virtual void DidCommitProvisionalLoadForFrame(
118 int64 frame_id, 100 int64 frame_id,
119 bool is_main_frame, 101 bool is_main_frame,
120 const GURL& url, 102 const GURL& url,
121 PageTransition transition_type, 103 PageTransition transition_type,
122 RenderViewHost* render_view_host) OVERRIDE; 104 RenderViewHost* render_view_host) OVERRIDE;
123 virtual void RenderViewDeleted(RenderViewHost* render_view_host) OVERRIDE; 105 virtual void RenderViewDeleted(RenderViewHost* render_view_host) OVERRIDE;
124 virtual void RenderViewGone(base::TerminationStatus status) OVERRIDE; 106 virtual void RenderViewGone(base::TerminationStatus status) OVERRIDE;
125 virtual void WebContentsDestroyed(WebContents* web_contents) OVERRIDE; 107 virtual void WebContentsDestroyed(WebContents* web_contents) OVERRIDE;
126 108
127 // NotificationObserver method override. 109 // NotificationObserver method override.
128 virtual void Observe(int type, 110 virtual void Observe(int type,
129 const NotificationSource& source, 111 const NotificationSource& source,
130 const NotificationDetails& details) OVERRIDE; 112 const NotificationDetails& details) OVERRIDE;
131 113
132 // A scoped container for notification registries. 114 // A scoped container for notification registries.
133 NotificationRegistrar registrar_; 115 NotificationRegistrar registrar_;
134 RenderProcessHost* embedder_render_process_host_; 116 RenderProcessHost* embedder_render_process_host_;
135 // An identifier that uniquely identifies a browser plugin container 117 // An identifier that uniquely identifies a browser plugin container
136 // within an embedder. 118 // within an embedder.
137 int instance_id_; 119 int instance_id_;
138 gfx::Size initial_size_; 120 gfx::Size initial_size_;
139 GuestMap guests_; 121 GuestMap guests_;
140 ContainerInstanceMap guests_by_container_id_; 122 ContainerInstanceMap guests_by_container_id_;
141 // TODO(fsamuel): This should not be exposed outside of WebContentsImpl
142 // because this can change at any time. Remove this, along with
143 // OnPendingNavigation once BrowserPluginHost_MapInstance is modified
144 // to be sent over the GuestToEmbedderChannel directly instead of through
145 // the browser process.
146 RenderViewHost* pending_render_view_host_;
147 }; 123 };
148 124
149 } // namespace content 125 } // namespace content
150 126
151 #endif // CONTENT_BROWSER_BROWSER_PLUGIN_BROWSER_PLUGIN_HOST_H_ 127 #endif // CONTENT_BROWSER_BROWSER_PLUGIN_BROWSER_PLUGIN_HOST_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698