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/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 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 86 #include "content/common/site_isolation_policy.h" | 86 #include "content/common/site_isolation_policy.h" |
| 87 #include "content/common/ssl_status_serialization.h" | 87 #include "content/common/ssl_status_serialization.h" |
| 88 #include "content/common/view_messages.h" | 88 #include "content/common/view_messages.h" |
| 89 #include "content/public/browser/ax_event_notification_details.h" | 89 #include "content/public/browser/ax_event_notification_details.h" |
| 90 #include "content/public/browser/browser_context.h" | 90 #include "content/public/browser/browser_context.h" |
| 91 #include "content/public/browser/browser_plugin_guest_manager.h" | 91 #include "content/public/browser/browser_plugin_guest_manager.h" |
| 92 #include "content/public/browser/content_browser_client.h" | 92 #include "content/public/browser/content_browser_client.h" |
| 93 #include "content/public/browser/devtools_agent_host.h" | 93 #include "content/public/browser/devtools_agent_host.h" |
| 94 #include "content/public/browser/download_manager.h" | 94 #include "content/public/browser/download_manager.h" |
| 95 #include "content/public/browser/download_url_parameters.h" | 95 #include "content/public/browser/download_url_parameters.h" |
| 96 #include "content/public/browser/guest_mode.h" | |
| 96 #include "content/public/browser/invalidate_type.h" | 97 #include "content/public/browser/invalidate_type.h" |
| 97 #include "content/public/browser/javascript_dialog_manager.h" | 98 #include "content/public/browser/javascript_dialog_manager.h" |
| 98 #include "content/public/browser/load_from_memory_cache_details.h" | 99 #include "content/public/browser/load_from_memory_cache_details.h" |
| 99 #include "content/public/browser/load_notification_details.h" | 100 #include "content/public/browser/load_notification_details.h" |
| 100 #include "content/public/browser/navigation_details.h" | 101 #include "content/public/browser/navigation_details.h" |
| 101 #include "content/public/browser/notification_details.h" | 102 #include "content/public/browser/notification_details.h" |
| 102 #include "content/public/browser/notification_service.h" | 103 #include "content/public/browser/notification_service.h" |
| 103 #include "content/public/browser/notification_types.h" | 104 #include "content/public/browser/notification_types.h" |
| 104 #include "content/public/browser/render_widget_host_iterator.h" | 105 #include "content/public/browser/render_widget_host_iterator.h" |
| 105 #include "content/public/browser/resource_request_details.h" | 106 #include "content/public/browser/resource_request_details.h" |
| (...skipping 1289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1395 } | 1396 } |
| 1396 | 1397 |
| 1397 void WebContentsImpl::DispatchBeforeUnload() { | 1398 void WebContentsImpl::DispatchBeforeUnload() { |
| 1398 bool for_cross_site_transition = false; | 1399 bool for_cross_site_transition = false; |
| 1399 GetMainFrame()->DispatchBeforeUnload(for_cross_site_transition, false); | 1400 GetMainFrame()->DispatchBeforeUnload(for_cross_site_transition, false); |
| 1400 } | 1401 } |
| 1401 | 1402 |
| 1402 void WebContentsImpl::AttachToOuterWebContentsFrame( | 1403 void WebContentsImpl::AttachToOuterWebContentsFrame( |
| 1403 WebContents* outer_web_contents, | 1404 WebContents* outer_web_contents, |
| 1404 RenderFrameHost* outer_contents_frame) { | 1405 RenderFrameHost* outer_contents_frame) { |
| 1405 CHECK(BrowserPluginGuestMode::UseCrossProcessFramesForGuests()); | 1406 CHECK(guest_mode::IsCrossProcessFrameGuest(this)); |
| 1406 RenderFrameHostManager* render_manager = GetRenderManager(); | 1407 RenderFrameHostManager* render_manager = GetRenderManager(); |
| 1407 | 1408 |
| 1408 // When the WebContents being initialized has an opener, the browser side | 1409 // When the WebContents being initialized has an opener, the browser side |
| 1409 // Render{View,Frame}Host must be initialized and the RenderWidgetHostView | 1410 // Render{View,Frame}Host must be initialized and the RenderWidgetHostView |
| 1410 // created. This is needed because the usual initialization happens during | 1411 // created. This is needed because the usual initialization happens during |
| 1411 // the first navigation, but when attaching a new window we don't navigate | 1412 // the first navigation, but when attaching a new window we don't navigate |
| 1412 // before attaching. If the browser side is already initialized, the calls | 1413 // before attaching. If the browser side is already initialized, the calls |
| 1413 // below will just early return. | 1414 // below will just early return. |
| 1414 render_manager->InitRenderView(GetRenderViewHost(), nullptr); | 1415 render_manager->InitRenderView(GetRenderViewHost(), nullptr); |
| 1415 GetMainFrame()->Init(); | 1416 GetMainFrame()->Init(); |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1551 switches::kUseMusInRenderer)) { | 1552 switches::kUseMusInRenderer)) { |
| 1552 ui::Window* mus_window = aura::GetMusWindow(params.context); | 1553 ui::Window* mus_window = aura::GetMusWindow(params.context); |
| 1553 if (mus_window) { | 1554 if (mus_window) { |
| 1554 view_.reset(new WebContentsViewMus(mus_window, this, delegate, | 1555 view_.reset(new WebContentsViewMus(mus_window, this, delegate, |
| 1555 &render_view_host_delegate_view_)); | 1556 &render_view_host_delegate_view_)); |
| 1556 } | 1557 } |
| 1557 } | 1558 } |
| 1558 #endif | 1559 #endif |
| 1559 | 1560 |
| 1560 if (!view_) { | 1561 if (!view_) { |
| 1561 if (browser_plugin_guest_ && | 1562 if (guest_mode::IsCrossProcessFrameGuest(this)) { |
| 1562 BrowserPluginGuestMode::UseCrossProcessFramesForGuests()) { | |
| 1563 view_.reset(new WebContentsViewChildFrame( | 1563 view_.reset(new WebContentsViewChildFrame( |
| 1564 this, delegate, &render_view_host_delegate_view_)); | 1564 this, delegate, &render_view_host_delegate_view_)); |
| 1565 } else { | 1565 } else { |
| 1566 view_.reset(CreateWebContentsView(this, delegate, | 1566 view_.reset(CreateWebContentsView(this, delegate, |
| 1567 &render_view_host_delegate_view_)); | 1567 &render_view_host_delegate_view_)); |
| 1568 } | 1568 } |
| 1569 } | 1569 } |
| 1570 | 1570 |
| 1571 if (browser_plugin_guest_ && | 1571 if (browser_plugin_guest_ && |
| 1572 !BrowserPluginGuestMode::UseCrossProcessFramesForGuests()) { | 1572 (browser_plugin_guest_->is_mime_handler_view_guest() || |
| 1573 !BrowserPluginGuestMode::UseCrossProcessFramesForGuests())) { | |
|
lfg
2016/09/02 18:29:40
Can we write this as (browser_plugin_guest_ && !gu
EhsanK
2016/09/02 21:01:06
Yes. Thanks.
| |
| 1573 view_.reset(new WebContentsViewGuest(this, browser_plugin_guest_.get(), | 1574 view_.reset(new WebContentsViewGuest(this, browser_plugin_guest_.get(), |
| 1574 std::move(view_), | 1575 std::move(view_), |
| 1575 &render_view_host_delegate_view_)); | 1576 &render_view_host_delegate_view_)); |
| 1576 } | 1577 } |
| 1577 CHECK(render_view_host_delegate_view_); | 1578 CHECK(render_view_host_delegate_view_); |
| 1578 CHECK(view_.get()); | 1579 CHECK(view_.get()); |
| 1579 | 1580 |
| 1580 gfx::Size initial_size = params.initial_size; | 1581 gfx::Size initial_size = params.initial_size; |
| 1581 view_->CreateView(initial_size, params.context); | 1582 view_->CreateView(initial_size, params.context); |
| 1582 | 1583 |
| (...skipping 2609 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4192 return delegate_->GetRootWindowResizerRect(); | 4193 return delegate_->GetRootWindowResizerRect(); |
| 4193 return gfx::Rect(); | 4194 return gfx::Rect(); |
| 4194 } | 4195 } |
| 4195 | 4196 |
| 4196 void WebContentsImpl::RemoveBrowserPluginEmbedder() { | 4197 void WebContentsImpl::RemoveBrowserPluginEmbedder() { |
| 4197 if (browser_plugin_embedder_) | 4198 if (browser_plugin_embedder_) |
| 4198 browser_plugin_embedder_.reset(); | 4199 browser_plugin_embedder_.reset(); |
| 4199 } | 4200 } |
| 4200 | 4201 |
| 4201 WebContentsImpl* WebContentsImpl::GetOuterWebContents() { | 4202 WebContentsImpl* WebContentsImpl::GetOuterWebContents() { |
| 4202 if (BrowserPluginGuestMode::UseCrossProcessFramesForGuests()) { | 4203 if (guest_mode::IsCrossProcessFrameGuest(this) && node_) |
| 4203 if (node_) | 4204 return node_->outer_web_contents(); |
| 4204 return node_->outer_web_contents(); | 4205 |
| 4205 } else { | 4206 if (browser_plugin_guest_) |
| 4206 if (GetBrowserPluginGuest()) | 4207 return browser_plugin_guest_->embedder_web_contents(); |
| 4207 return GetBrowserPluginGuest()->embedder_web_contents(); | 4208 |
| 4208 } | |
| 4209 return nullptr; | 4209 return nullptr; |
| 4210 } | 4210 } |
| 4211 | 4211 |
| 4212 WebContentsImpl* WebContentsImpl::GetFocusedWebContents() { | 4212 WebContentsImpl* WebContentsImpl::GetFocusedWebContents() { |
| 4213 // There is no inner or outer web contents. | 4213 // There is no inner or outer web contents. |
| 4214 if (!node_ && !GetBrowserPluginGuest()) | 4214 if (!node_ && !GetBrowserPluginGuest()) |
| 4215 return this; | 4215 return this; |
| 4216 | 4216 |
| 4217 // We may need to create a node_ on the outermost contents in the | 4217 // We may need to create a node_ on the outermost contents in the |
| 4218 // BrowserPlugin case. | 4218 // BrowserPlugin case. |
| (...skipping 409 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4628 | 4628 |
| 4629 void WebContentsImpl::EnsureOpenerProxiesExist(RenderFrameHost* source_rfh) { | 4629 void WebContentsImpl::EnsureOpenerProxiesExist(RenderFrameHost* source_rfh) { |
| 4630 WebContentsImpl* source_web_contents = static_cast<WebContentsImpl*>( | 4630 WebContentsImpl* source_web_contents = static_cast<WebContentsImpl*>( |
| 4631 WebContents::FromRenderFrameHost(source_rfh)); | 4631 WebContents::FromRenderFrameHost(source_rfh)); |
| 4632 | 4632 |
| 4633 if (source_web_contents) { | 4633 if (source_web_contents) { |
| 4634 // If this message is going to outer WebContents from inner WebContents, | 4634 // If this message is going to outer WebContents from inner WebContents, |
| 4635 // then we should not create a RenderView. AttachToOuterWebContentsFrame() | 4635 // then we should not create a RenderView. AttachToOuterWebContentsFrame() |
| 4636 // already created a RenderFrameProxyHost for that purpose. | 4636 // already created a RenderFrameProxyHost for that purpose. |
| 4637 if (GetBrowserPluginEmbedder() && | 4637 if (GetBrowserPluginEmbedder() && |
| 4638 BrowserPluginGuestMode::UseCrossProcessFramesForGuests()) { | 4638 guest_mode::IsCrossProcessFrameGuest(source_web_contents)) { |
| 4639 return; | 4639 return; |
| 4640 } | 4640 } |
| 4641 | 4641 |
| 4642 if (this != source_web_contents && GetBrowserPluginGuest()) { | 4642 if (this != source_web_contents && GetBrowserPluginGuest()) { |
| 4643 // We create a RenderFrameProxyHost for the embedder in the guest's render | 4643 // We create a RenderFrameProxyHost for the embedder in the guest's render |
| 4644 // process but we intentionally do not expose the embedder's opener chain | 4644 // process but we intentionally do not expose the embedder's opener chain |
| 4645 // to it. | 4645 // to it. |
| 4646 source_web_contents->GetRenderManager()->CreateRenderFrameProxy( | 4646 source_web_contents->GetRenderManager()->CreateRenderFrameProxy( |
| 4647 GetSiteInstance()); | 4647 GetSiteInstance()); |
| 4648 } else { | 4648 } else { |
| (...skipping 583 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 5232 for (RenderViewHost* render_view_host : render_view_host_set) | 5232 for (RenderViewHost* render_view_host : render_view_host_set) |
| 5233 render_view_host->OnWebkitPreferencesChanged(); | 5233 render_view_host->OnWebkitPreferencesChanged(); |
| 5234 } | 5234 } |
| 5235 | 5235 |
| 5236 void WebContentsImpl::SetJavaScriptDialogManagerForTesting( | 5236 void WebContentsImpl::SetJavaScriptDialogManagerForTesting( |
| 5237 JavaScriptDialogManager* dialog_manager) { | 5237 JavaScriptDialogManager* dialog_manager) { |
| 5238 dialog_manager_ = dialog_manager; | 5238 dialog_manager_ = dialog_manager; |
| 5239 } | 5239 } |
| 5240 | 5240 |
| 5241 } // namespace content | 5241 } // namespace content |
| OLD | NEW |