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

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

Issue 2679513002: Track the original opener of a webcontents so we can rely on it for popups (Closed)
Patch Set: Created 3 years, 10 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
« no previous file with comments | « content/browser/web_contents/web_contents_impl.h ('k') | content/public/browser/web_contents.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 578 matching lines...) Expand 10 before | Expand all | Expand 10 after
589 } 589 }
590 590
591 WebContentsImpl* WebContentsImpl::CreateWithOpener( 591 WebContentsImpl* WebContentsImpl::CreateWithOpener(
592 const WebContents::CreateParams& params, 592 const WebContents::CreateParams& params,
593 FrameTreeNode* opener) { 593 FrameTreeNode* opener) {
594 TRACE_EVENT0("browser", "WebContentsImpl::CreateWithOpener"); 594 TRACE_EVENT0("browser", "WebContentsImpl::CreateWithOpener");
595 WebContentsImpl* new_contents = new WebContentsImpl(params.browser_context); 595 WebContentsImpl* new_contents = new WebContentsImpl(params.browser_context);
596 596
597 FrameTreeNode* new_root = new_contents->GetFrameTree()->root(); 597 FrameTreeNode* new_root = new_contents->GetFrameTree()->root();
598 598
599 if (!params.opener_suppressed && opener) { 599 if (opener) {
600 new_root->SetOpener(opener); 600 new_root->SetOriginalOpener(opener);
601 new_contents->created_with_opener_ = true; 601 if (!params.opener_suppressed) {
602 new_root->SetOpener(opener);
603 new_contents->created_with_opener_ = true;
604 }
602 } 605 }
603 606
604 // If the opener is sandboxed, a new popup must inherit the opener's sandbox 607 // If the opener is sandboxed, a new popup must inherit the opener's sandbox
605 // flags, and these flags take effect immediately. An exception is if the 608 // flags, and these flags take effect immediately. An exception is if the
606 // opener's sandbox flags lack the PropagatesToAuxiliaryBrowsingContexts 609 // opener's sandbox flags lack the PropagatesToAuxiliaryBrowsingContexts
607 // bit (which is controlled by the "allow-popups-to-escape-sandbox" token). 610 // bit (which is controlled by the "allow-popups-to-escape-sandbox" token).
608 // See https://html.spec.whatwg.org/#attr-iframe-sandbox. 611 // See https://html.spec.whatwg.org/#attr-iframe-sandbox.
609 if (opener) { 612 if (opener) {
610 blink::WebSandboxFlags opener_flags = opener->effective_sandbox_flags(); 613 blink::WebSandboxFlags opener_flags = opener->effective_sandbox_flags();
611 const blink::WebSandboxFlags inherit_flag = 614 const blink::WebSandboxFlags inherit_flag =
(...skipping 2501 matching lines...) Expand 10 before | Expand all | Expand 10 after
3113 3116
3114 bool WebContentsImpl::HasOpener() const { 3117 bool WebContentsImpl::HasOpener() const {
3115 return GetOpener() != NULL; 3118 return GetOpener() != NULL;
3116 } 3119 }
3117 3120
3118 WebContentsImpl* WebContentsImpl::GetOpener() const { 3121 WebContentsImpl* WebContentsImpl::GetOpener() const {
3119 FrameTreeNode* opener_ftn = frame_tree_.root()->opener(); 3122 FrameTreeNode* opener_ftn = frame_tree_.root()->opener();
3120 return opener_ftn ? FromFrameTreeNode(opener_ftn) : nullptr; 3123 return opener_ftn ? FromFrameTreeNode(opener_ftn) : nullptr;
3121 } 3124 }
3122 3125
3126 bool WebContentsImpl::HasOriginalOpener() const {
3127 return GetOriginalOpener() != NULL;
3128 }
3129
3130 WebContents* WebContentsImpl::GetOriginalOpener() const {
3131 FrameTreeNode* opener_ftn = frame_tree_.root()->original_opener();
3132 return opener_ftn ? FromFrameTreeNode(opener_ftn) : nullptr;
3133 }
3134
3123 void WebContentsImpl::DidChooseColorInColorChooser(SkColor color) { 3135 void WebContentsImpl::DidChooseColorInColorChooser(SkColor color) {
3124 if (!color_chooser_info_.get()) 3136 if (!color_chooser_info_.get())
3125 return; 3137 return;
3126 RenderFrameHost* rfh = RenderFrameHost::FromID( 3138 RenderFrameHost* rfh = RenderFrameHost::FromID(
3127 color_chooser_info_->render_process_id, 3139 color_chooser_info_->render_process_id,
3128 color_chooser_info_->render_frame_id); 3140 color_chooser_info_->render_frame_id);
3129 if (!rfh) 3141 if (!rfh)
3130 return; 3142 return;
3131 3143
3132 rfh->Send(new FrameMsg_DidChooseColorResponse( 3144 rfh->Send(new FrameMsg_DidChooseColorResponse(
(...skipping 2288 matching lines...) Expand 10 before | Expand all | Expand 10 after
5421 GetMainFrame()->AddMessageToConsole( 5433 GetMainFrame()->AddMessageToConsole(
5422 content::CONSOLE_MESSAGE_LEVEL_WARNING, 5434 content::CONSOLE_MESSAGE_LEVEL_WARNING,
5423 base::StringPrintf("This site does not have a valid SSL " 5435 base::StringPrintf("This site does not have a valid SSL "
5424 "certificate! Without SSL, your site's and " 5436 "certificate! Without SSL, your site's and "
5425 "visitors' data is vulnerable to theft and " 5437 "visitors' data is vulnerable to theft and "
5426 "tampering. Get a valid SSL certificate before" 5438 "tampering. Get a valid SSL certificate before"
5427 " releasing your website to the public.")); 5439 " releasing your website to the public."));
5428 } 5440 }
5429 5441
5430 } // namespace content 5442 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/web_contents/web_contents_impl.h ('k') | content/public/browser/web_contents.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698