OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/external_protocol_dialog.h" | 5 #import "chrome/browser/ui/cocoa/external_protocol_dialog.h" |
6 | 6 |
7 #include "base/message_loop.h" | 7 #include "base/message_loop.h" |
8 #include "base/metrics/histogram.h" | 8 #include "base/metrics/histogram.h" |
9 #include "base/string_util.h" | 9 #include "base/string_util.h" |
10 #include "base/sys_string_conversions.h" | 10 #include "base/sys_string_conversions.h" |
(...skipping 20 matching lines...) Expand all Loading... |
31 - (void)alertEnded:(NSAlert *)alert | 31 - (void)alertEnded:(NSAlert *)alert |
32 returnCode:(int)returnCode | 32 returnCode:(int)returnCode |
33 contextInfo:(void*)contextInfo; | 33 contextInfo:(void*)contextInfo; |
34 - (string16)appNameForProtocol; | 34 - (string16)appNameForProtocol; |
35 @end | 35 @end |
36 | 36 |
37 @implementation ExternalProtocolDialogController | 37 @implementation ExternalProtocolDialogController |
38 - (id)initWithGURL:(const GURL*)url { | 38 - (id)initWithGURL:(const GURL*)url { |
39 DCHECK_EQ(MessageLoop::TYPE_UI, MessageLoop::current()->type()); | 39 DCHECK_EQ(MessageLoop::TYPE_UI, MessageLoop::current()->type()); |
40 | 40 |
| 41 if (!(self = [super init])) |
| 42 return nil; |
| 43 |
41 url_ = *url; | 44 url_ = *url; |
42 creation_time_ = base::Time::Now(); | 45 creation_time_ = base::Time::Now(); |
43 | 46 |
44 string16 appName = [self appNameForProtocol]; | 47 string16 appName = [self appNameForProtocol]; |
45 if (appName.length() == 0) { | 48 if (appName.length() == 0) { |
46 // No registered apps for this protocol; give up and go home. | 49 // No registered apps for this protocol; give up and go home. |
47 [self autorelease]; | 50 [self autorelease]; |
48 return nil; | 51 return nil; |
49 } | 52 } |
50 | 53 |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
144 } | 147 } |
145 NSString* appPath = [(NSURL*)openingApp path]; | 148 NSString* appPath = [(NSURL*)openingApp path]; |
146 CFRelease(openingApp); // NOT A BUG; LSGetApplicationForURL retains for us | 149 CFRelease(openingApp); // NOT A BUG; LSGetApplicationForURL retains for us |
147 NSString* appDisplayName = | 150 NSString* appDisplayName = |
148 [[NSFileManager defaultManager] displayNameAtPath:appPath]; | 151 [[NSFileManager defaultManager] displayNameAtPath:appPath]; |
149 | 152 |
150 return base::SysNSStringToUTF16(appDisplayName); | 153 return base::SysNSStringToUTF16(appDisplayName); |
151 } | 154 } |
152 | 155 |
153 @end | 156 @end |
OLD | NEW |