OLD | NEW |
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 #include "content/browser/browser_plugin/browser_plugin_guest.h" | 5 #include "content/browser/browser_plugin/browser_plugin_guest.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 | 10 |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
140 // |guest_proxy_routing_id_| and perform any necessary cleanup on Detach | 140 // |guest_proxy_routing_id_| and perform any necessary cleanup on Detach |
141 // to enable this. | 141 // to enable this. |
142 // | 142 // |
143 // TODO(ekaramad): If the guest is embedded inside a cross-process <iframe> | 143 // TODO(ekaramad): If the guest is embedded inside a cross-process <iframe> |
144 // (e.g., <embed>-ed PDF), the reverse proxy will not be created and the | 144 // (e.g., <embed>-ed PDF), the reverse proxy will not be created and the |
145 // posted message's source attribute will be null which in turn breaks the | 145 // posted message's source attribute will be null which in turn breaks the |
146 // two-way messaging between the guest and the embedder. We should either | 146 // two-way messaging between the guest and the embedder. We should either |
147 // create a RenderFrameProxyHost for the reverse path, or implement | 147 // create a RenderFrameProxyHost for the reverse path, or implement |
148 // MimeHandlerViewGuest using OOPIF (https://crbug.com/659750). | 148 // MimeHandlerViewGuest using OOPIF (https://crbug.com/659750). |
149 SiteInstance* owner_site_instance = delegate_->GetOwnerSiteInstance(); | 149 SiteInstance* owner_site_instance = delegate_->GetOwnerSiteInstance(); |
| 150 if (!owner_site_instance) |
| 151 return MSG_ROUTING_NONE; |
150 int proxy_routing_id = GetWebContents() | 152 int proxy_routing_id = GetWebContents() |
151 ->GetFrameTree() | 153 ->GetFrameTree() |
152 ->root() | 154 ->root() |
153 ->render_manager() | 155 ->render_manager() |
154 ->CreateRenderFrameProxy(owner_site_instance); | 156 ->CreateRenderFrameProxy(owner_site_instance); |
155 guest_proxy_routing_id_ = RenderFrameProxyHost::FromID( | 157 guest_proxy_routing_id_ = RenderFrameProxyHost::FromID( |
156 owner_site_instance->GetProcess()->GetID(), proxy_routing_id) | 158 owner_site_instance->GetProcess()->GetID(), proxy_routing_id) |
157 ->GetRenderViewHost()->GetRoutingID(); | 159 ->GetRenderViewHost()->GetRoutingID(); |
158 | 160 |
159 return guest_proxy_routing_id_; | 161 return guest_proxy_routing_id_; |
(...skipping 11 matching lines...) Expand all Loading... |
171 last_seen_view_size_ = new_size; | 173 last_seen_view_size_ = new_size; |
172 } | 174 } |
173 } | 175 } |
174 | 176 |
175 void BrowserPluginGuest::SizeContents(const gfx::Size& new_size) { | 177 void BrowserPluginGuest::SizeContents(const gfx::Size& new_size) { |
176 GetWebContents()->GetView()->SizeContents(new_size); | 178 GetWebContents()->GetView()->SizeContents(new_size); |
177 } | 179 } |
178 | 180 |
179 void BrowserPluginGuest::WillDestroy() { | 181 void BrowserPluginGuest::WillDestroy() { |
180 is_in_destruction_ = true; | 182 is_in_destruction_ = true; |
| 183 |
| 184 // It is important that the WebContents is notified before detaching. |
| 185 GetWebContents()->BrowserPluginGuestWillDetach(); |
| 186 |
| 187 attached_ = false; |
181 owner_web_contents_ = nullptr; | 188 owner_web_contents_ = nullptr; |
182 attached_ = false; | |
183 } | 189 } |
184 | 190 |
185 RenderWidgetHostImpl* BrowserPluginGuest::GetOwnerRenderWidgetHost() const { | 191 RenderWidgetHostImpl* BrowserPluginGuest::GetOwnerRenderWidgetHost() const { |
186 return static_cast<RenderWidgetHostImpl*>( | 192 return static_cast<RenderWidgetHostImpl*>( |
187 delegate_->GetOwnerRenderWidgetHost()); | 193 delegate_->GetOwnerRenderWidgetHost()); |
188 } | 194 } |
189 | 195 |
190 void BrowserPluginGuest::Init() { | 196 void BrowserPluginGuest::Init() { |
191 if (initialized_) | 197 if (initialized_) |
192 return; | 198 return; |
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
423 GetSurfaceManager()->SatisfySequence(sequence); | 429 GetSurfaceManager()->SatisfySequence(sequence); |
424 } | 430 } |
425 | 431 |
426 void BrowserPluginGuest::OnRequireSequence( | 432 void BrowserPluginGuest::OnRequireSequence( |
427 int instance_id, | 433 int instance_id, |
428 const cc::SurfaceId& id, | 434 const cc::SurfaceId& id, |
429 const cc::SurfaceSequence& sequence) { | 435 const cc::SurfaceSequence& sequence) { |
430 GetSurfaceManager()->RequireSequence(id, sequence); | 436 GetSurfaceManager()->RequireSequence(id, sequence); |
431 } | 437 } |
432 | 438 |
433 bool BrowserPluginGuest::HandleFindForEmbedder( | |
434 int request_id, | |
435 const base::string16& search_text, | |
436 const blink::WebFindOptions& options) { | |
437 return delegate_->HandleFindForEmbedder(request_id, search_text, options); | |
438 } | |
439 | |
440 bool BrowserPluginGuest::HandleStopFindingForEmbedder(StopFindAction action) { | |
441 return delegate_->HandleStopFindingForEmbedder(action); | |
442 } | |
443 | |
444 void BrowserPluginGuest::ResendEventToEmbedder( | 439 void BrowserPluginGuest::ResendEventToEmbedder( |
445 const blink::WebInputEvent& event) { | 440 const blink::WebInputEvent& event) { |
446 if (!attached() || !owner_web_contents_) | 441 if (!attached() || !owner_web_contents_) |
447 return; | 442 return; |
448 | 443 |
449 DCHECK(browser_plugin_instance_id_); | 444 DCHECK(browser_plugin_instance_id_); |
450 RenderWidgetHostViewBase* view = | 445 RenderWidgetHostViewBase* view = |
451 static_cast<RenderWidgetHostViewBase*>(GetOwnerRenderWidgetHostView()); | 446 static_cast<RenderWidgetHostViewBase*>(GetOwnerRenderWidgetHostView()); |
452 | 447 |
453 gfx::Vector2d offset_from_embedder = guest_window_rect_.OffsetFromOrigin(); | 448 gfx::Vector2d offset_from_embedder = guest_window_rect_.OffsetFromOrigin(); |
(...skipping 362 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
816 rwhv->RegisterFrameSinkId(); | 811 rwhv->RegisterFrameSinkId(); |
817 has_render_view_ = true; | 812 has_render_view_ = true; |
818 | 813 |
819 RecordAction(base::UserMetricsAction("BrowserPlugin.Guest.Attached")); | 814 RecordAction(base::UserMetricsAction("BrowserPlugin.Guest.Attached")); |
820 } | 815 } |
821 | 816 |
822 void BrowserPluginGuest::OnDetach(int browser_plugin_instance_id) { | 817 void BrowserPluginGuest::OnDetach(int browser_plugin_instance_id) { |
823 if (!attached()) | 818 if (!attached()) |
824 return; | 819 return; |
825 | 820 |
| 821 // It is important that the WebContents is notified before detaching. |
| 822 GetWebContents()->BrowserPluginGuestWillDetach(); |
| 823 |
826 // This tells BrowserPluginGuest to queue up all IPCs to BrowserPlugin until | 824 // This tells BrowserPluginGuest to queue up all IPCs to BrowserPlugin until |
827 // it's attached again. | 825 // it's attached again. |
828 attached_ = false; | 826 attached_ = false; |
829 | 827 |
830 RenderWidgetHostViewChildFrame* rwhv = | 828 RenderWidgetHostViewChildFrame* rwhv = |
831 static_cast<RenderWidgetHostViewChildFrame*>( | 829 static_cast<RenderWidgetHostViewChildFrame*>( |
832 web_contents()->GetRenderWidgetHostView()); | 830 web_contents()->GetRenderWidgetHostView()); |
833 // If the guest is terminated, our host may already be gone. | 831 // If the guest is terminated, our host may already be gone. |
834 if (rwhv) | 832 if (rwhv) |
835 rwhv->UnregisterFrameSinkId(); | 833 rwhv->UnregisterFrameSinkId(); |
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1060 range, character_bounds); | 1058 range, character_bounds); |
1061 } | 1059 } |
1062 #endif | 1060 #endif |
1063 | 1061 |
1064 void BrowserPluginGuest::SetContextMenuPosition(const gfx::Point& position) { | 1062 void BrowserPluginGuest::SetContextMenuPosition(const gfx::Point& position) { |
1065 if (delegate_) | 1063 if (delegate_) |
1066 delegate_->SetContextMenuPosition(position); | 1064 delegate_->SetContextMenuPosition(position); |
1067 } | 1065 } |
1068 | 1066 |
1069 } // namespace content | 1067 } // namespace content |
OLD | NEW |