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" |
(...skipping 1292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1396 } | 1397 } |
1397 | 1398 |
1398 void WebContentsImpl::DispatchBeforeUnload() { | 1399 void WebContentsImpl::DispatchBeforeUnload() { |
1399 bool for_cross_site_transition = false; | 1400 bool for_cross_site_transition = false; |
1400 GetMainFrame()->DispatchBeforeUnload(for_cross_site_transition, false); | 1401 GetMainFrame()->DispatchBeforeUnload(for_cross_site_transition, false); |
1401 } | 1402 } |
1402 | 1403 |
1403 void WebContentsImpl::AttachToOuterWebContentsFrame( | 1404 void WebContentsImpl::AttachToOuterWebContentsFrame( |
1404 WebContents* outer_web_contents, | 1405 WebContents* outer_web_contents, |
1405 RenderFrameHost* outer_contents_frame) { | 1406 RenderFrameHost* outer_contents_frame) { |
1406 CHECK(BrowserPluginGuestMode::UseCrossProcessFramesForGuests()); | 1407 CHECK(guest_mode::IsCrossProcessFrameGuest(this)); |
1407 RenderFrameHostManager* render_manager = GetRenderManager(); | 1408 RenderFrameHostManager* render_manager = GetRenderManager(); |
1408 | 1409 |
1409 // When the WebContents being initialized has an opener, the browser side | 1410 // When the WebContents being initialized has an opener, the browser side |
1410 // Render{View,Frame}Host must be initialized and the RenderWidgetHostView | 1411 // Render{View,Frame}Host must be initialized and the RenderWidgetHostView |
1411 // created. This is needed because the usual initialization happens during | 1412 // created. This is needed because the usual initialization happens during |
1412 // the first navigation, but when attaching a new window we don't navigate | 1413 // 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 | 1414 // before attaching. If the browser side is already initialized, the calls |
1414 // below will just early return. | 1415 // below will just early return. |
1415 render_manager->InitRenderView(GetRenderViewHost(), nullptr); | 1416 render_manager->InitRenderView(GetRenderViewHost(), nullptr); |
1416 GetMainFrame()->Init(); | 1417 GetMainFrame()->Init(); |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1552 switches::kUseMusInRenderer)) { | 1553 switches::kUseMusInRenderer)) { |
1553 ui::Window* mus_window = aura::GetMusWindow(params.context); | 1554 ui::Window* mus_window = aura::GetMusWindow(params.context); |
1554 if (mus_window) { | 1555 if (mus_window) { |
1555 view_.reset(new WebContentsViewMus(mus_window, this, delegate, | 1556 view_.reset(new WebContentsViewMus(mus_window, this, delegate, |
1556 &render_view_host_delegate_view_)); | 1557 &render_view_host_delegate_view_)); |
1557 } | 1558 } |
1558 } | 1559 } |
1559 #endif | 1560 #endif |
1560 | 1561 |
1561 if (!view_) { | 1562 if (!view_) { |
1562 if (browser_plugin_guest_ && | 1563 if (guest_mode::IsCrossProcessFrameGuest(this)) { |
1563 BrowserPluginGuestMode::UseCrossProcessFramesForGuests()) { | |
1564 view_.reset(new WebContentsViewChildFrame( | 1564 view_.reset(new WebContentsViewChildFrame( |
1565 this, delegate, &render_view_host_delegate_view_)); | 1565 this, delegate, &render_view_host_delegate_view_)); |
1566 } else { | 1566 } else { |
1567 view_.reset(CreateWebContentsView(this, delegate, | 1567 view_.reset(CreateWebContentsView(this, delegate, |
1568 &render_view_host_delegate_view_)); | 1568 &render_view_host_delegate_view_)); |
1569 } | 1569 } |
1570 } | 1570 } |
1571 | 1571 |
1572 if (browser_plugin_guest_ && | 1572 if (browser_plugin_guest_ && |
Charlie Reis
2016/09/07 00:22:29
Why does this still have the browser_plugin_guest_
EhsanK
2016/09/08 18:14:58
The null check is inherent to the method call. So
Charlie Reis
2016/09/15 20:56:10
That doesn't answer why line 1563 is missing the n
EhsanK
2016/09/21 21:34:53
On line 1563, the call to guest_mode::IsCrossProce
Charlie Reis
2016/09/21 22:18:21
Oh, I see now. Thanks.
| |
1573 !BrowserPluginGuestMode::UseCrossProcessFramesForGuests()) { | 1573 !guest_mode::IsCrossProcessFrameGuest(this)) { |
1574 view_.reset(new WebContentsViewGuest(this, browser_plugin_guest_.get(), | 1574 view_.reset(new WebContentsViewGuest(this, browser_plugin_guest_.get(), |
1575 std::move(view_), | 1575 std::move(view_), |
1576 &render_view_host_delegate_view_)); | 1576 &render_view_host_delegate_view_)); |
1577 } | 1577 } |
1578 CHECK(render_view_host_delegate_view_); | 1578 CHECK(render_view_host_delegate_view_); |
1579 CHECK(view_.get()); | 1579 CHECK(view_.get()); |
1580 | 1580 |
1581 gfx::Size initial_size = params.initial_size; | 1581 gfx::Size initial_size = params.initial_size; |
1582 view_->CreateView(initial_size, params.context); | 1582 view_->CreateView(initial_size, params.context); |
1583 | 1583 |
(...skipping 2584 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4168 return delegate_->GetRootWindowResizerRect(); | 4168 return delegate_->GetRootWindowResizerRect(); |
4169 return gfx::Rect(); | 4169 return gfx::Rect(); |
4170 } | 4170 } |
4171 | 4171 |
4172 void WebContentsImpl::RemoveBrowserPluginEmbedder() { | 4172 void WebContentsImpl::RemoveBrowserPluginEmbedder() { |
4173 if (browser_plugin_embedder_) | 4173 if (browser_plugin_embedder_) |
4174 browser_plugin_embedder_.reset(); | 4174 browser_plugin_embedder_.reset(); |
4175 } | 4175 } |
4176 | 4176 |
4177 WebContentsImpl* WebContentsImpl::GetOuterWebContents() { | 4177 WebContentsImpl* WebContentsImpl::GetOuterWebContents() { |
4178 if (BrowserPluginGuestMode::UseCrossProcessFramesForGuests()) { | 4178 if (guest_mode::IsCrossProcessFrameGuest(this) && node_) |
4179 if (node_) | 4179 return node_->outer_web_contents(); |
4180 return node_->outer_web_contents(); | 4180 |
4181 } else { | 4181 if (browser_plugin_guest_) |
4182 if (GetBrowserPluginGuest()) | 4182 return browser_plugin_guest_->embedder_web_contents(); |
4183 return GetBrowserPluginGuest()->embedder_web_contents(); | 4183 |
4184 } | |
4185 return nullptr; | 4184 return nullptr; |
4186 } | 4185 } |
4187 | 4186 |
4188 WebContentsImpl* WebContentsImpl::GetFocusedWebContents() { | 4187 WebContentsImpl* WebContentsImpl::GetFocusedWebContents() { |
4189 // There is no inner or outer web contents. | 4188 // There is no inner or outer web contents. |
4190 if (!node_ && !GetBrowserPluginGuest()) | 4189 if (!node_ && !GetBrowserPluginGuest()) |
4191 return this; | 4190 return this; |
4192 | 4191 |
4193 // We may need to create a node_ on the outermost contents in the | 4192 // We may need to create a node_ on the outermost contents in the |
4194 // BrowserPlugin case. | 4193 // BrowserPlugin case. |
(...skipping 409 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4604 | 4603 |
4605 void WebContentsImpl::EnsureOpenerProxiesExist(RenderFrameHost* source_rfh) { | 4604 void WebContentsImpl::EnsureOpenerProxiesExist(RenderFrameHost* source_rfh) { |
4606 WebContentsImpl* source_web_contents = static_cast<WebContentsImpl*>( | 4605 WebContentsImpl* source_web_contents = static_cast<WebContentsImpl*>( |
4607 WebContents::FromRenderFrameHost(source_rfh)); | 4606 WebContents::FromRenderFrameHost(source_rfh)); |
4608 | 4607 |
4609 if (source_web_contents) { | 4608 if (source_web_contents) { |
4610 // If this message is going to outer WebContents from inner WebContents, | 4609 // If this message is going to outer WebContents from inner WebContents, |
4611 // then we should not create a RenderView. AttachToOuterWebContentsFrame() | 4610 // then we should not create a RenderView. AttachToOuterWebContentsFrame() |
4612 // already created a RenderFrameProxyHost for that purpose. | 4611 // already created a RenderFrameProxyHost for that purpose. |
4613 if (GetBrowserPluginEmbedder() && | 4612 if (GetBrowserPluginEmbedder() && |
4614 BrowserPluginGuestMode::UseCrossProcessFramesForGuests()) { | 4613 guest_mode::IsCrossProcessFrameGuest(source_web_contents)) { |
4615 return; | 4614 return; |
4616 } | 4615 } |
4617 | 4616 |
4618 if (this != source_web_contents && GetBrowserPluginGuest()) { | 4617 if (this != source_web_contents && GetBrowserPluginGuest()) { |
4619 // We create a RenderFrameProxyHost for the embedder in the guest's render | 4618 // We create a RenderFrameProxyHost for the embedder in the guest's render |
4620 // process but we intentionally do not expose the embedder's opener chain | 4619 // process but we intentionally do not expose the embedder's opener chain |
4621 // to it. | 4620 // to it. |
4622 source_web_contents->GetRenderManager()->CreateRenderFrameProxy( | 4621 source_web_contents->GetRenderManager()->CreateRenderFrameProxy( |
4623 GetSiteInstance()); | 4622 GetSiteInstance()); |
4624 } else { | 4623 } else { |
(...skipping 580 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5205 for (RenderViewHost* render_view_host : render_view_host_set) | 5204 for (RenderViewHost* render_view_host : render_view_host_set) |
5206 render_view_host->OnWebkitPreferencesChanged(); | 5205 render_view_host->OnWebkitPreferencesChanged(); |
5207 } | 5206 } |
5208 | 5207 |
5209 void WebContentsImpl::SetJavaScriptDialogManagerForTesting( | 5208 void WebContentsImpl::SetJavaScriptDialogManagerForTesting( |
5210 JavaScriptDialogManager* dialog_manager) { | 5209 JavaScriptDialogManager* dialog_manager) { |
5211 dialog_manager_ = dialog_manager; | 5210 dialog_manager_ = dialog_manager; |
5212 } | 5211 } |
5213 | 5212 |
5214 } // namespace content | 5213 } // namespace content |
OLD | NEW |