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

Side by Side Diff: chrome/browser/ui/cocoa/constrained_window/constrained_window_mac.mm

Issue 287123002: [WebModals] New API for browser-scoped popup management. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 6 years, 5 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 | Annotate | Revision Log
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 "chrome/browser/ui/cocoa/constrained_window/constrained_window_mac.h" 5 #include "chrome/browser/ui/cocoa/constrained_window/constrained_window_mac.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "chrome/browser/guest_view/web_view/web_view_guest.h" 8 #include "chrome/browser/guest_view/web_view/web_view_guest.h"
9 #include "chrome/browser/ui/browser_finder.h" 9 #include "chrome/browser/ui/browser_finder.h"
10 #include "chrome/browser/ui/browser_window.h" 10 #include "chrome/browser/ui/browser_window.h"
11 #import "chrome/browser/ui/cocoa/constrained_window/constrained_window_sheet.h" 11 #import "chrome/browser/ui/cocoa/constrained_window/constrained_window_sheet.h"
12 #import "chrome/browser/ui/cocoa/constrained_window/constrained_window_sheet_con troller.h" 12 #import "chrome/browser/ui/cocoa/constrained_window/constrained_window_sheet_con troller.h"
13 #import "chrome/browser/ui/cocoa/tabs/tab_strip_controller.h" 13 #import "chrome/browser/ui/cocoa/tabs/tab_strip_controller.h"
14 #include "components/web_modal/popup_manager.h"
14 #include "components/web_modal/web_contents_modal_dialog_manager.h" 15 #include "components/web_modal/web_contents_modal_dialog_manager.h"
15 #include "content/public/browser/browser_thread.h" 16 #include "content/public/browser/browser_thread.h"
16 #include "content/public/browser/web_contents.h" 17 #include "content/public/browser/web_contents.h"
17 18
18 using web_modal::WebContentsModalDialogManager; 19 using web_modal::WebContentsModalDialogManager;
19 using web_modal::NativeWebContentsModalDialog; 20 using web_modal::NativeWebContentsModalDialog;
20 21
21 ConstrainedWindowMac::ConstrainedWindowMac( 22 ConstrainedWindowMac::ConstrainedWindowMac(
22 ConstrainedWindowMacDelegate* delegate, 23 ConstrainedWindowMacDelegate* delegate,
23 content::WebContents* web_contents, 24 content::WebContents* web_contents,
24 id<ConstrainedWindowSheet> sheet) 25 id<ConstrainedWindowSheet> sheet)
25 : delegate_(delegate), 26 : delegate_(delegate),
26 web_contents_(NULL), 27 web_contents_(NULL),
27 sheet_([sheet retain]), 28 sheet_([sheet retain]),
28 shown_(false) { 29 shown_(false) {
29 DCHECK(web_contents); 30 DCHECK(web_contents);
30 WebViewGuest* web_view_guest = WebViewGuest::FromWebContents(web_contents); 31 WebViewGuest* web_view_guest = WebViewGuest::FromWebContents(web_contents);
31 // For embedded WebContents, use the embedder's WebContents for constrained 32 // For embedded WebContents, use the embedder's WebContents for constrained
32 // window. 33 // window.
33 web_contents_ = web_view_guest && web_view_guest->embedder_web_contents() ? 34 web_contents_ = web_view_guest && web_view_guest->embedder_web_contents() ?
34 web_view_guest->embedder_web_contents() : web_contents; 35 web_view_guest->embedder_web_contents() : web_contents;
35 DCHECK(sheet_.get()); 36 DCHECK(sheet_.get());
36 WebContentsModalDialogManager* web_contents_modal_dialog_manager = 37 web_modal::PopupManager* popup_manager =
37 WebContentsModalDialogManager::FromWebContents(web_contents_); 38 web_modal::PopupManager::FromWebContents(web_contents_);
38 web_contents_modal_dialog_manager->ShowModalDialog(this); 39 if (popup_manager)
40 popup_manager->ShowModalDialog(this, web_contents);
groby-ooo-7-16 2014/06/28 02:04:05 If the popup manager is scoped to web_contents, wh
Greg Billock 2014/06/30 03:59:11 It's scoped to the browser; this registration isn'
39 } 41 }
40 42
41 ConstrainedWindowMac::~ConstrainedWindowMac() { 43 ConstrainedWindowMac::~ConstrainedWindowMac() {
42 CHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); 44 CHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
43 } 45 }
44 46
45 void ConstrainedWindowMac::ShowWebContentsModalDialog() { 47 void ConstrainedWindowMac::ShowWebContentsModalDialog() {
46 if (shown_) 48 if (shown_)
47 return; 49 return;
48 50
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 92
91 NSWindow* ConstrainedWindowMac::GetParentWindow() const { 93 NSWindow* ConstrainedWindowMac::GetParentWindow() const {
92 // Tab contents in a tabbed browser may not be inside a window. For this 94 // Tab contents in a tabbed browser may not be inside a window. For this
93 // reason use a browser window if possible. 95 // reason use a browser window if possible.
94 Browser* browser = chrome::FindBrowserWithWebContents(web_contents_); 96 Browser* browser = chrome::FindBrowserWithWebContents(web_contents_);
95 if (browser) 97 if (browser)
96 return browser->window()->GetNativeWindow(); 98 return browser->window()->GetNativeWindow();
97 99
98 return web_contents_->GetTopLevelNativeWindow(); 100 return web_contents_->GetTopLevelNativeWindow();
99 } 101 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698