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

Side by Side Diff: chrome/browser/js_modal_dialog_mac.mm

Issue 1520006: Mac: reform our shutdown routine. (Closed)
Patch Set: changed comment Created 10 years, 8 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
« no previous file with comments | « chrome/browser/chrome_browser_application_mac.mm ('k') | chrome/chrome_browser.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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/js_modal_dialog.h" 5 #include "chrome/browser/js_modal_dialog.h"
6 6
7 #import <Cocoa/Cocoa.h> 7 #import <Cocoa/Cocoa.h>
8 8
9 #include "app/l10n_util_mac.h" 9 #include "app/l10n_util_mac.h"
10 #include "app/message_box_flags.h" 10 #include "app/message_box_flags.h"
11 #import "base/cocoa_protocols_mac.h" 11 #import "base/cocoa_protocols_mac.h"
12 #include "base/sys_string_conversions.h" 12 #include "base/sys_string_conversions.h"
13 #import "chrome/browser/chrome_browser_application_mac.h"
13 #include "grit/app_strings.h" 14 #include "grit/app_strings.h"
14 #include "grit/generated_resources.h" 15 #include "grit/generated_resources.h"
15 16
16 // Helper object that receives the notification that the dialog/sheet is 17 // Helper object that receives the notification that the dialog/sheet is
17 // going away. Is responsible for cleaning itself up. 18 // going away. Is responsible for cleaning itself up.
18 @interface JavaScriptAppModalDialogHelper : NSObject<NSAlertDelegate> { 19 @interface JavaScriptAppModalDialogHelper : NSObject<NSAlertDelegate> {
19 @private 20 @private
20 NSAlert* alert_; 21 NSAlert* alert_;
21 NSTextField* textField_; // WEAK; owned by alert_ 22 NSTextField* textField_; // WEAK; owned by alert_
22 } 23 }
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 input = base::SysNSStringToWide([textField_ stringValue]); 62 input = base::SysNSStringToWide([textField_ stringValue]);
62 switch (returnCode) { 63 switch (returnCode) {
63 case NSAlertFirstButtonReturn: { // OK 64 case NSAlertFirstButtonReturn: { // OK
64 bool shouldSuppress = false; 65 bool shouldSuppress = false;
65 if ([alert showsSuppressionButton]) 66 if ([alert showsSuppressionButton])
66 shouldSuppress = [[alert suppressionButton] state] == NSOnState; 67 shouldSuppress = [[alert suppressionButton] state] == NSOnState;
67 bridge->OnAccept(input, shouldSuppress); 68 bridge->OnAccept(input, shouldSuppress);
68 break; 69 break;
69 } 70 }
70 case NSAlertSecondButtonReturn: { // Cancel 71 case NSAlertSecondButtonReturn: { // Cancel
72 // If the user wants to stay on this page, stop quitting (if a quit is in
73 // progress).
74 if (bridge->is_before_unload_dialog())
75 chrome_browser_application_mac::CancelTerminate();
76
71 bridge->OnCancel(); 77 bridge->OnCancel();
72 break; 78 break;
73 } 79 }
74 case NSRunStoppedResponse: { // Window was closed underneath us 80 case NSRunStoppedResponse: { // Window was closed underneath us
75 // Need to call OnCancel() because there is some cleanup that needs 81 // Need to call OnCancel() because there is some cleanup that needs
76 // to be done. It won't call back to the javascript since the 82 // to be done. It won't call back to the javascript since the
77 // JavaScriptAppModalDialog knows that the TabContents was destroyed. 83 // JavaScriptAppModalDialog knows that the TabContents was destroyed.
78 bridge->OnCancel(); 84 bridge->OnCancel();
79 break; 85 break;
80 } 86 }
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
172 NOTIMPLEMENTED(); 178 NOTIMPLEMENTED();
173 return nil; 179 return nil;
174 } 180 }
175 181
176 void JavaScriptAppModalDialog::CloseModalDialog() { 182 void JavaScriptAppModalDialog::CloseModalDialog() {
177 NSAlert* alert = dialog_; 183 NSAlert* alert = dialog_;
178 DCHECK([alert isKindOfClass:[NSAlert class]]); 184 DCHECK([alert isKindOfClass:[NSAlert class]]);
179 [NSApp endSheet:[alert window]]; 185 [NSApp endSheet:[alert window]];
180 dialog_ = nil; 186 dialog_ = nil;
181 } 187 }
OLDNEW
« no previous file with comments | « chrome/browser/chrome_browser_application_mac.mm ('k') | chrome/chrome_browser.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698