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

Unified Diff: chrome/browser/cocoa/download_request_dialog_delegate_mac.mm

Issue 164547: Mac: make save/open dialogs operate as tab-modal sheets.... Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: Painfully (but hopefully correctly) merged ToT. Created 11 years, 2 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/cocoa/download_request_dialog_delegate_mac.mm
diff --git a/chrome/browser/cocoa/download_request_dialog_delegate_mac.mm b/chrome/browser/cocoa/download_request_dialog_delegate_mac.mm
index 4f5e29acba60df6e6c48806ec11d005edfdf6fd4..bb9e846a89ee5c3afedb1002560452e42abcdb1f 100644
--- a/chrome/browser/cocoa/download_request_dialog_delegate_mac.mm
+++ b/chrome/browser/cocoa/download_request_dialog_delegate_mac.mm
@@ -37,10 +37,18 @@
@end
+// Return value passed to the end-sheet routine to indicate that the sheet was
+// ended by |DeleteDelegate()|. This just needs to be some value never used by
+// Apple as a return value for the sheet.
+static int kClosedByDelegate = 658042027;
+
// static
DownloadRequestDialogDelegate* DownloadRequestDialogDelegate::Create(
TabContents* tab,
DownloadRequestManager::TabDownloadState* host) {
+ if (!tab->CanCreateConstrainedDialog())
+ return NULL;
+
return new DownloadRequestDialogDelegateMac(tab, host);
}
@@ -81,7 +89,8 @@ void DownloadRequestDialogDelegateMac::CloseWindow() {
void DownloadRequestDialogDelegateMac::DeleteDelegate() {
if (is_sheet_open()) {
// Close sheet if it's still open.
- [NSApp endSheet:[(NSAlert*)sheet() window]]; // calls SheetDidEnd().
+ [NSApp endSheet:[(NSAlert*)sheet() window]
+ returnCode:kClosedByDelegate]; // Calls SheetDidEnd().
DCHECK(responded_);
}
if (!responded_) {
@@ -95,10 +104,18 @@ void DownloadRequestDialogDelegateMac::DeleteDelegate() {
void DownloadRequestDialogDelegateMac::SheetDidEnd(int returnCode) {
DCHECK(!responded_);
+ responded_ = true;
if (returnCode == NSAlertFirstButtonReturn) {
DoAccept();
} else {
DoCancel();
+
+ // If this ended in a "normal" way, i.e., the user pressing one of the
+ // buttons, we still have to clean up the window (and the delegate). If, on
+ // the other hand, the window was ended by |CloseConstrainedWindow()| (which
+ // caused this routine to be called), then we *must* not try to do that
+ // again.
+ if (returnCode != kClosedByDelegate)
+ CloseWindow();
}
- responded_ = true;
}
« no previous file with comments | « chrome/browser/cocoa/constrained_window_mac.mm ('k') | chrome/browser/cocoa/history_menu_cocoa_controller.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698