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

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

Issue 269113002: Remove BrowserPluginGuestManager (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@guestview_manager_createguest
Patch Set: Updateed Created 6 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
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/message_loop.h" 9 #include "base/message_loop/message_loop.h"
10 #include "base/strings/string_util.h" 10 #include "base/strings/string_util.h"
11 #include "base/strings/utf_string_conversions.h" 11 #include "base/strings/utf_string_conversions.h"
12 #include "content/browser/browser_plugin/browser_plugin_embedder.h" 12 #include "content/browser/browser_plugin/browser_plugin_embedder.h"
13 #include "content/browser/browser_plugin/browser_plugin_guest_manager.h"
14 #include "content/browser/browser_plugin/browser_plugin_host_factory.h" 13 #include "content/browser/browser_plugin/browser_plugin_host_factory.h"
15 #include "content/browser/browser_thread_impl.h" 14 #include "content/browser/browser_thread_impl.h"
16 #include "content/browser/child_process_security_policy_impl.h" 15 #include "content/browser/child_process_security_policy_impl.h"
17 #include "content/browser/frame_host/render_frame_host_impl.h" 16 #include "content/browser/frame_host/render_frame_host_impl.h"
18 #include "content/browser/frame_host/render_widget_host_view_guest.h" 17 #include "content/browser/frame_host/render_widget_host_view_guest.h"
19 #include "content/browser/loader/resource_dispatcher_host_impl.h" 18 #include "content/browser/loader/resource_dispatcher_host_impl.h"
20 #include "content/browser/renderer_host/render_view_host_delegate_view.h" 19 #include "content/browser/renderer_host/render_view_host_delegate_view.h"
21 #include "content/browser/renderer_host/render_view_host_impl.h" 20 #include "content/browser/renderer_host/render_view_host_impl.h"
22 #include "content/browser/renderer_host/render_widget_host_impl.h" 21 #include "content/browser/renderer_host/render_widget_host_impl.h"
23 #include "content/browser/renderer_host/render_widget_host_view_base.h" 22 #include "content/browser/renderer_host/render_widget_host_view_base.h"
24 #include "content/browser/web_contents/web_contents_impl.h" 23 #include "content/browser/web_contents/web_contents_impl.h"
25 #include "content/browser/web_contents/web_contents_view_guest.h" 24 #include "content/browser/web_contents/web_contents_view_guest.h"
26 #include "content/common/browser_plugin/browser_plugin_constants.h" 25 #include "content/common/browser_plugin/browser_plugin_constants.h"
27 #include "content/common/browser_plugin/browser_plugin_messages.h" 26 #include "content/common/browser_plugin/browser_plugin_messages.h"
28 #include "content/common/content_constants_internal.h" 27 #include "content/common/content_constants_internal.h"
29 #include "content/common/drag_messages.h" 28 #include "content/common/drag_messages.h"
30 #include "content/common/input_messages.h" 29 #include "content/common/input_messages.h"
31 #include "content/common/view_messages.h" 30 #include "content/common/view_messages.h"
32 #include "content/public/browser/browser_context.h" 31 #include "content/public/browser/browser_context.h"
32 #include "content/public/browser/browser_plugin_guest_manager_delegate.h"
33 #include "content/public/browser/content_browser_client.h" 33 #include "content/public/browser/content_browser_client.h"
34 #include "content/public/browser/navigation_controller.h" 34 #include "content/public/browser/navigation_controller.h"
35 #include "content/public/browser/render_widget_host_view.h" 35 #include "content/public/browser/render_widget_host_view.h"
36 #include "content/public/browser/user_metrics.h" 36 #include "content/public/browser/user_metrics.h"
37 #include "content/public/browser/web_contents_observer.h" 37 #include "content/public/browser/web_contents_observer.h"
38 #include "content/public/common/context_menu_params.h" 38 #include "content/public/common/context_menu_params.h"
39 #include "content/public/common/drop_data.h" 39 #include "content/public/common/drop_data.h"
40 #include "content/public/common/media_stream_request.h" 40 #include "content/public/common/media_stream_request.h"
41 #include "content/public/common/result_codes.h" 41 #include "content/public/common/result_codes.h"
42 #include "content/public/common/url_constants.h" 42 #include "content/public/common/url_constants.h"
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 embedder_render_process_id, 104 embedder_render_process_id,
105 base::Bind(&BrowserPluginGuest::NewWindowRequest::RespondInternal, 105 base::Bind(&BrowserPluginGuest::NewWindowRequest::RespondInternal,
106 base::Unretained(this), 106 base::Unretained(this),
107 should_allow)); 107 should_allow));
108 } 108 }
109 109
110 private: 110 private:
111 virtual ~NewWindowRequest() {} 111 virtual ~NewWindowRequest() {}
112 112
113 void RespondInternal(bool should_allow, 113 void RespondInternal(bool should_allow,
114 BrowserPluginGuest* guest) { 114 WebContents* guest_web_contents) {
115 if (!guest) { 115 if (!guest_web_contents) {
116 VLOG(0) << "Guest not found. Instance ID: " << instance_id_; 116 VLOG(0) << "Guest not found. Instance ID: " << instance_id_;
117 return; 117 return;
118 } 118 }
119 119
120 BrowserPluginGuest* guest =
121 static_cast<WebContentsImpl*>(guest_web_contents)->
122 GetBrowserPluginGuest();
123 DCHECK(guest);
120 // If we do not destroy the guest then we allow the new window. 124 // If we do not destroy the guest then we allow the new window.
121 if (!should_allow) 125 if (!should_allow)
122 guest->Destroy(); 126 guest->Destroy();
123 } 127 }
124 128
125 int instance_id_; 129 int instance_id_;
126 }; 130 };
127 131
128 namespace { 132 namespace {
129 std::string WindowOpenDispositionToString( 133 std::string WindowOpenDispositionToString(
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
299 BrowserPluginGuestDelegate::PermissionResponseCallback callback = 303 BrowserPluginGuestDelegate::PermissionResponseCallback callback =
300 base::Bind(&BrowserPluginGuest::RespondToPermissionRequest, 304 base::Bind(&BrowserPluginGuest::RespondToPermissionRequest,
301 AsWeakPtr(), 305 AsWeakPtr(),
302 request_id); 306 request_id);
303 delegate_->RequestPermission( 307 delegate_->RequestPermission(
304 permission_type, request_info, callback, request->AllowedByDefault()); 308 permission_type, request_info, callback, request->AllowedByDefault());
305 } 309 }
306 310
307 BrowserPluginGuest* BrowserPluginGuest::CreateNewGuestWindow( 311 BrowserPluginGuest* BrowserPluginGuest::CreateNewGuestWindow(
308 const OpenURLParams& params) { 312 const OpenURLParams& params) {
309 BrowserPluginGuestManager* guest_manager = GetBrowserPluginGuestManager(); 313 BrowserPluginGuestManagerDelegate* guest_manager =
314 GetBrowserPluginGuestManager();
310 315
311 // Allocate a new instance ID for the new guest. 316 // Allocate a new instance ID for the new guest.
312 int instance_id = guest_manager->GetNextInstanceID(); 317 int instance_id = guest_manager->GetNextInstanceID();
313 318
314 // Set the attach params to use the same partition as the opener. 319 // Set the attach params to use the same partition as the opener.
315 // We pull the partition information from the site's URL, which is of the form 320 // We pull the partition information from the site's URL, which is of the form
316 // guest://site/{persist}?{partition_name}. 321 // guest://site/{persist}?{partition_name}.
317 const GURL& site_url = GetWebContents()->GetSiteInstance()->GetSiteURL(); 322 const GURL& site_url = GetWebContents()->GetSiteInstance()->GetSiteURL();
318 323
319 // The new guest gets a copy of this guest's extra params so that the content 324 // The new guest gets a copy of this guest's extra params so that the content
320 // embedder exposes the same API for this guest as its opener. 325 // embedder exposes the same API for this guest as its opener.
321 scoped_ptr<base::DictionaryValue> extra_params( 326 scoped_ptr<base::DictionaryValue> extra_params(
322 extra_attach_params_->DeepCopy()); 327 extra_attach_params_->DeepCopy());
323 const std::string& storage_partition_id = site_url.query(); 328 const std::string& storage_partition_id = site_url.query();
324 bool persist_storage = 329 bool persist_storage =
325 site_url.path().find("persist") != std::string::npos; 330 site_url.path().find("persist") != std::string::npos;
326 BrowserPluginGuest* new_guest = 331 WebContents* new_guest_web_contents =
327 guest_manager->CreateGuest(GetWebContents()->GetSiteInstance(), 332 guest_manager->CreateGuest(GetWebContents()->GetSiteInstance(),
328 instance_id, 333 instance_id,
329 storage_partition_id, 334 storage_partition_id,
330 persist_storage, 335 persist_storage,
331 extra_params.Pass()); 336 extra_params.Pass());
337 BrowserPluginGuest* new_guest =
338 static_cast<WebContentsImpl*>(new_guest_web_contents)->
339 GetBrowserPluginGuest();
332 if (new_guest->delegate_) 340 if (new_guest->delegate_)
333 new_guest->delegate_->SetOpener(GetWebContents()); 341 new_guest->delegate_->SetOpener(GetWebContents());
334 342
335 // Take ownership of |new_guest|. 343 // Take ownership of |new_guest|.
336 pending_new_windows_.insert( 344 pending_new_windows_.insert(
337 std::make_pair(new_guest, NewWindowInfo(params.url, std::string()))); 345 std::make_pair(new_guest, NewWindowInfo(params.url, std::string())));
338 346
339 // Request permission to show the new window. 347 // Request permission to show the new window.
340 RequestNewWindowPermission(params.disposition, gfx::Rect(), 348 RequestNewWindowPermission(params.disposition, gfx::Rect(),
341 params.user_gesture, new_guest->GetWebContents()); 349 params.user_gesture, new_guest->GetWebContents());
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after
567 void BrowserPluginGuest::CopyFromCompositingSurface( 575 void BrowserPluginGuest::CopyFromCompositingSurface(
568 gfx::Rect src_subrect, 576 gfx::Rect src_subrect,
569 gfx::Size dst_size, 577 gfx::Size dst_size,
570 const base::Callback<void(bool, const SkBitmap&)>& callback) { 578 const base::Callback<void(bool, const SkBitmap&)>& callback) {
571 copy_request_callbacks_.insert(std::make_pair(++copy_request_id_, callback)); 579 copy_request_callbacks_.insert(std::make_pair(++copy_request_id_, callback));
572 SendMessageToEmbedder( 580 SendMessageToEmbedder(
573 new BrowserPluginMsg_CopyFromCompositingSurface(instance_id(), 581 new BrowserPluginMsg_CopyFromCompositingSurface(instance_id(),
574 copy_request_id_, src_subrect, dst_size)); 582 copy_request_id_, src_subrect, dst_size));
575 } 583 }
576 584
577 BrowserPluginGuestManager* 585 BrowserPluginGuestManagerDelegate*
578 BrowserPluginGuest::GetBrowserPluginGuestManager() const { 586 BrowserPluginGuest::GetBrowserPluginGuestManager() const {
579 return BrowserPluginGuestManager::FromBrowserContext( 587 return GetWebContents()->GetBrowserContext()->GetGuestManagerDelegate();
580 GetWebContents()->GetBrowserContext());
581 } 588 }
582 589
583 // screen. 590 // screen.
584 gfx::Rect BrowserPluginGuest::ToGuestRect(const gfx::Rect& bounds) { 591 gfx::Rect BrowserPluginGuest::ToGuestRect(const gfx::Rect& bounds) {
585 gfx::Rect guest_rect(bounds); 592 gfx::Rect guest_rect(bounds);
586 guest_rect.Offset(guest_window_rect_.OffsetFromOrigin()); 593 guest_rect.Offset(guest_window_rect_.OffsetFromOrigin());
587 return guest_rect; 594 return guest_rect;
588 } 595 }
589 596
590 void BrowserPluginGuest::EmbedderVisibilityChanged(bool visible) { 597 void BrowserPluginGuest::EmbedderVisibilityChanged(bool visible) {
(...skipping 964 matching lines...) Expand 10 before | Expand all | Expand 10 after
1555 const GURL& url) { 1562 const GURL& url) {
1556 if (!url.is_valid()) { 1563 if (!url.is_valid()) {
1557 callback.Run(false); 1564 callback.Run(false);
1558 return; 1565 return;
1559 } 1566 }
1560 1567
1561 delegate_->CanDownload(request_method, url, callback); 1568 delegate_->CanDownload(request_method, url, callback);
1562 } 1569 }
1563 1570
1564 } // namespace content 1571 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/browser_plugin/browser_plugin_guest.h ('k') | content/browser/browser_plugin/browser_plugin_guest_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698