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

Side by Side Diff: content/browser/web_contents/web_contents_impl.cc

Issue 2165523004: Force MimeHandlerView to always use BrowserPlugin (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added BrowserPluginGuestDelegateMode::DelegateMode(FromWebContents)? Created 4 years, 4 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/web_contents/web_contents_impl.h" 5 #include "content/browser/web_contents/web_contents_impl.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <cmath> 9 #include <cmath>
10 #include <utility> 10 #include <utility>
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 #include "content/common/browser_plugin/browser_plugin_messages.h" 79 #include "content/common/browser_plugin/browser_plugin_messages.h"
80 #include "content/common/frame_messages.h" 80 #include "content/common/frame_messages.h"
81 #include "content/common/input/web_input_event_traits.h" 81 #include "content/common/input/web_input_event_traits.h"
82 #include "content/common/input_messages.h" 82 #include "content/common/input_messages.h"
83 #include "content/common/page_messages.h" 83 #include "content/common/page_messages.h"
84 #include "content/common/site_isolation_policy.h" 84 #include "content/common/site_isolation_policy.h"
85 #include "content/common/ssl_status_serialization.h" 85 #include "content/common/ssl_status_serialization.h"
86 #include "content/common/view_messages.h" 86 #include "content/common/view_messages.h"
87 #include "content/public/browser/ax_event_notification_details.h" 87 #include "content/public/browser/ax_event_notification_details.h"
88 #include "content/public/browser/browser_context.h" 88 #include "content/public/browser/browser_context.h"
89 #include "content/public/browser/browser_plugin_guest_delegate_mode.h"
89 #include "content/public/browser/browser_plugin_guest_manager.h" 90 #include "content/public/browser/browser_plugin_guest_manager.h"
90 #include "content/public/browser/content_browser_client.h" 91 #include "content/public/browser/content_browser_client.h"
91 #include "content/public/browser/devtools_agent_host.h" 92 #include "content/public/browser/devtools_agent_host.h"
92 #include "content/public/browser/download_manager.h" 93 #include "content/public/browser/download_manager.h"
93 #include "content/public/browser/download_url_parameters.h" 94 #include "content/public/browser/download_url_parameters.h"
94 #include "content/public/browser/invalidate_type.h" 95 #include "content/public/browser/invalidate_type.h"
95 #include "content/public/browser/javascript_dialog_manager.h" 96 #include "content/public/browser/javascript_dialog_manager.h"
96 #include "content/public/browser/load_from_memory_cache_details.h" 97 #include "content/public/browser/load_from_memory_cache_details.h"
97 #include "content/public/browser/load_notification_details.h" 98 #include "content/public/browser/load_notification_details.h"
98 #include "content/public/browser/navigation_details.h" 99 #include "content/public/browser/navigation_details.h"
99 #include "content/public/browser/notification_details.h" 100 #include "content/public/browser/notification_details.h"
100 #include "content/public/browser/notification_service.h" 101 #include "content/public/browser/notification_service.h"
101 #include "content/public/browser/notification_types.h" 102 #include "content/public/browser/notification_types.h"
102 #include "content/public/browser/render_widget_host_iterator.h" 103 #include "content/public/browser/render_widget_host_iterator.h"
103 #include "content/public/browser/resource_request_details.h" 104 #include "content/public/browser/resource_request_details.h"
104 #include "content/public/browser/screen_orientation_dispatcher_host.h" 105 #include "content/public/browser/screen_orientation_dispatcher_host.h"
105 #include "content/public/browser/security_style_explanations.h" 106 #include "content/public/browser/security_style_explanations.h"
106 #include "content/public/browser/storage_partition.h" 107 #include "content/public/browser/storage_partition.h"
107 #include "content/public/browser/user_metrics.h" 108 #include "content/public/browser/user_metrics.h"
108 #include "content/public/browser/web_contents_delegate.h" 109 #include "content/public/browser/web_contents_delegate.h"
109 #include "content/public/common/bindings_policy.h" 110 #include "content/public/common/bindings_policy.h"
110 #include "content/public/common/browser_plugin_guest_mode.h"
111 #include "content/public/common/browser_side_navigation_policy.h" 111 #include "content/public/common/browser_side_navigation_policy.h"
112 #include "content/public/common/child_process_host.h" 112 #include "content/public/common/child_process_host.h"
113 #include "content/public/common/content_constants.h" 113 #include "content/public/common/content_constants.h"
114 #include "content/public/common/content_switches.h" 114 #include "content/public/common/content_switches.h"
115 #include "content/public/common/page_zoom.h" 115 #include "content/public/common/page_zoom.h"
116 #include "content/public/common/result_codes.h" 116 #include "content/public/common/result_codes.h"
117 #include "content/public/common/security_style.h" 117 #include "content/public/common/security_style.h"
118 #include "content/public/common/url_constants.h" 118 #include "content/public/common/url_constants.h"
119 #include "content/public/common/url_utils.h" 119 #include "content/public/common/url_utils.h"
120 #include "content/public/common/web_preferences.h" 120 #include "content/public/common/web_preferences.h"
(...skipping 1253 matching lines...) Expand 10 before | Expand all | Expand 10 after
1374 } 1374 }
1375 1375
1376 void WebContentsImpl::DispatchBeforeUnload() { 1376 void WebContentsImpl::DispatchBeforeUnload() {
1377 bool for_cross_site_transition = false; 1377 bool for_cross_site_transition = false;
1378 GetMainFrame()->DispatchBeforeUnload(for_cross_site_transition, false); 1378 GetMainFrame()->DispatchBeforeUnload(for_cross_site_transition, false);
1379 } 1379 }
1380 1380
1381 void WebContentsImpl::AttachToOuterWebContentsFrame( 1381 void WebContentsImpl::AttachToOuterWebContentsFrame(
1382 WebContents* outer_web_contents, 1382 WebContents* outer_web_contents,
1383 RenderFrameHost* outer_contents_frame) { 1383 RenderFrameHost* outer_contents_frame) {
1384 CHECK(BrowserPluginGuestMode::UseCrossProcessFramesForGuests()); 1384 CHECK_EQ(BrowserPluginGuestDelegateMode::USING_CROSS_PROCESS_FRAMES,
1385 BrowserPluginGuestDelegateMode::DelegateModeFromWebContents(this));
1385 RenderFrameHostManager* render_manager = GetRenderManager(); 1386 RenderFrameHostManager* render_manager = GetRenderManager();
1386 1387
1387 // When the WebContents being initialized has an opener, the browser side 1388 // When the WebContents being initialized has an opener, the browser side
1388 // Render{View,Frame}Host must be initialized and the RenderWidgetHostView 1389 // Render{View,Frame}Host must be initialized and the RenderWidgetHostView
1389 // created. This is needed because the usual initialization happens during 1390 // created. This is needed because the usual initialization happens during
1390 // the first navigation, but when attaching a new window we don't navigate 1391 // the first navigation, but when attaching a new window we don't navigate
1391 // before attaching. If the browser side is already initialized, the calls 1392 // before attaching. If the browser side is already initialized, the calls
1392 // below will just early return. 1393 // below will just early return.
1393 render_manager->InitRenderView(GetRenderViewHost(), nullptr); 1394 render_manager->InitRenderView(GetRenderViewHost(), nullptr);
1394 GetMainFrame()->Init(); 1395 GetMainFrame()->Init();
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
1530 switches::kUseMusInRenderer)) { 1531 switches::kUseMusInRenderer)) {
1531 ui::Window* mus_window = aura::GetMusWindow(params.context); 1532 ui::Window* mus_window = aura::GetMusWindow(params.context);
1532 if (mus_window) { 1533 if (mus_window) {
1533 view_.reset(new WebContentsViewMus(mus_window, this, delegate, 1534 view_.reset(new WebContentsViewMus(mus_window, this, delegate,
1534 &render_view_host_delegate_view_)); 1535 &render_view_host_delegate_view_));
1535 } 1536 }
1536 } 1537 }
1537 #endif 1538 #endif
1538 1539
1539 if (!view_) { 1540 if (!view_) {
1540 if (browser_plugin_guest_ && 1541 if (BrowserPluginGuestDelegateMode::DelegateModeFromWebContents(this) ==
1541 BrowserPluginGuestMode::UseCrossProcessFramesForGuests()) { 1542 BrowserPluginGuestDelegateMode::USING_CROSS_PROCESS_FRAMES) {
1542 view_.reset(new WebContentsViewChildFrame( 1543 view_.reset(new WebContentsViewChildFrame(
1543 this, delegate, &render_view_host_delegate_view_)); 1544 this, delegate, &render_view_host_delegate_view_));
1544 } else { 1545 } else {
1545 view_.reset(CreateWebContentsView(this, delegate, 1546 view_.reset(CreateWebContentsView(this, delegate,
1546 &render_view_host_delegate_view_)); 1547 &render_view_host_delegate_view_));
1547 } 1548 }
1548 } 1549 }
1549 1550
1550 if (browser_plugin_guest_ && 1551 if (BrowserPluginGuestDelegateMode::DelegateModeFromWebContents(this) ==
1551 !BrowserPluginGuestMode::UseCrossProcessFramesForGuests()) { 1552 BrowserPluginGuestDelegateMode::NOT_USING_CROSS_PROCESS_FRAMES) {
1552 view_.reset(new WebContentsViewGuest(this, browser_plugin_guest_.get(), 1553 view_.reset(new WebContentsViewGuest(this, browser_plugin_guest_.get(),
1553 std::move(view_), 1554 std::move(view_),
1554 &render_view_host_delegate_view_)); 1555 &render_view_host_delegate_view_));
1555 } 1556 }
1556 CHECK(render_view_host_delegate_view_); 1557 CHECK(render_view_host_delegate_view_);
1557 CHECK(view_.get()); 1558 CHECK(view_.get());
1558 1559
1559 gfx::Size initial_size = params.initial_size; 1560 gfx::Size initial_size = params.initial_size;
1560 view_->CreateView(initial_size, params.context); 1561 view_->CreateView(initial_size, params.context);
1561 1562
(...skipping 2989 matching lines...) Expand 10 before | Expand all | Expand 10 after
4551 4552
4552 void WebContentsImpl::EnsureOpenerProxiesExist(RenderFrameHost* source_rfh) { 4553 void WebContentsImpl::EnsureOpenerProxiesExist(RenderFrameHost* source_rfh) {
4553 WebContentsImpl* source_web_contents = static_cast<WebContentsImpl*>( 4554 WebContentsImpl* source_web_contents = static_cast<WebContentsImpl*>(
4554 WebContents::FromRenderFrameHost(source_rfh)); 4555 WebContents::FromRenderFrameHost(source_rfh));
4555 4556
4556 if (source_web_contents) { 4557 if (source_web_contents) {
4557 // If this message is going to outer WebContents from inner WebContents, 4558 // If this message is going to outer WebContents from inner WebContents,
4558 // then we should not create a RenderView. AttachToOuterWebContentsFrame() 4559 // then we should not create a RenderView. AttachToOuterWebContentsFrame()
4559 // already created a RenderFrameProxyHost for that purpose. 4560 // already created a RenderFrameProxyHost for that purpose.
4560 if (GetBrowserPluginEmbedder() && 4561 if (GetBrowserPluginEmbedder() &&
4561 BrowserPluginGuestMode::UseCrossProcessFramesForGuests()) { 4562 BrowserPluginGuestDelegateMode::DelegateModeFromWebContents(this) !=
4563 BrowserPluginGuestDelegateMode::NOT_USING_CROSS_PROCESS_FRAMES) {
4562 return; 4564 return;
4563 } 4565 }
4564 4566
4565 if (this != source_web_contents && GetBrowserPluginGuest()) { 4567 if (this != source_web_contents && GetBrowserPluginGuest()) {
4566 // We create a RenderFrameProxyHost for the embedder in the guest's render 4568 // We create a RenderFrameProxyHost for the embedder in the guest's render
4567 // process but we intentionally do not expose the embedder's opener chain 4569 // process but we intentionally do not expose the embedder's opener chain
4568 // to it. 4570 // to it.
4569 source_web_contents->GetRenderManager()->CreateRenderFrameProxy( 4571 source_web_contents->GetRenderManager()->CreateRenderFrameProxy(
4570 GetSiteInstance()); 4572 GetSiteInstance());
4571 } else { 4573 } else {
(...skipping 382 matching lines...) Expand 10 before | Expand all | Expand 10 after
4954 return node_->outer_contents_frame_tree_node_id(); 4956 return node_->outer_contents_frame_tree_node_id();
4955 4957
4956 return FrameTreeNode::kFrameTreeNodeInvalidId; 4958 return FrameTreeNode::kFrameTreeNodeInvalidId;
4957 } 4959 }
4958 4960
4959 RenderFrameHostManager* WebContentsImpl::GetRenderManager() const { 4961 RenderFrameHostManager* WebContentsImpl::GetRenderManager() const {
4960 return frame_tree_.root()->render_manager(); 4962 return frame_tree_.root()->render_manager();
4961 } 4963 }
4962 4964
4963 WebContentsImpl* WebContentsImpl::GetOuterWebContents() { 4965 WebContentsImpl* WebContentsImpl::GetOuterWebContents() {
4964 if (BrowserPluginGuestMode::UseCrossProcessFramesForGuests()) { 4966 BrowserPluginGuestDelegateMode::DelegateMode mode =
4965 if (node_) 4967 BrowserPluginGuestDelegateMode::DelegateModeFromWebContents(this);
4966 return node_->outer_web_contents(); 4968 if (BrowserPluginGuestDelegateMode::NONE == mode)
4967 } else { 4969 return nullptr;
4968 if (GetBrowserPluginGuest()) 4970
4969 return GetBrowserPluginGuest()->embedder_web_contents(); 4971 if (BrowserPluginGuestDelegateMode::USING_CROSS_PROCESS_FRAMES == mode)
4970 } 4972 return !!node_ ? node_->outer_web_contents() : nullptr;
4971 return nullptr; 4973
4974 return browser_plugin_guest_->embedder_web_contents();
4972 } 4975 }
4973 4976
4974 BrowserPluginGuest* WebContentsImpl::GetBrowserPluginGuest() const { 4977 BrowserPluginGuest* WebContentsImpl::GetBrowserPluginGuest() const {
4975 return browser_plugin_guest_.get(); 4978 return browser_plugin_guest_.get();
4976 } 4979 }
4977 4980
4978 void WebContentsImpl::SetBrowserPluginGuest(BrowserPluginGuest* guest) { 4981 void WebContentsImpl::SetBrowserPluginGuest(BrowserPluginGuest* guest) {
4979 CHECK(!browser_plugin_guest_); 4982 CHECK(!browser_plugin_guest_);
4980 CHECK(guest); 4983 CHECK(guest);
4981 browser_plugin_guest_.reset(guest); 4984 browser_plugin_guest_.reset(guest);
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
5153 for (RenderViewHost* render_view_host : render_view_host_set) 5156 for (RenderViewHost* render_view_host : render_view_host_set)
5154 render_view_host->OnWebkitPreferencesChanged(); 5157 render_view_host->OnWebkitPreferencesChanged();
5155 } 5158 }
5156 5159
5157 void WebContentsImpl::SetJavaScriptDialogManagerForTesting( 5160 void WebContentsImpl::SetJavaScriptDialogManagerForTesting(
5158 JavaScriptDialogManager* dialog_manager) { 5161 JavaScriptDialogManager* dialog_manager) {
5159 dialog_manager_ = dialog_manager; 5162 dialog_manager_ = dialog_manager;
5160 } 5163 }
5161 5164
5162 } // namespace content 5165 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698