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.h" | 9 #include "base/message_loop.h" |
| 10 #include "base/string_util.h" | 10 #include "base/string_util.h" |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 113 damage_buffer_sequence_id_(0), | 113 damage_buffer_sequence_id_(0), |
| 114 damage_buffer_size_(0), | 114 damage_buffer_size_(0), |
| 115 damage_buffer_scale_factor_(1.0f), | 115 damage_buffer_scale_factor_(1.0f), |
| 116 guest_hang_timeout_( | 116 guest_hang_timeout_( |
| 117 base::TimeDelta::FromMilliseconds(kHungRendererDelayMs)), | 117 base::TimeDelta::FromMilliseconds(kHungRendererDelayMs)), |
| 118 focused_(false), | 118 focused_(false), |
| 119 mouse_locked_(false), | 119 mouse_locked_(false), |
| 120 pending_lock_request_(false), | 120 pending_lock_request_(false), |
| 121 embedder_visible_(true), | 121 embedder_visible_(true), |
| 122 opener_(NULL), | 122 opener_(NULL), |
| 123 next_permission_request_id_(0) { | 123 next_permission_request_id_(0), |
| 124 persist_storage_(false) { | |
| 124 DCHECK(web_contents); | 125 DCHECK(web_contents); |
| 125 web_contents->SetDelegate(this); | 126 web_contents->SetDelegate(this); |
| 126 GetWebContents()->GetBrowserPluginGuestManager()->AddGuest(instance_id_, | 127 GetWebContents()->GetBrowserPluginGuestManager()->AddGuest(instance_id_, |
| 127 GetWebContents()); | 128 GetWebContents()); |
| 128 } | 129 } |
| 129 | 130 |
| 130 void BrowserPluginGuest::DestroyUnattachedWindows() { | 131 void BrowserPluginGuest::DestroyUnattachedWindows() { |
| 131 // Destroy() reaches in and removes the BrowserPluginGuest from its opener's | 132 // Destroy() reaches in and removes the BrowserPluginGuest from its opener's |
| 132 // pending_new_windows_ set. To avoid mutating the set while iterating, we | 133 // pending_new_windows_ set. To avoid mutating the set while iterating, we |
| 133 // create a copy of the pending new windows set and iterate over the copy. | 134 // create a copy of the pending new windows set and iterate over the copy. |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 184 void BrowserPluginGuest::Initialize( | 185 void BrowserPluginGuest::Initialize( |
| 185 WebContentsImpl* embedder_web_contents, | 186 WebContentsImpl* embedder_web_contents, |
| 186 const BrowserPluginHostMsg_CreateGuest_Params& params) { | 187 const BrowserPluginHostMsg_CreateGuest_Params& params) { |
| 187 focused_ = params.focused; | 188 focused_ = params.focused; |
| 188 guest_visible_ = params.visible; | 189 guest_visible_ = params.visible; |
| 189 if (!params.name.empty()) | 190 if (!params.name.empty()) |
| 190 name_ = params.name; | 191 name_ = params.name; |
| 191 auto_size_enabled_ = params.auto_size_params.enable; | 192 auto_size_enabled_ = params.auto_size_params.enable; |
| 192 max_auto_size_ = params.auto_size_params.max_size; | 193 max_auto_size_ = params.auto_size_params.max_size; |
| 193 min_auto_size_ = params.auto_size_params.min_size; | 194 min_auto_size_ = params.auto_size_params.min_size; |
| 195 if (!params.storage_partition_id.empty()) { | |
| 196 storage_partition_id_ = params.storage_partition_id; | |
| 197 persist_storage_ = params.persist_storage; | |
| 198 } | |
| 194 | 199 |
| 195 // Once a BrowserPluginGuest has an embedder WebContents, it's considered to | 200 // Once a BrowserPluginGuest has an embedder WebContents, it's considered to |
| 196 // be attached. | 201 // be attached. |
| 197 embedder_web_contents_ = embedder_web_contents; | 202 embedder_web_contents_ = embedder_web_contents; |
| 198 | 203 |
| 199 // |render_view_host| manages the ownership of this BrowserPluginGuestHelper. | 204 // |render_view_host| manages the ownership of this BrowserPluginGuestHelper. |
| 200 new BrowserPluginGuestHelper(this, GetWebContents()->GetRenderViewHost()); | 205 new BrowserPluginGuestHelper(this, GetWebContents()->GetRenderViewHost()); |
| 201 | 206 |
| 202 RendererPreferences* renderer_prefs = | 207 RendererPreferences* renderer_prefs = |
| 203 GetWebContents()->GetMutableRendererPrefs(); | 208 GetWebContents()->GetMutableRendererPrefs(); |
| (...skipping 486 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 690 // processed the move. The browser may have ignored the move, but it | 695 // processed the move. The browser may have ignored the move, but it |
| 691 // finished processing. This is used because the renderer keeps a temporary | 696 // finished processing. This is used because the renderer keeps a temporary |
| 692 // cache of the widget position while these asynchronous operations are in | 697 // cache of the widget position while these asynchronous operations are in |
| 693 // progress. | 698 // progress. |
| 694 Send(new ViewMsg_Move_ACK(web_contents()->GetRoutingID())); | 699 Send(new ViewMsg_Move_ACK(web_contents()->GetRoutingID())); |
| 695 } | 700 } |
| 696 // Once a new guest is attached to the DOM of the embedder page, then the | 701 // Once a new guest is attached to the DOM of the embedder page, then the |
| 697 // lifetime of the new guest is no longer managed by the opener guest. | 702 // lifetime of the new guest is no longer managed by the opener guest. |
| 698 opener()->pending_new_windows_.erase(this); | 703 opener()->pending_new_windows_.erase(this); |
| 699 | 704 |
| 705 // The new window inherits the opener's storage partition. | |
| 706 storage_partition_id_ = opener()->storage_partition_id_; | |
| 707 persist_storage_ = opener()->persist_storage_; | |
| 708 | |
| 700 // The guest's frame name takes precedence over the BrowserPlugin's name. | 709 // The guest's frame name takes precedence over the BrowserPlugin's name. |
| 701 // The guest's frame name is assigned in | 710 // The guest's frame name is assigned in |
| 702 // BrowserPluginGuest::WebContentsCreated. | 711 // BrowserPluginGuest::WebContentsCreated. |
| 703 if (!name_.empty()) | 712 if (!name_.empty()) |
| 704 params.name.clear(); | 713 params.name.clear(); |
| 705 | 714 |
| 706 Initialize(embedder_web_contents, params); | 715 Initialize(embedder_web_contents, params); |
| 707 | 716 |
| 708 // We initialize the RenderViewHost after a BrowserPlugin has been attached | 717 // We initialize the RenderViewHost after a BrowserPlugin has been attached |
| 709 // to it and is ready to receive pixels. Until a RenderViewHost is | 718 // to it and is ready to receive pixels. Until a RenderViewHost is |
| 710 // initialized, it will not allow any resize requests. | 719 // initialized, it will not allow any resize requests. |
| 711 if (!GetWebContents()->GetRenderViewHost()->IsRenderViewLive()) { | 720 if (!GetWebContents()->GetRenderViewHost()->IsRenderViewLive()) { |
| 712 static_cast<RenderViewHostImpl*>( | 721 static_cast<RenderViewHostImpl*>( |
| 713 GetWebContents()->GetRenderViewHost())->Init(); | 722 GetWebContents()->GetRenderViewHost())->Init(); |
| 714 } | 723 } |
| 715 | 724 |
| 716 // Inform the embedder BrowserPlugin of the attached guest. | 725 // Inform the embedder of the guest's information. |
| 717 if (!name_.empty()) { | 726 |
|
lazyboy
2013/03/25 18:12:55
nit: remove new line after comment line.
Fady Samuel
2013/03/25 19:28:20
Done.
| |
| 718 SendMessageToEmbedder( | 727 BrowserPluginMsg_Attach_ACK_Params ack_params; |
| 719 new BrowserPluginMsg_UpdatedName(instance_id_, name_)); | 728 ack_params.storage_partition_id = storage_partition_id_; |
| 720 } | 729 ack_params.persist_storage = persist_storage_; |
| 730 ack_params.name = name_; | |
| 731 SendMessageToEmbedder( | |
| 732 new BrowserPluginMsg_Attach_ACK(instance_id_, ack_params)); | |
| 721 } | 733 } |
| 722 | 734 |
| 723 void BrowserPluginGuest::OnDragStatusUpdate(int instance_id, | 735 void BrowserPluginGuest::OnDragStatusUpdate(int instance_id, |
| 724 WebKit::WebDragStatus drag_status, | 736 WebKit::WebDragStatus drag_status, |
| 725 const WebDropData& drop_data, | 737 const WebDropData& drop_data, |
| 726 WebKit::WebDragOperationsMask mask, | 738 WebKit::WebDragOperationsMask mask, |
| 727 const gfx::Point& location) { | 739 const gfx::Point& location) { |
| 728 RenderViewHost* host = GetWebContents()->GetRenderViewHost(); | 740 RenderViewHost* host = GetWebContents()->GetRenderViewHost(); |
| 729 switch (drag_status) { | 741 switch (drag_status) { |
| 730 case WebKit::WebDragStatusEnter: | 742 case WebKit::WebDragStatusEnter: |
| (...skipping 499 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1230 LOG(INFO) << "Guest not found. Instance ID: " << instance_id; | 1242 LOG(INFO) << "Guest not found. Instance ID: " << instance_id; |
| 1231 return; | 1243 return; |
| 1232 } | 1244 } |
| 1233 if (!should_allow) | 1245 if (!should_allow) |
| 1234 guest->Destroy(); | 1246 guest->Destroy(); |
| 1235 // If we do not destroy the guest then we allow the new window. | 1247 // If we do not destroy the guest then we allow the new window. |
| 1236 new_window_request_map_.erase(new_window_request_iter); | 1248 new_window_request_map_.erase(new_window_request_iter); |
| 1237 } | 1249 } |
| 1238 | 1250 |
| 1239 } // namespace content | 1251 } // namespace content |
| OLD | NEW |