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

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: Make PopupManager a thin API for WCMDM Created 6 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 | 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/ui/browser_finder.h" 8 #include "chrome/browser/ui/browser_finder.h"
9 #include "chrome/browser/ui/browser_window.h" 9 #include "chrome/browser/ui/browser_window.h"
10 #import "chrome/browser/ui/cocoa/constrained_window/constrained_window_sheet.h" 10 #import "chrome/browser/ui/cocoa/constrained_window/constrained_window_sheet.h"
11 #import "chrome/browser/ui/cocoa/constrained_window/constrained_window_sheet_con troller.h" 11 #import "chrome/browser/ui/cocoa/constrained_window/constrained_window_sheet_con troller.h"
12 #import "chrome/browser/ui/cocoa/tabs/tab_strip_controller.h" 12 #import "chrome/browser/ui/cocoa/tabs/tab_strip_controller.h"
13 #include "components/web_modal/web_contents_modal_dialog_manager.h" 13 #include "components/web_modal/web_contents_modal_dialog_manager.h"
14 #include "content/public/browser/browser_thread.h" 14 #include "content/public/browser/browser_thread.h"
15 #include "content/public/browser/web_contents.h" 15 #include "content/public/browser/web_contents.h"
16 16
17 using web_modal::WebContentsModalDialogManager; 17 using web_modal::WebContentsModalDialogManager;
18 using web_modal::NativeWebContentsModalDialog; 18 using web_modal::NativeWebContentsModalDialog;
19 19
20 ConstrainedWindowMac::ConstrainedWindowMac( 20 ConstrainedWindowMac::ConstrainedWindowMac(
21 ConstrainedWindowMacDelegate* delegate, 21 ConstrainedWindowMacDelegate* delegate,
22 content::WebContents* web_contents, 22 content::WebContents* web_contents,
23 id<ConstrainedWindowSheet> sheet) 23 id<ConstrainedWindowSheet> sheet)
24 : delegate_(delegate), 24 : delegate_(delegate),
25 web_contents_(web_contents), 25 web_contents_(web_contents),
26 sheet_([sheet retain]), 26 sheet_([sheet retain]),
27 shown_(false) { 27 shown_(false) {
28 DCHECK(web_contents); 28 DCHECK(web_contents);
29 DCHECK(sheet_.get()); 29 DCHECK(sheet_.get());
30 // TODO(gbillock): Use PopupManager here.
30 WebContentsModalDialogManager* web_contents_modal_dialog_manager = 31 WebContentsModalDialogManager* web_contents_modal_dialog_manager =
31 WebContentsModalDialogManager::FromWebContents(web_contents); 32 WebContentsModalDialogManager::FromWebContents(web_contents);
32 web_contents_modal_dialog_manager->ShowModalDialog(this); 33 web_contents_modal_dialog_manager->ShowModalDialog(this);
33 } 34 }
34 35
35 ConstrainedWindowMac::~ConstrainedWindowMac() { 36 ConstrainedWindowMac::~ConstrainedWindowMac() {
36 CHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); 37 CHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
37 } 38 }
38 39
39 void ConstrainedWindowMac::ShowWebContentsModalDialog() { 40 void ConstrainedWindowMac::ShowWebContentsModalDialog() {
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 85
85 NSWindow* ConstrainedWindowMac::GetParentWindow() const { 86 NSWindow* ConstrainedWindowMac::GetParentWindow() const {
86 // Tab contents in a tabbed browser may not be inside a window. For this 87 // Tab contents in a tabbed browser may not be inside a window. For this
87 // reason use a browser window if possible. 88 // reason use a browser window if possible.
88 Browser* browser = chrome::FindBrowserWithWebContents(web_contents_); 89 Browser* browser = chrome::FindBrowserWithWebContents(web_contents_);
89 if (browser) 90 if (browser)
90 return browser->window()->GetNativeWindow(); 91 return browser->window()->GetNativeWindow();
91 92
92 return web_contents_->GetTopLevelNativeWindow(); 93 return web_contents_->GetTopLevelNativeWindow();
93 } 94 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698