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

Side by Side Diff: content/browser/browser_plugin/browser_plugin_guest.cc

Issue 13032003: Browser Plugin: <webview> should inherit partition attribute of opener on attachment. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Addressed comments Created 7 years, 9 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 #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
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
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
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_;
Charlie Reis 2013/03/26 17:02:32 The partition name and whether it is persistent is
Fady Samuel 2013/03/26 17:15:40 I thought about that. The issue is BrowserPluginGu
Charlie Reis 2013/03/26 17:49:30 I'm not happy with having a separate copy of these
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 BrowserPluginMsg_Attach_ACK_Params ack_params;
718 SendMessageToEmbedder( 727 ack_params.storage_partition_id = storage_partition_id_;
719 new BrowserPluginMsg_UpdatedName(instance_id_, name_)); 728 ack_params.persist_storage = persist_storage_;
720 } 729 ack_params.name = name_;
730 SendMessageToEmbedder(
731 new BrowserPluginMsg_Attach_ACK(instance_id_, ack_params));
Charlie Reis 2013/03/26 17:02:32 I don't understand why we need to send these in th
Fady Samuel 2013/03/26 17:15:40 No, the BrowserPlugin is a pre-existing BrowserPlu
Charlie Reis 2013/03/26 17:49:30 So the guest is already created in the correct par
721 } 732 }
722 733
723 void BrowserPluginGuest::OnDragStatusUpdate(int instance_id, 734 void BrowserPluginGuest::OnDragStatusUpdate(int instance_id,
724 WebKit::WebDragStatus drag_status, 735 WebKit::WebDragStatus drag_status,
725 const WebDropData& drop_data, 736 const WebDropData& drop_data,
726 WebKit::WebDragOperationsMask mask, 737 WebKit::WebDragOperationsMask mask,
727 const gfx::Point& location) { 738 const gfx::Point& location) {
728 RenderViewHost* host = GetWebContents()->GetRenderViewHost(); 739 RenderViewHost* host = GetWebContents()->GetRenderViewHost();
729 switch (drag_status) { 740 switch (drag_status) {
730 case WebKit::WebDragStatusEnter: 741 case WebKit::WebDragStatusEnter:
(...skipping 499 matching lines...) Expand 10 before | Expand all | Expand 10 after
1230 LOG(INFO) << "Guest not found. Instance ID: " << instance_id; 1241 LOG(INFO) << "Guest not found. Instance ID: " << instance_id;
1231 return; 1242 return;
1232 } 1243 }
1233 if (!should_allow) 1244 if (!should_allow)
1234 guest->Destroy(); 1245 guest->Destroy();
1235 // If we do not destroy the guest then we allow the new window. 1246 // If we do not destroy the guest then we allow the new window.
1236 new_window_request_map_.erase(new_window_request_iter); 1247 new_window_request_map_.erase(new_window_request_iter);
1237 } 1248 }
1238 1249
1239 } // namespace content 1250 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698