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

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

Issue 2661403003: Track the original opener of a webcontents so we can rely on it for popups (Closed)
Patch Set: typo 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 575 matching lines...) Expand 10 before | Expand all | Expand 10 after
586 } 586 }
587 587
588 WebContentsImpl* WebContentsImpl::CreateWithOpener( 588 WebContentsImpl* WebContentsImpl::CreateWithOpener(
589 const WebContents::CreateParams& params, 589 const WebContents::CreateParams& params,
590 FrameTreeNode* opener) { 590 FrameTreeNode* opener) {
591 TRACE_EVENT0("browser", "WebContentsImpl::CreateWithOpener"); 591 TRACE_EVENT0("browser", "WebContentsImpl::CreateWithOpener");
592 WebContentsImpl* new_contents = new WebContentsImpl(params.browser_context); 592 WebContentsImpl* new_contents = new WebContentsImpl(params.browser_context);
593 593
594 FrameTreeNode* new_root = new_contents->GetFrameTree()->root(); 594 FrameTreeNode* new_root = new_contents->GetFrameTree()->root();
595 595
596 if (!params.opener_suppressed && opener) { 596 if (opener) {
597 new_root->SetOpener(opener); 597 new_root->SetOriginalOpener(opener);
598 new_contents->created_with_opener_ = true; 598 if (!params.opener_suppressed) {
599 new_root->SetOpener(opener);
600 new_contents->created_with_opener_ = true;
601 }
599 } 602 }
600 603
601 // If the opener is sandboxed, a new popup must inherit the opener's sandbox 604 // If the opener is sandboxed, a new popup must inherit the opener's sandbox
602 // flags, and these flags take effect immediately. An exception is if the 605 // flags, and these flags take effect immediately. An exception is if the
603 // opener's sandbox flags lack the PropagatesToAuxiliaryBrowsingContexts 606 // opener's sandbox flags lack the PropagatesToAuxiliaryBrowsingContexts
604 // bit (which is controlled by the "allow-popups-to-escape-sandbox" token). 607 // bit (which is controlled by the "allow-popups-to-escape-sandbox" token).
605 // See https://html.spec.whatwg.org/#attr-iframe-sandbox. 608 // See https://html.spec.whatwg.org/#attr-iframe-sandbox.
606 if (opener) { 609 if (opener) {
607 blink::WebSandboxFlags opener_flags = opener->effective_sandbox_flags(); 610 blink::WebSandboxFlags opener_flags = opener->effective_sandbox_flags();
608 const blink::WebSandboxFlags inherit_flag = 611 const blink::WebSandboxFlags inherit_flag =
(...skipping 2499 matching lines...) Expand 10 before | Expand all | Expand 10 after
3108 3111
3109 bool WebContentsImpl::HasOpener() const { 3112 bool WebContentsImpl::HasOpener() const {
3110 return GetOpener() != NULL; 3113 return GetOpener() != NULL;
3111 } 3114 }
3112 3115
3113 WebContentsImpl* WebContentsImpl::GetOpener() const { 3116 WebContentsImpl* WebContentsImpl::GetOpener() const {
3114 FrameTreeNode* opener_ftn = frame_tree_.root()->opener(); 3117 FrameTreeNode* opener_ftn = frame_tree_.root()->opener();
3115 return opener_ftn ? FromFrameTreeNode(opener_ftn) : nullptr; 3118 return opener_ftn ? FromFrameTreeNode(opener_ftn) : nullptr;
3116 } 3119 }
3117 3120
3121 bool WebContentsImpl::HasOriginalOpener() const {
3122 return GetOriginalOpener() != NULL;
3123 }
3124
3125 WebContents* WebContentsImpl::GetOriginalOpener() const {
3126 FrameTreeNode* opener_ftn = frame_tree_.root()->original_opener();
3127 return opener_ftn ? FromFrameTreeNode(opener_ftn) : nullptr;
3128 }
3129
3118 void WebContentsImpl::DidChooseColorInColorChooser(SkColor color) { 3130 void WebContentsImpl::DidChooseColorInColorChooser(SkColor color) {
3119 if (!color_chooser_info_.get()) 3131 if (!color_chooser_info_.get())
3120 return; 3132 return;
3121 RenderFrameHost* rfh = RenderFrameHost::FromID( 3133 RenderFrameHost* rfh = RenderFrameHost::FromID(
3122 color_chooser_info_->render_process_id, 3134 color_chooser_info_->render_process_id,
3123 color_chooser_info_->render_frame_id); 3135 color_chooser_info_->render_frame_id);
3124 if (!rfh) 3136 if (!rfh)
3125 return; 3137 return;
3126 3138
3127 rfh->Send(new FrameMsg_DidChooseColorResponse( 3139 rfh->Send(new FrameMsg_DidChooseColorResponse(
(...skipping 2262 matching lines...) Expand 10 before | Expand all | Expand 10 after
5390 GetMainFrame()->AddMessageToConsole( 5402 GetMainFrame()->AddMessageToConsole(
5391 content::CONSOLE_MESSAGE_LEVEL_WARNING, 5403 content::CONSOLE_MESSAGE_LEVEL_WARNING,
5392 base::StringPrintf("This site does not have a valid SSL " 5404 base::StringPrintf("This site does not have a valid SSL "
5393 "certificate! Without SSL, your site's and " 5405 "certificate! Without SSL, your site's and "
5394 "visitors' data is vulnerable to theft and " 5406 "visitors' data is vulnerable to theft and "
5395 "tampering. Get a valid SSL certificate before" 5407 "tampering. Get a valid SSL certificate before"
5396 " releasing your website to the public.")); 5408 " releasing your website to the public."));
5397 } 5409 }
5398 5410
5399 } // namespace content 5411 } // 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