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

Side by Side Diff: chrome/browser/ui/cocoa/single_web_contents_dialog_manager_cocoa.mm

Issue 1446623003: [Reland] Enable AutoResize for Constrained Web Dialogs for Mac. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase. Created 4 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
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 #import "chrome/browser/ui/cocoa/single_web_contents_dialog_manager_cocoa.h" 5 #import "chrome/browser/ui/cocoa/single_web_contents_dialog_manager_cocoa.h"
6 6
7 #import "chrome/browser/ui/cocoa/constrained_window/constrained_window_custom_sh eet.h" 7 #import "chrome/browser/ui/cocoa/constrained_window/constrained_window_custom_sh eet.h"
8 #import "chrome/browser/ui/cocoa/constrained_window/constrained_window_mac.h" 8 #import "chrome/browser/ui/cocoa/constrained_window/constrained_window_mac.h"
9 #import "chrome/browser/ui/cocoa/constrained_window/constrained_window_sheet_con troller.h" 9 #import "chrome/browser/ui/cocoa/constrained_window/constrained_window_sheet_con troller.h"
10 #include "components/web_modal/web_contents_modal_dialog_host.h" 10 #include "components/web_modal/web_contents_modal_dialog_host.h"
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 NSWindow* parent_window = 51 NSWindow* parent_window =
52 delegate_->GetWebContents()->GetTopLevelNativeWindow(); 52 delegate_->GetWebContents()->GetTopLevelNativeWindow();
53 [[ConstrainedWindowSheetController controllerForParentWindow:parent_window] 53 [[ConstrainedWindowSheetController controllerForParentWindow:parent_window]
54 hideSheet]; 54 hideSheet];
55 } 55 }
56 56
57 void SingleWebContentsDialogManagerCocoa::Close() { 57 void SingleWebContentsDialogManagerCocoa::Close() {
58 [[ConstrainedWindowSheetController controllerForSheet:sheet_] 58 [[ConstrainedWindowSheetController controllerForSheet:sheet_]
59 closeSheet:sheet_]; 59 closeSheet:sheet_];
60 client_->set_manager(nullptr); 60 client_->set_manager(nullptr);
61
62 bool dialog_was_open = client_->DialogWasShown();
61 client_->OnDialogClosing(); // |client_| might delete itself here. 63 client_->OnDialogClosing(); // |client_| might delete itself here.
62 delegate_->WillClose(dialog()); // Deletes |this|. 64
65 if (dialog_was_open)
66 delegate_->WillClose(dialog()); // Deletes |this|.
63 } 67 }
64 68
65 void SingleWebContentsDialogManagerCocoa::Focus() { 69 void SingleWebContentsDialogManagerCocoa::Focus() {
66 } 70 }
67 71
68 void SingleWebContentsDialogManagerCocoa::Pulse() { 72 void SingleWebContentsDialogManagerCocoa::Pulse() {
69 [[ConstrainedWindowSheetController controllerForSheet:sheet_] 73 [[ConstrainedWindowSheetController controllerForSheet:sheet_]
70 pulseSheet:sheet_]; 74 pulseSheet:sheet_];
71 } 75 }
72 76
73 void SingleWebContentsDialogManagerCocoa::HostChanged( 77 void SingleWebContentsDialogManagerCocoa::HostChanged(
74 web_modal::WebContentsModalDialogHost* new_host) { 78 web_modal::WebContentsModalDialogHost* new_host) {
75 // No need to observe the host. For Cocoa, the constrained window controller 79 // No need to observe the host. For Cocoa, the constrained window controller
76 // will reposition the dialog when necessary. The host can also never change. 80 // will reposition the dialog when necessary. The host can also never change.
77 // Tabs showing a dialog can not be dragged off a Cocoa browser window. 81 // Tabs showing a dialog can not be dragged off a Cocoa browser window.
78 // However, closing a tab with a dialog open will set the host back to null. 82 // However, closing a tab with a dialog open will set the host back to null.
79 DCHECK_NE(!!host_, !!new_host); 83 DCHECK_NE(!!host_, !!new_host);
80 host_ = new_host; 84 host_ = new_host;
81 } 85 }
82 86
83 gfx::NativeWindow SingleWebContentsDialogManagerCocoa::dialog() { 87 gfx::NativeWindow SingleWebContentsDialogManagerCocoa::dialog() {
84 return [sheet_ sheetWindow]; 88 return [sheet_ sheetWindow];
85 } 89 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/cocoa/profiles/user_manager_mac.mm ('k') | chrome/browser/ui/cocoa/ssl_client_certificate_selector_cocoa.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698