| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "content/shell/browser/shell_login_dialog.h" | 5 #include "content/shell/browser/shell_login_dialog.h" |
| 6 | 6 |
| 7 #import <Cocoa/Cocoa.h> | 7 #import <Cocoa/Cocoa.h> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/mac/bundle_locations.h" | 10 #include "base/mac/bundle_locations.h" |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 81 - (void)cancel { | 81 - (void)cancel { |
| 82 [NSApp endSheet:[alert_ window]]; | 82 [NSApp endSheet:[alert_ window]]; |
| 83 alert_.reset(); | 83 alert_.reset(); |
| 84 } | 84 } |
| 85 | 85 |
| 86 @end | 86 @end |
| 87 | 87 |
| 88 namespace content { | 88 namespace content { |
| 89 | 89 |
| 90 void ShellLoginDialog::PlatformCreateDialog(const base::string16& message) { | 90 void ShellLoginDialog::PlatformCreateDialog(const base::string16& message) { |
| 91 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 91 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 92 helper_ = [[ShellLoginDialogHelper alloc] init]; | 92 helper_ = [[ShellLoginDialogHelper alloc] init]; |
| 93 | 93 |
| 94 // Show the modal dialog. | 94 // Show the modal dialog. |
| 95 NSAlert* alert = [helper_ alert]; | 95 NSAlert* alert = [helper_ alert]; |
| 96 [alert setDelegate:helper_]; | 96 [alert setDelegate:helper_]; |
| 97 [alert setInformativeText:base::SysUTF16ToNSString(message)]; | 97 [alert setInformativeText:base::SysUTF16ToNSString(message)]; |
| 98 [alert setMessageText:@"Please log in."]; | 98 [alert setMessageText:@"Please log in."]; |
| 99 [alert addButtonWithTitle:@"OK"]; | 99 [alert addButtonWithTitle:@"OK"]; |
| 100 NSButton* other = [alert addButtonWithTitle:@"Cancel"]; | 100 NSButton* other = [alert addButtonWithTitle:@"Cancel"]; |
| 101 [other setKeyEquivalent:@"\e"]; | 101 [other setKeyEquivalent:@"\e"]; |
| 102 [alert | 102 [alert |
| 103 beginSheetModalForWindow:nil // nil here makes it app-modal | 103 beginSheetModalForWindow:nil // nil here makes it app-modal |
| 104 modalDelegate:helper_ | 104 modalDelegate:helper_ |
| 105 didEndSelector:@selector(alertDidEnd:returnCode:contextInfo:) | 105 didEndSelector:@selector(alertDidEnd:returnCode:contextInfo:) |
| 106 contextInfo:this]; | 106 contextInfo:this]; |
| 107 | 107 |
| 108 [helper_ focus]; | 108 [helper_ focus]; |
| 109 } | 109 } |
| 110 | 110 |
| 111 void ShellLoginDialog::PlatformCleanUp() { | 111 void ShellLoginDialog::PlatformCleanUp() { |
| 112 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 112 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 113 [helper_ release]; | 113 [helper_ release]; |
| 114 helper_ = nil; | 114 helper_ = nil; |
| 115 } | 115 } |
| 116 | 116 |
| 117 void ShellLoginDialog::PlatformRequestCancelled() { | 117 void ShellLoginDialog::PlatformRequestCancelled() { |
| 118 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 118 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 119 [helper_ cancel]; | 119 [helper_ cancel]; |
| 120 } | 120 } |
| 121 | 121 |
| 122 } // namespace content | 122 } // namespace content |
| OLD | NEW |