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 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
84 #include "content/common/page_state_serialization.h" | 84 #include "content/common/page_state_serialization.h" |
85 #include "content/common/site_isolation_policy.h" | 85 #include "content/common/site_isolation_policy.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_manager.h" | 89 #include "content/public/browser/browser_plugin_guest_manager.h" |
90 #include "content/public/browser/content_browser_client.h" | 90 #include "content/public/browser/content_browser_client.h" |
91 #include "content/public/browser/devtools_agent_host.h" | 91 #include "content/public/browser/devtools_agent_host.h" |
92 #include "content/public/browser/download_manager.h" | 92 #include "content/public/browser/download_manager.h" |
93 #include "content/public/browser/download_url_parameters.h" | 93 #include "content/public/browser/download_url_parameters.h" |
| 94 #include "content/public/browser/guest_mode.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_notification_details.h" | 97 #include "content/public/browser/load_notification_details.h" |
97 #include "content/public/browser/navigation_details.h" | 98 #include "content/public/browser/navigation_details.h" |
98 #include "content/public/browser/notification_details.h" | 99 #include "content/public/browser/notification_details.h" |
99 #include "content/public/browser/notification_service.h" | 100 #include "content/public/browser/notification_service.h" |
100 #include "content/public/browser/notification_types.h" | 101 #include "content/public/browser/notification_types.h" |
101 #include "content/public/browser/render_widget_host_iterator.h" | 102 #include "content/public/browser/render_widget_host_iterator.h" |
102 #include "content/public/browser/resource_request_details.h" | 103 #include "content/public/browser/resource_request_details.h" |
103 #include "content/public/browser/screen_orientation_dispatcher_host.h" | 104 #include "content/public/browser/screen_orientation_dispatcher_host.h" |
104 #include "content/public/browser/security_style_explanations.h" | 105 #include "content/public/browser/security_style_explanations.h" |
105 #include "content/public/browser/storage_partition.h" | 106 #include "content/public/browser/storage_partition.h" |
106 #include "content/public/browser/user_metrics.h" | 107 #include "content/public/browser/user_metrics.h" |
107 #include "content/public/browser/web_contents_delegate.h" | 108 #include "content/public/browser/web_contents_delegate.h" |
108 #include "content/public/common/bindings_policy.h" | 109 #include "content/public/common/bindings_policy.h" |
109 #include "content/public/common/browser_plugin_guest_mode.h" | |
110 #include "content/public/common/browser_side_navigation_policy.h" | 110 #include "content/public/common/browser_side_navigation_policy.h" |
111 #include "content/public/common/child_process_host.h" | 111 #include "content/public/common/child_process_host.h" |
112 #include "content/public/common/content_constants.h" | 112 #include "content/public/common/content_constants.h" |
113 #include "content/public/common/content_switches.h" | 113 #include "content/public/common/content_switches.h" |
114 #include "content/public/common/page_zoom.h" | 114 #include "content/public/common/page_zoom.h" |
115 #include "content/public/common/result_codes.h" | 115 #include "content/public/common/result_codes.h" |
116 #include "content/public/common/url_constants.h" | 116 #include "content/public/common/url_constants.h" |
117 #include "content/public/common/url_utils.h" | 117 #include "content/public/common/url_utils.h" |
118 #include "content/public/common/web_preferences.h" | 118 #include "content/public/common/web_preferences.h" |
119 #include "device/geolocation/geolocation_service_context.h" | 119 #include "device/geolocation/geolocation_service_context.h" |
(...skipping 1276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1396 } | 1396 } |
1397 | 1397 |
1398 void WebContentsImpl::DispatchBeforeUnload() { | 1398 void WebContentsImpl::DispatchBeforeUnload() { |
1399 bool for_cross_site_transition = false; | 1399 bool for_cross_site_transition = false; |
1400 GetMainFrame()->DispatchBeforeUnload(for_cross_site_transition, false); | 1400 GetMainFrame()->DispatchBeforeUnload(for_cross_site_transition, false); |
1401 } | 1401 } |
1402 | 1402 |
1403 void WebContentsImpl::AttachToOuterWebContentsFrame( | 1403 void WebContentsImpl::AttachToOuterWebContentsFrame( |
1404 WebContents* outer_web_contents, | 1404 WebContents* outer_web_contents, |
1405 RenderFrameHost* outer_contents_frame) { | 1405 RenderFrameHost* outer_contents_frame) { |
1406 CHECK(BrowserPluginGuestMode::UseCrossProcessFramesForGuests()); | 1406 CHECK(GuestMode::IsCrossProcessFrameGuest(this)); |
1407 RenderFrameHostManager* render_manager = GetRenderManager(); | 1407 RenderFrameHostManager* render_manager = GetRenderManager(); |
1408 | 1408 |
1409 // When the WebContents being initialized has an opener, the browser side | 1409 // When the WebContents being initialized has an opener, the browser side |
1410 // Render{View,Frame}Host must be initialized and the RenderWidgetHostView | 1410 // Render{View,Frame}Host must be initialized and the RenderWidgetHostView |
1411 // created. This is needed because the usual initialization happens during | 1411 // created. This is needed because the usual initialization happens during |
1412 // 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 |
1413 // before attaching. If the browser side is already initialized, the calls | 1413 // before attaching. If the browser side is already initialized, the calls |
1414 // below will just early return. | 1414 // below will just early return. |
1415 render_manager->InitRenderView(GetRenderViewHost(), nullptr); | 1415 render_manager->InitRenderView(GetRenderViewHost(), nullptr); |
1416 GetMainFrame()->Init(); | 1416 GetMainFrame()->Init(); |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1552 switches::kUseMusInRenderer)) { | 1552 switches::kUseMusInRenderer)) { |
1553 ui::Window* mus_window = aura::GetMusWindow(params.context); | 1553 ui::Window* mus_window = aura::GetMusWindow(params.context); |
1554 if (mus_window) { | 1554 if (mus_window) { |
1555 view_.reset(new WebContentsViewMus(mus_window, this, delegate, | 1555 view_.reset(new WebContentsViewMus(mus_window, this, delegate, |
1556 &render_view_host_delegate_view_)); | 1556 &render_view_host_delegate_view_)); |
1557 } | 1557 } |
1558 } | 1558 } |
1559 #endif | 1559 #endif |
1560 | 1560 |
1561 if (!view_) { | 1561 if (!view_) { |
1562 if (browser_plugin_guest_ && | 1562 if (GuestMode::IsCrossProcessFrameGuest(this)) { |
1563 BrowserPluginGuestMode::UseCrossProcessFramesForGuests()) { | |
1564 view_.reset(new WebContentsViewChildFrame( | 1563 view_.reset(new WebContentsViewChildFrame( |
1565 this, delegate, &render_view_host_delegate_view_)); | 1564 this, delegate, &render_view_host_delegate_view_)); |
1566 } else { | 1565 } else { |
1567 view_.reset(CreateWebContentsView(this, delegate, | 1566 view_.reset(CreateWebContentsView(this, delegate, |
1568 &render_view_host_delegate_view_)); | 1567 &render_view_host_delegate_view_)); |
1569 } | 1568 } |
1570 } | 1569 } |
1571 | 1570 |
1572 if (browser_plugin_guest_ && | 1571 if (browser_plugin_guest_ && !GuestMode::IsCrossProcessFrameGuest(this)) { |
1573 !BrowserPluginGuestMode::UseCrossProcessFramesForGuests()) { | |
1574 view_.reset(new WebContentsViewGuest(this, browser_plugin_guest_.get(), | 1572 view_.reset(new WebContentsViewGuest(this, browser_plugin_guest_.get(), |
1575 std::move(view_), | 1573 std::move(view_), |
1576 &render_view_host_delegate_view_)); | 1574 &render_view_host_delegate_view_)); |
1577 } | 1575 } |
1578 CHECK(render_view_host_delegate_view_); | 1576 CHECK(render_view_host_delegate_view_); |
1579 CHECK(view_.get()); | 1577 CHECK(view_.get()); |
1580 | 1578 |
1581 gfx::Size initial_size = params.initial_size; | 1579 gfx::Size initial_size = params.initial_size; |
1582 view_->CreateView(initial_size, params.context); | 1580 view_->CreateView(initial_size, params.context); |
1583 | 1581 |
(...skipping 2604 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4188 return delegate_->GetRootWindowResizerRect(); | 4186 return delegate_->GetRootWindowResizerRect(); |
4189 return gfx::Rect(); | 4187 return gfx::Rect(); |
4190 } | 4188 } |
4191 | 4189 |
4192 void WebContentsImpl::RemoveBrowserPluginEmbedder() { | 4190 void WebContentsImpl::RemoveBrowserPluginEmbedder() { |
4193 if (browser_plugin_embedder_) | 4191 if (browser_plugin_embedder_) |
4194 browser_plugin_embedder_.reset(); | 4192 browser_plugin_embedder_.reset(); |
4195 } | 4193 } |
4196 | 4194 |
4197 WebContentsImpl* WebContentsImpl::GetOuterWebContents() { | 4195 WebContentsImpl* WebContentsImpl::GetOuterWebContents() { |
4198 if (BrowserPluginGuestMode::UseCrossProcessFramesForGuests()) { | 4196 if (GuestMode::IsCrossProcessFrameGuest(this) && node_) |
4199 if (node_) | 4197 return node_->outer_web_contents(); |
4200 return node_->outer_web_contents(); | 4198 |
4201 } else { | 4199 if (browser_plugin_guest_) |
4202 if (GetBrowserPluginGuest()) | 4200 return browser_plugin_guest_->embedder_web_contents(); |
4203 return GetBrowserPluginGuest()->embedder_web_contents(); | 4201 |
4204 } | |
4205 return nullptr; | 4202 return nullptr; |
4206 } | 4203 } |
4207 | 4204 |
4208 WebContentsImpl* WebContentsImpl::GetFocusedWebContents() { | 4205 WebContentsImpl* WebContentsImpl::GetFocusedWebContents() { |
4209 // There is no inner or outer web contents. | 4206 // There is no inner or outer web contents. |
4210 if (!node_ && !GetBrowserPluginGuest()) | 4207 if (!node_ && !GetBrowserPluginGuest()) |
4211 return this; | 4208 return this; |
4212 | 4209 |
4213 // We may need to create a node_ on the outermost contents in the | 4210 // We may need to create a node_ on the outermost contents in the |
4214 // BrowserPlugin case. | 4211 // BrowserPlugin case. |
(...skipping 409 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4624 | 4621 |
4625 void WebContentsImpl::EnsureOpenerProxiesExist(RenderFrameHost* source_rfh) { | 4622 void WebContentsImpl::EnsureOpenerProxiesExist(RenderFrameHost* source_rfh) { |
4626 WebContentsImpl* source_web_contents = static_cast<WebContentsImpl*>( | 4623 WebContentsImpl* source_web_contents = static_cast<WebContentsImpl*>( |
4627 WebContents::FromRenderFrameHost(source_rfh)); | 4624 WebContents::FromRenderFrameHost(source_rfh)); |
4628 | 4625 |
4629 if (source_web_contents) { | 4626 if (source_web_contents) { |
4630 // If this message is going to outer WebContents from inner WebContents, | 4627 // If this message is going to outer WebContents from inner WebContents, |
4631 // then we should not create a RenderView. AttachToOuterWebContentsFrame() | 4628 // then we should not create a RenderView. AttachToOuterWebContentsFrame() |
4632 // already created a RenderFrameProxyHost for that purpose. | 4629 // already created a RenderFrameProxyHost for that purpose. |
4633 if (GetBrowserPluginEmbedder() && | 4630 if (GetBrowserPluginEmbedder() && |
4634 BrowserPluginGuestMode::UseCrossProcessFramesForGuests()) { | 4631 GuestMode::IsCrossProcessFrameGuest(source_web_contents)) { |
4635 return; | 4632 return; |
4636 } | 4633 } |
4637 | 4634 |
4638 if (this != source_web_contents && GetBrowserPluginGuest()) { | 4635 if (this != source_web_contents && GetBrowserPluginGuest()) { |
4639 // We create a RenderFrameProxyHost for the embedder in the guest's render | 4636 // We create a RenderFrameProxyHost for the embedder in the guest's render |
4640 // process but we intentionally do not expose the embedder's opener chain | 4637 // process but we intentionally do not expose the embedder's opener chain |
4641 // to it. | 4638 // to it. |
4642 source_web_contents->GetRenderManager()->CreateRenderFrameProxy( | 4639 source_web_contents->GetRenderManager()->CreateRenderFrameProxy( |
4643 GetSiteInstance()); | 4640 GetSiteInstance()); |
4644 } else { | 4641 } else { |
4645 RenderFrameHostImpl* source_rfhi = | 4642 RenderFrameHostImpl* source_rfhi = |
4646 static_cast<RenderFrameHostImpl*>(source_rfh); | 4643 static_cast<RenderFrameHostImpl*>(source_rfh); |
4647 source_rfhi->frame_tree_node()->render_manager()->CreateOpenerProxies( | 4644 source_rfhi->frame_tree_node()->render_manager()->CreateOpenerProxies( |
4648 GetSiteInstance(), nullptr); | 4645 GetSiteInstance(), nullptr); |
4649 } | 4646 } |
4650 } | 4647 } |
4651 } | 4648 } |
4652 | 4649 |
4653 void WebContentsImpl::SetFocusedFrame(FrameTreeNode* node, | 4650 void WebContentsImpl::SetFocusedFrame(FrameTreeNode* node, |
4654 SiteInstance* source) { | 4651 SiteInstance* source) { |
4655 if (!BrowserPluginGuestMode::UseCrossProcessFramesForGuests()) { | 4652 if (!GuestMode::IsCrossProcessFrameGuest(this) && browser_plugin_guest_) { |
4656 frame_tree_.SetFocusedFrame(node, source); | 4653 frame_tree_.SetFocusedFrame(node, source); |
4657 return; | 4654 return; |
4658 } | 4655 } |
4659 | 4656 |
4660 // 1. Find old focused frame and unfocus it. | 4657 // 1. Find old focused frame and unfocus it. |
4661 // 2. Focus the new frame in the current FrameTree. | 4658 // 2. Focus the new frame in the current FrameTree. |
4662 // 3. Set current WebContents as focused. | 4659 // 3. Set current WebContents as focused. |
4663 WebContentsImpl* old_focused_contents = GetFocusedWebContents(); | 4660 WebContentsImpl* old_focused_contents = GetFocusedWebContents(); |
4664 if (old_focused_contents != this) { | 4661 if (old_focused_contents != this) { |
4665 // Focus is moving between frame trees, unfocus the frame in the old tree. | 4662 // Focus is moving between frame trees, unfocus the frame in the old tree. |
4666 old_focused_contents->frame_tree_.SetFocusedFrame(nullptr, source); | 4663 old_focused_contents->frame_tree_.SetFocusedFrame(nullptr, source); |
4667 GetOutermostWebContents()->node_->SetFocusedWebContents(this); | 4664 GetOutermostWebContents()->node_->SetFocusedWebContents(this); |
4668 } | 4665 } |
4669 | 4666 |
4670 frame_tree_.SetFocusedFrame(node, source); | 4667 frame_tree_.SetFocusedFrame(node, source); |
4671 | 4668 |
4672 // TODO(avallee): Remove this once page focus is fixed. | 4669 // TODO(avallee): Remove this once page focus is fixed. |
4673 RenderWidgetHostImpl* rwh = node->current_frame_host()->GetRenderWidgetHost(); | 4670 RenderWidgetHostImpl* rwh = node->current_frame_host()->GetRenderWidgetHost(); |
4674 if (rwh && old_focused_contents != this && | 4671 if (rwh && old_focused_contents != this) |
4675 BrowserPluginGuestMode::UseCrossProcessFramesForGuests()) | |
4676 rwh->Focus(); | 4672 rwh->Focus(); |
4677 } | 4673 } |
4678 | 4674 |
4679 bool WebContentsImpl::AddMessageToConsole(int32_t level, | 4675 bool WebContentsImpl::AddMessageToConsole(int32_t level, |
4680 const base::string16& message, | 4676 const base::string16& message, |
4681 int32_t line_no, | 4677 int32_t line_no, |
4682 const base::string16& source_id) { | 4678 const base::string16& source_id) { |
4683 if (!delegate_) | 4679 if (!delegate_) |
4684 return false; | 4680 return false; |
4685 return delegate_->AddMessageToConsole(this, level, message, line_no, | 4681 return delegate_->AddMessageToConsole(this, level, message, line_no, |
(...skipping 517 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5203 for (RenderViewHost* render_view_host : render_view_host_set) | 5199 for (RenderViewHost* render_view_host : render_view_host_set) |
5204 render_view_host->OnWebkitPreferencesChanged(); | 5200 render_view_host->OnWebkitPreferencesChanged(); |
5205 } | 5201 } |
5206 | 5202 |
5207 void WebContentsImpl::SetJavaScriptDialogManagerForTesting( | 5203 void WebContentsImpl::SetJavaScriptDialogManagerForTesting( |
5208 JavaScriptDialogManager* dialog_manager) { | 5204 JavaScriptDialogManager* dialog_manager) { |
5209 dialog_manager_ = dialog_manager; | 5205 dialog_manager_ = dialog_manager; |
5210 } | 5206 } |
5211 | 5207 |
5212 } // namespace content | 5208 } // namespace content |
OLD | NEW |