OLD | NEW |
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 #import "chrome/browser/ui/cocoa/external_protocol_dialog.h" | 5 #import "chrome/browser/ui/cocoa/external_protocol_dialog.h" |
6 | 6 |
7 #include "app/l10n_util_mac.h" | 7 #include "app/l10n_util_mac.h" |
| 8 #include "app/text_elider.h" |
8 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
9 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
10 #include "base/string_util.h" | 11 #include "base/string_util.h" |
11 #include "base/sys_string_conversions.h" | 12 #include "base/sys_string_conversions.h" |
12 #include "base/utf_string_conversions.h" | 13 #include "base/utf_string_conversions.h" |
13 #include "chrome/browser/external_protocol_handler.h" | 14 #include "chrome/browser/external_protocol_handler.h" |
14 #include "grit/chromium_strings.h" | 15 #include "grit/chromium_strings.h" |
15 #include "grit/generated_resources.h" | 16 #include "grit/generated_resources.h" |
16 | 17 |
17 /////////////////////////////////////////////////////////////////////////////// | 18 /////////////////////////////////////////////////////////////////////////////// |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
54 | 55 |
55 NSButton* allowButton = [alert_ addButtonWithTitle: | 56 NSButton* allowButton = [alert_ addButtonWithTitle: |
56 l10n_util::GetNSStringWithFixup(IDS_EXTERNAL_PROTOCOL_OK_BUTTON_TEXT)]; | 57 l10n_util::GetNSStringWithFixup(IDS_EXTERNAL_PROTOCOL_OK_BUTTON_TEXT)]; |
57 [allowButton setKeyEquivalent:@""]; // disallow as default | 58 [allowButton setKeyEquivalent:@""]; // disallow as default |
58 [alert_ addButtonWithTitle: | 59 [alert_ addButtonWithTitle: |
59 l10n_util::GetNSStringWithFixup( | 60 l10n_util::GetNSStringWithFixup( |
60 IDS_EXTERNAL_PROTOCOL_CANCEL_BUTTON_TEXT)]; | 61 IDS_EXTERNAL_PROTOCOL_CANCEL_BUTTON_TEXT)]; |
61 | 62 |
62 const int kMaxUrlWithoutSchemeSize = 256; | 63 const int kMaxUrlWithoutSchemeSize = 256; |
63 std::wstring elided_url_without_scheme; | 64 std::wstring elided_url_without_scheme; |
64 ElideString(ASCIIToWide(url_.possibly_invalid_spec()), | 65 gfx::ElideString(ASCIIToWide(url_.possibly_invalid_spec()), |
65 kMaxUrlWithoutSchemeSize, &elided_url_without_scheme); | 66 kMaxUrlWithoutSchemeSize, &elided_url_without_scheme); |
66 | 67 |
67 NSString* urlString = l10n_util::GetNSStringFWithFixup( | 68 NSString* urlString = l10n_util::GetNSStringFWithFixup( |
68 IDS_EXTERNAL_PROTOCOL_INFORMATION, | 69 IDS_EXTERNAL_PROTOCOL_INFORMATION, |
69 ASCIIToUTF16(url_.scheme() + ":"), | 70 ASCIIToUTF16(url_.scheme() + ":"), |
70 WideToUTF16(elided_url_without_scheme)); | 71 WideToUTF16(elided_url_without_scheme)); |
71 NSString* appString = l10n_util::GetNSStringFWithFixup( | 72 NSString* appString = l10n_util::GetNSStringFWithFixup( |
72 IDS_EXTERNAL_PROTOCOL_APPLICATION_TO_LAUNCH, | 73 IDS_EXTERNAL_PROTOCOL_APPLICATION_TO_LAUNCH, |
73 appName); | 74 appName); |
74 NSString* warningString = | 75 NSString* warningString = |
75 l10n_util::GetNSStringWithFixup(IDS_EXTERNAL_PROTOCOL_WARNING); | 76 l10n_util::GetNSStringWithFixup(IDS_EXTERNAL_PROTOCOL_WARNING); |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
143 } | 144 } |
144 NSString* appPath = [(NSURL*)openingApp path]; | 145 NSString* appPath = [(NSURL*)openingApp path]; |
145 CFRelease(openingApp); // NOT A BUG; LSGetApplicationForURL retains for us | 146 CFRelease(openingApp); // NOT A BUG; LSGetApplicationForURL retains for us |
146 NSString* appDisplayName = | 147 NSString* appDisplayName = |
147 [[NSFileManager defaultManager] displayNameAtPath:appPath]; | 148 [[NSFileManager defaultManager] displayNameAtPath:appPath]; |
148 | 149 |
149 return base::SysNSStringToUTF16(appDisplayName); | 150 return base::SysNSStringToUTF16(appDisplayName); |
150 } | 151 } |
151 | 152 |
152 @end | 153 @end |
OLD | NEW |