Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/ui/cocoa/javascript_app_modal_dialog_cocoa.h" | 5 #include "chrome/browser/ui/cocoa/javascript_app_modal_dialog_cocoa.h" |
| 6 | 6 |
| 7 #import <Cocoa/Cocoa.h> | 7 #import <Cocoa/Cocoa.h> |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 | 9 |
| 10 #include "base/i18n/rtl.h" | 10 #include "base/i18n/rtl.h" |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 74 | 74 |
| 75 - (instancetype)initWithNativeDialog:(JavaScriptAppModalDialogCocoa*)dialog { | 75 - (instancetype)initWithNativeDialog:(JavaScriptAppModalDialogCocoa*)dialog { |
| 76 DCHECK(dialog); | 76 DCHECK(dialog); |
| 77 self = [super init]; | 77 self = [super init]; |
| 78 if (self) | 78 if (self) |
| 79 nativeDialog_ = dialog; | 79 nativeDialog_ = dialog; |
| 80 return self; | 80 return self; |
| 81 } | 81 } |
| 82 | 82 |
| 83 - (NSAlert*)alert { | 83 - (NSAlert*)alert { |
| 84 if (!alert_) | 84 if (!alert_) { |
| 85 alert_.reset([[NSAlert alloc] init]); | 85 alert_.reset([[NSAlert alloc] init]); |
| 86 [alert_ setIcon:[NSImage new]]; | |
|
meacer
2016/02/04 22:17:58
Not sure about the ownership here, does alert own
droger
2016/02/05 10:33:01
Drive-by.
I expect this to be a memory leak.
Does
Avi (use Gerrit)
2016/02/05 17:06:09
It'll make its own reference, so you're leaking he
Avi (use Gerrit)
2016/02/05 17:11:23
Gah, yes. I replied but forgot to mail my comments
meacer
2016/02/05 19:37:16
Done, thanks for the snippet.
| |
| 87 } | |
| 86 return alert_; | 88 return alert_; |
| 87 } | 89 } |
| 88 | 90 |
| 89 - (void)addTextFieldWithPrompt:(NSString*)prompt { | 91 - (void)addTextFieldWithPrompt:(NSString*)prompt { |
| 90 DCHECK(!textField_); | 92 DCHECK(!textField_); |
| 91 textField_.reset( | 93 textField_.reset( |
| 92 [[NSTextField alloc] initWithFrame:NSMakeRect(0, 0, 300, 22)]); | 94 [[NSTextField alloc] initWithFrame:NSMakeRect(0, 0, 300, 22)]); |
| 93 [[textField_ cell] setLineBreakMode:NSLineBreakByTruncatingTail]; | 95 [[textField_ cell] setLineBreakMode:NSLineBreakByTruncatingTail]; |
| 94 [[self alert] setAccessoryView:textField_]; | 96 [[self alert] setAccessoryView:textField_]; |
| 95 [[alert_ window] setInitialFirstResponder:textField_]; | 97 [[alert_ window] setInitialFirstResponder:textField_]; |
| (...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 459 DISALLOW_COPY_AND_ASSIGN(ChromeJavaScriptNativeDialogCocoaFactory); | 461 DISALLOW_COPY_AND_ASSIGN(ChromeJavaScriptNativeDialogCocoaFactory); |
| 460 }; | 462 }; |
| 461 | 463 |
| 462 } // namespace | 464 } // namespace |
| 463 | 465 |
| 464 void InstallChromeJavaScriptNativeDialogFactory() { | 466 void InstallChromeJavaScriptNativeDialogFactory() { |
| 465 app_modal::JavaScriptDialogManager::GetInstance()-> | 467 app_modal::JavaScriptDialogManager::GetInstance()-> |
| 466 SetNativeDialogFactory( | 468 SetNativeDialogFactory( |
| 467 make_scoped_ptr(new ChromeJavaScriptNativeDialogCocoaFactory)); | 469 make_scoped_ptr(new ChromeJavaScriptNativeDialogCocoaFactory)); |
| 468 } | 470 } |
| OLD | NEW |