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

Unified Diff: chrome/browser/ui/cocoa/constrained_window/constrained_window_mac.mm

Issue 1430023002: Enable AutoResize for Constrained Web Dialogs for Mac. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 1 month 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/cocoa/constrained_window/constrained_window_mac.mm
diff --git a/chrome/browser/ui/cocoa/constrained_window/constrained_window_mac.mm b/chrome/browser/ui/cocoa/constrained_window/constrained_window_mac.mm
index f043fad5a0c019634695a187d725aec839d59d58..60f3eff703678a98464cf276b56bab93dcba2b93 100644
--- a/chrome/browser/ui/cocoa/constrained_window/constrained_window_mac.mm
+++ b/chrome/browser/ui/cocoa/constrained_window/constrained_window_mac.mm
@@ -9,16 +9,37 @@
#import "chrome/browser/ui/cocoa/constrained_window/constrained_window_sheet.h"
#import "chrome/browser/ui/cocoa/single_web_contents_dialog_manager_cocoa.h"
#include "components/guest_view/browser/guest_view_base.h"
-#include "components/web_modal/web_contents_modal_dialog_manager.h"
#include "content/public/browser/browser_thread.h"
using web_modal::WebContentsModalDialogManager;
+ConstrainedWindowMac* ShowWebModalDialogMac(
+ ConstrainedWindowMacDelegate* delegate,
+ content::WebContents* web_contents,
+ id<ConstrainedWindowSheet> sheet) {
+ ConstrainedWindowMac* window = new ConstrainedWindowMac(delegate);
+ window->ShowDialog(web_contents, sheet);
+ return window;
+}
+
+ConstrainedWindowMac* CreateWebModalDialogMac(
+ ConstrainedWindowMacDelegate* delegate,
+ content::WebContents* web_contents,
+ id<ConstrainedWindowSheet> sheet) {
+ return new ConstrainedWindowMac(delegate, web_contents, sheet);
+}
+
+ConstrainedWindowMac::ConstrainedWindowMac(
+ ConstrainedWindowMacDelegate* delegate)
+ : delegate_(delegate) {
+}
+
ConstrainedWindowMac::ConstrainedWindowMac(
ConstrainedWindowMacDelegate* delegate,
content::WebContents* web_contents,
id<ConstrainedWindowSheet> sheet)
- : delegate_(delegate) {
+ : delegate_(delegate),
+ sheet_(sheet) {
DCHECK(sheet);
// |web_contents| may be embedded within a chain of nested GuestViews. If it
@@ -26,15 +47,34 @@ ConstrainedWindowMac::ConstrainedWindowMac(
web_contents =
guest_view::GuestViewBase::GetTopLevelWebContents(web_contents);
+ dialog_manager_ =
+ WebContentsModalDialogManager::FromWebContents(web_contents);
+ native_manager_.reset(
+ new SingleWebContentsDialogManagerCocoa(this, sheet_, dialog_manager_));
+}
+
+ConstrainedWindowMac::~ConstrainedWindowMac() {
+ CHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
+ native_manager_.reset();
+ DCHECK(!manager_);
+}
+
+void ConstrainedWindowMac::ShowDialog(
+ content::WebContents* web_contents,
+ id<ConstrainedWindowSheet> sheet) {
+ DCHECK(sheet);
+ web_contents =
+ guest_view::GuestViewBase::GetTopLevelWebContents(web_contents);
+
auto manager = WebContentsModalDialogManager::FromWebContents(web_contents);
scoped_ptr<SingleWebContentsDialogManagerCocoa> native_manager(
new SingleWebContentsDialogManagerCocoa(this, sheet, manager));
manager->ShowDialogWithManager([sheet sheetWindow], native_manager.Pass());
}
-ConstrainedWindowMac::~ConstrainedWindowMac() {
- CHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
- DCHECK(!manager_);
+void ConstrainedWindowMac::ShowDialog() {
+ dialog_manager_->ShowDialogWithManager(
+ [sheet_ sheetWindow], native_manager_.Pass());
}
void ConstrainedWindowMac::CloseWebContentsModalDialog() {

Powered by Google App Engine
This is Rietveld 408576698