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

Side by Side Diff: chrome/browser/ui/blocked_content/app_modal_dialog_helper.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 | « no previous file | chrome/browser/ui/blocked_content/popup_blocker_browsertest.cc » ('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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "chrome/browser/ui/blocked_content/app_modal_dialog_helper.h" 5 #include "chrome/browser/ui/blocked_content/app_modal_dialog_helper.h"
6 6
7 #include "chrome/browser/ui/browser.h" 7 #include "chrome/browser/ui/browser.h"
8 #include "chrome/browser/ui/browser_finder.h" 8 #include "chrome/browser/ui/browser_finder.h"
9 #include "chrome/browser/ui/browser_list.h" 9 #include "chrome/browser/ui/browser_list.h"
10 #include "chrome/browser/ui/tabs/tab_strip_model.h" 10 #include "chrome/browser/ui/tabs/tab_strip_model.h"
(...skipping 18 matching lines...) Expand all
29 #endif 29 #endif
30 30
31 // If the WebContents that triggered this dialog is not currently focused, we 31 // If the WebContents that triggered this dialog is not currently focused, we
32 // want to store a potential popup here to restore it after the dialog was 32 // want to store a potential popup here to restore it after the dialog was
33 // closed. 33 // closed.
34 Browser* active_browser = BrowserList::GetInstance()->GetLastActive(); 34 Browser* active_browser = BrowserList::GetInstance()->GetLastActive();
35 if (active_browser) { 35 if (active_browser) {
36 content::WebContents* active_web_contents = 36 content::WebContents* active_web_contents =
37 active_browser->tab_strip_model()->GetActiveWebContents(); 37 active_browser->tab_strip_model()->GetActiveWebContents();
38 if (active_browser->is_type_popup() && active_web_contents && 38 if (active_browser->is_type_popup() && active_web_contents &&
39 active_web_contents->GetOpener() == actual_host) { 39 active_web_contents->GetOriginalOpener() == actual_host) {
40 // It's indeed a popup from the dialog opening WebContents. Store it, so 40 // It's indeed a popup from the dialog opening WebContents. Store it, so
41 // we can focus it later. 41 // we can focus it later.
42 popup_ = active_web_contents; 42 popup_ = active_web_contents;
43 Observe(popup_); 43 Observe(popup_);
44 } 44 }
45 } 45 }
46 } 46 }
47 47
48 AppModalDialogHelper::~AppModalDialogHelper() { 48 AppModalDialogHelper::~AppModalDialogHelper() {
49 if (!popup_) 49 if (!popup_)
50 return; 50 return;
51 51
52 content::WebContentsDelegate* delegate = popup_->GetDelegate(); 52 content::WebContentsDelegate* delegate = popup_->GetDelegate();
53 if (!delegate) 53 if (!delegate)
54 return; 54 return;
55 55
56 delegate->ActivateContents(popup_); 56 delegate->ActivateContents(popup_);
57 } 57 }
58 58
59 void AppModalDialogHelper::WebContentsDestroyed() { 59 void AppModalDialogHelper::WebContentsDestroyed() {
60 popup_ = nullptr; 60 popup_ = nullptr;
61 } 61 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/ui/blocked_content/popup_blocker_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698