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

Side by Side Diff: chrome/browser/ui/blocked_content/app_modal_dialog_helper.cc

Issue 2882513005: Propagate opener to BackgroundsContents. (Closed)
Patch Set: Tweaked the comment in DriveWebContentsManager::ShouldCreateWebContents Created 3 years, 6 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 | « chrome/browser/prerender/prerender_contents.cc ('k') | chrome/browser/ui/browser.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 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 17 matching lines...) Expand all
28 actual_host = guest->embedder_web_contents(); 28 actual_host = guest->embedder_web_contents();
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->GetOriginalOpener() == actual_host) { 39 content::WebContents* original_opener =
40 // It's indeed a popup from the dialog opening WebContents. Store it, so 40 content::WebContents::FromRenderFrameHost(
41 // we can focus it later. 41 active_web_contents->GetOriginalOpener());
42 popup_ = active_web_contents; 42 if (original_opener == actual_host) {
43 Observe(popup_); 43 // It's indeed a popup from the dialog opening WebContents. Store it, so
44 // we can focus it later.
45 popup_ = active_web_contents;
46 Observe(popup_);
47 }
44 } 48 }
45 } 49 }
46 } 50 }
47 51
48 AppModalDialogHelper::~AppModalDialogHelper() { 52 AppModalDialogHelper::~AppModalDialogHelper() {
49 if (!popup_) 53 if (!popup_)
50 return; 54 return;
51 55
52 content::WebContentsDelegate* delegate = popup_->GetDelegate(); 56 content::WebContentsDelegate* delegate = popup_->GetDelegate();
53 if (!delegate) 57 if (!delegate)
54 return; 58 return;
55 59
56 delegate->ActivateContents(popup_); 60 delegate->ActivateContents(popup_);
57 } 61 }
58 62
59 void AppModalDialogHelper::WebContentsDestroyed() { 63 void AppModalDialogHelper::WebContentsDestroyed() {
60 popup_ = nullptr; 64 popup_ = nullptr;
61 } 65 }
OLDNEW
« no previous file with comments | « chrome/browser/prerender/prerender_contents.cc ('k') | chrome/browser/ui/browser.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698