Chromium Code Reviews| 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 <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
| 10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
| (...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 167 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_SetVisibility, OnSetVisibility) | 167 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_SetVisibility, OnSetVisibility) |
| 168 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_UnlockMouse_ACK, OnUnlockMouseAck) | 168 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_UnlockMouse_ACK, OnUnlockMouseAck) |
| 169 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_UpdateGeometry, OnUpdateGeometry) | 169 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_UpdateGeometry, OnUpdateGeometry) |
| 170 IPC_MESSAGE_UNHANDLED(handled = false) | 170 IPC_MESSAGE_UNHANDLED(handled = false) |
| 171 IPC_END_MESSAGE_MAP() | 171 IPC_END_MESSAGE_MAP() |
| 172 return handled; | 172 return handled; |
| 173 } | 173 } |
| 174 | 174 |
| 175 void BrowserPluginGuest::Initialize( | 175 void BrowserPluginGuest::Initialize( |
| 176 const BrowserPluginHostMsg_Attach_Params& params, | 176 const BrowserPluginHostMsg_Attach_Params& params, |
| 177 WebContentsImpl* embedder_web_contents) { | 177 WebContentsImpl* embedder_web_contents, |
| 178 const base::DictionaryValue& extra_params) { | |
| 179 printf("BPG::Initialize()\n"); | |
| 178 focused_ = params.focused; | 180 focused_ = params.focused; |
| 179 guest_visible_ = params.visible; | 181 guest_visible_ = params.visible; |
| 180 guest_opaque_ = params.opaque; | 182 guest_opaque_ = params.opaque; |
| 181 guest_window_rect_ = params.resize_guest_params.view_rect; | 183 guest_window_rect_ = params.resize_guest_params.view_rect; |
| 182 | 184 |
| 183 auto_size_enabled_ = params.auto_size_params.enable; | 185 auto_size_enabled_ = params.auto_size_params.enable; |
| 184 max_auto_size_ = params.auto_size_params.max_size; | 186 max_auto_size_ = params.auto_size_params.max_size; |
| 185 min_auto_size_ = params.auto_size_params.min_size; | 187 min_auto_size_ = params.auto_size_params.min_size; |
| 186 | 188 |
| 187 // Once a BrowserPluginGuest has an embedder WebContents, it's considered to | 189 // Once a BrowserPluginGuest has an embedder WebContents, it's considered to |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 220 | 222 |
| 221 // Create a swapped out RenderView for the guest in the embedder render | 223 // Create a swapped out RenderView for the guest in the embedder render |
| 222 // process, so that the embedder can access the guest's window object. | 224 // process, so that the embedder can access the guest's window object. |
| 223 int guest_routing_id = | 225 int guest_routing_id = |
| 224 GetWebContents()->CreateSwappedOutRenderView( | 226 GetWebContents()->CreateSwappedOutRenderView( |
| 225 embedder_web_contents_->GetSiteInstance()); | 227 embedder_web_contents_->GetSiteInstance()); |
| 226 SendMessageToEmbedder( | 228 SendMessageToEmbedder( |
| 227 new BrowserPluginMsg_GuestContentWindowReady(instance_id_, | 229 new BrowserPluginMsg_GuestContentWindowReady(instance_id_, |
| 228 guest_routing_id)); | 230 guest_routing_id)); |
| 229 | 231 |
| 230 if (!params.src.empty()) { | |
| 231 // params.src will be validated in BrowserPluginGuest::OnNavigateGuest. | |
| 232 OnNavigateGuest(instance_id_, params.src); | |
|
Fady Samuel
2014/05/29 20:35:23
We probably get rid of the IPC message and the met
lazyboy
2014/05/30 05:48:21
Done.
| |
| 233 has_render_view_ = true; | |
| 234 } | |
| 235 | |
| 236 WebPreferences prefs = GetWebContents()->GetWebkitPrefs(); | 232 WebPreferences prefs = GetWebContents()->GetWebkitPrefs(); |
| 237 prefs.navigate_on_drag_drop = false; | 233 prefs.navigate_on_drag_drop = false; |
| 238 GetWebContents()->GetRenderViewHost()->UpdateWebkitPreferences(prefs); | 234 GetWebContents()->GetRenderViewHost()->UpdateWebkitPreferences(prefs); |
| 239 | 235 |
| 240 // Enable input method for guest if it's enabled for the embedder. | 236 // Enable input method for guest if it's enabled for the embedder. |
| 241 if (static_cast<RenderViewHostImpl*>( | 237 if (static_cast<RenderViewHostImpl*>( |
| 242 embedder_web_contents_->GetRenderViewHost())->input_method_active()) { | 238 embedder_web_contents_->GetRenderViewHost())->input_method_active()) { |
| 243 RenderViewHostImpl* guest_rvh = static_cast<RenderViewHostImpl*>( | 239 RenderViewHostImpl* guest_rvh = static_cast<RenderViewHostImpl*>( |
| 244 GetWebContents()->GetRenderViewHost()); | 240 GetWebContents()->GetRenderViewHost()); |
| 245 guest_rvh->SetInputMethodActive(true); | 241 guest_rvh->SetInputMethodActive(true); |
| 246 } | 242 } |
| 247 | 243 |
| 248 // Inform the embedder of the guest's information. | 244 // Inform the embedder of the guest's information. |
|
Fady Samuel
2014/05/29 20:35:23
We can get rid of the parameters on Attach_ACK.
lazyboy
2014/05/30 05:48:21
Done.
| |
| 249 // We pull the partition information from the site's URL, which is of the form | 245 // We pull the partition information from the site's URL, which is of the form |
| 250 // guest://site/{persist}?{partition_name}. | 246 // guest://site/{persist}?{partition_name}. |
| 251 const GURL& site_url = GetWebContents()->GetSiteInstance()->GetSiteURL(); | 247 const GURL& site_url = GetWebContents()->GetSiteInstance()->GetSiteURL(); |
| 252 BrowserPluginMsg_Attach_ACK_Params ack_params; | 248 BrowserPluginMsg_Attach_ACK_Params ack_params; |
| 253 ack_params.storage_partition_id = site_url.query(); | 249 ack_params.storage_partition_id = site_url.query(); |
| 254 ack_params.persist_storage = | 250 ack_params.persist_storage = |
| 255 site_url.path().find("persist") != std::string::npos; | 251 site_url.path().find("persist") != std::string::npos; |
| 256 SendMessageToEmbedder( | 252 SendMessageToEmbedder( |
| 257 new BrowserPluginMsg_Attach_ACK(instance_id_, ack_params)); | 253 new BrowserPluginMsg_Attach_ACK(instance_id_, ack_params)); |
| 258 | 254 |
| 259 if (delegate_) | 255 if (delegate_) { |
| 260 delegate_->DidAttach(); | 256 delegate_->DidAttach(extra_params); |
| 257 // TODO(lazyboy): Should not set this if src is empty. | |
|
Fady Samuel
2014/05/29 20:35:23
In theory it should always be the case that we've
lazyboy
2014/05/30 05:48:21
Removed TODO.
| |
| 258 has_render_view_ = true; | |
| 259 } | |
| 261 } | 260 } |
| 262 | 261 |
| 263 BrowserPluginGuest::~BrowserPluginGuest() { | 262 BrowserPluginGuest::~BrowserPluginGuest() { |
| 264 while (!pending_messages_.empty()) { | 263 while (!pending_messages_.empty()) { |
| 265 delete pending_messages_.front(); | 264 delete pending_messages_.front(); |
| 266 pending_messages_.pop(); | 265 pending_messages_.pop(); |
| 267 } | 266 } |
| 268 } | 267 } |
| 269 | 268 |
| 270 // static | 269 // static |
| (...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 541 #endif | 540 #endif |
| 542 IPC_MESSAGE_HANDLER(ViewHostMsg_UnlockMouse, OnUnlockMouse) | 541 IPC_MESSAGE_HANDLER(ViewHostMsg_UnlockMouse, OnUnlockMouse) |
| 543 IPC_MESSAGE_HANDLER(ViewHostMsg_UpdateRect, OnUpdateRect) | 542 IPC_MESSAGE_HANDLER(ViewHostMsg_UpdateRect, OnUpdateRect) |
| 544 IPC_MESSAGE_UNHANDLED(handled = false) | 543 IPC_MESSAGE_UNHANDLED(handled = false) |
| 545 IPC_END_MESSAGE_MAP() | 544 IPC_END_MESSAGE_MAP() |
| 546 return handled; | 545 return handled; |
| 547 } | 546 } |
| 548 | 547 |
| 549 void BrowserPluginGuest::Attach( | 548 void BrowserPluginGuest::Attach( |
| 550 WebContentsImpl* embedder_web_contents, | 549 WebContentsImpl* embedder_web_contents, |
| 551 BrowserPluginHostMsg_Attach_Params params, | 550 BrowserPluginHostMsg_Attach_Params params, |
|
Fady Samuel
2014/05/29 20:35:23
If we're not modifying the attach params now, this
lazyboy
2014/05/30 05:48:21
Done.
| |
| 552 const base::DictionaryValue& extra_params) { | 551 const base::DictionaryValue& extra_params) { |
| 553 if (attached()) | 552 if (attached()) |
| 554 return; | 553 return; |
| 555 | 554 |
| 556 // Clear parameters that get inherited from the opener. | |
| 557 params.storage_partition_id.clear(); | |
| 558 params.persist_storage = false; | |
| 559 params.src.clear(); | |
| 560 | |
| 561 // If a RenderView has already been created for this new window, then we need | 555 // If a RenderView has already been created for this new window, then we need |
| 562 // to initialize the browser-side state now so that the RenderFrameHostManager | 556 // to initialize the browser-side state now so that the RenderFrameHostManager |
| 563 // does not create a new RenderView on navigation. | 557 // does not create a new RenderView on navigation. |
| 564 if (has_render_view_) { | 558 if (has_render_view_) { |
| 565 static_cast<RenderViewHostImpl*>( | 559 static_cast<RenderViewHostImpl*>( |
| 566 GetWebContents()->GetRenderViewHost())->Init(); | 560 GetWebContents()->GetRenderViewHost())->Init(); |
| 567 WebContentsViewGuest* new_view = | 561 WebContentsViewGuest* new_view = |
| 568 static_cast<WebContentsViewGuest*>(GetWebContents()->GetView()); | 562 static_cast<WebContentsViewGuest*>(GetWebContents()->GetView()); |
| 569 new_view->CreateViewForWidget(web_contents()->GetRenderViewHost()); | 563 new_view->CreateViewForWidget(web_contents()->GetRenderViewHost()); |
| 570 } | 564 } |
| 571 | 565 |
| 572 Initialize(params, embedder_web_contents); | 566 Initialize(params, embedder_web_contents, extra_params); |
| 573 | 567 |
| 574 SendQueuedMessages(); | 568 SendQueuedMessages(); |
|
Fady Samuel
2014/05/29 20:35:23
I don't think we need a separate BrowserPluginGues
lazyboy
2014/05/30 05:48:21
I've made BPEmbedder always call Attach, and made
| |
| 575 | 569 |
| 576 RecordAction(base::UserMetricsAction("BrowserPlugin.Guest.Attached")); | 570 RecordAction(base::UserMetricsAction("BrowserPlugin.Guest.Attached")); |
| 577 } | 571 } |
| 578 | 572 |
| 579 void BrowserPluginGuest::OnCompositorFrameSwappedACK( | 573 void BrowserPluginGuest::OnCompositorFrameSwappedACK( |
| 580 int instance_id, | 574 int instance_id, |
| 581 const FrameHostMsg_CompositorFrameSwappedACK_Params& params) { | 575 const FrameHostMsg_CompositorFrameSwappedACK_Params& params) { |
| 582 RenderWidgetHostImpl::SendSwapCompositorFrameAck(params.producing_route_id, | 576 RenderWidgetHostImpl::SendSwapCompositorFrameAck(params.producing_route_id, |
| 583 params.output_surface_id, | 577 params.output_surface_id, |
| 584 params.producing_host_id, | 578 params.producing_host_id, |
| (...skipping 386 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 971 void BrowserPluginGuest::OnImeCompositionRangeChanged( | 965 void BrowserPluginGuest::OnImeCompositionRangeChanged( |
| 972 const gfx::Range& range, | 966 const gfx::Range& range, |
| 973 const std::vector<gfx::Rect>& character_bounds) { | 967 const std::vector<gfx::Rect>& character_bounds) { |
| 974 static_cast<RenderWidgetHostViewBase*>( | 968 static_cast<RenderWidgetHostViewBase*>( |
| 975 web_contents()->GetRenderWidgetHostView())->ImeCompositionRangeChanged( | 969 web_contents()->GetRenderWidgetHostView())->ImeCompositionRangeChanged( |
| 976 range, character_bounds); | 970 range, character_bounds); |
| 977 } | 971 } |
| 978 #endif | 972 #endif |
| 979 | 973 |
| 980 } // namespace content | 974 } // namespace content |
| OLD | NEW |