| 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 #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/message_loop.h" | 7 #include "base/message_loop/message_loop.h" |
| 8 #include "base/metrics/histogram.h" | 8 #include "base/metrics/histogram.h" |
| 9 #include "base/strings/string_util.h" | 9 #include "base/strings/string_util.h" |
| 10 #include "base/strings/sys_string_conversions.h" | 10 #include "base/strings/sys_string_conversions.h" |
| 11 #include "base/strings/utf_string_conversions.h" | 11 #include "base/strings/utf_string_conversions.h" |
| 12 #include "chrome/browser/external_protocol/external_protocol_handler.h" | 12 #include "chrome/browser/external_protocol/external_protocol_handler.h" |
| 13 #include "grit/chromium_strings.h" | 13 #include "grit/chromium_strings.h" |
| 14 #include "grit/generated_resources.h" | 14 #include "grit/generated_resources.h" |
| 15 #include "ui/base/l10n/l10n_util_mac.h" | 15 #include "ui/base/l10n/l10n_util_mac.h" |
| 16 #include "ui/base/text/text_elider.h" | 16 #include "ui/gfx/text_elider.h" |
| 17 | 17 |
| 18 /////////////////////////////////////////////////////////////////////////////// | 18 /////////////////////////////////////////////////////////////////////////////// |
| 19 // ExternalProtocolHandler | 19 // ExternalProtocolHandler |
| 20 | 20 |
| 21 // static | 21 // static |
| 22 void ExternalProtocolHandler::RunExternalProtocolDialog( | 22 void ExternalProtocolHandler::RunExternalProtocolDialog( |
| 23 const GURL& url, int render_process_host_id, int routing_id) { | 23 const GURL& url, int render_process_host_id, int routing_id) { |
| 24 [[ExternalProtocolDialogController alloc] initWithGURL:&url]; | 24 [[ExternalProtocolDialogController alloc] initWithGURL:&url]; |
| 25 } | 25 } |
| 26 | 26 |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 58 | 58 |
| 59 NSButton* allowButton = [alert_ addButtonWithTitle: | 59 NSButton* allowButton = [alert_ addButtonWithTitle: |
| 60 l10n_util::GetNSStringWithFixup(IDS_EXTERNAL_PROTOCOL_OK_BUTTON_TEXT)]; | 60 l10n_util::GetNSStringWithFixup(IDS_EXTERNAL_PROTOCOL_OK_BUTTON_TEXT)]; |
| 61 [allowButton setKeyEquivalent:@""]; // disallow as default | 61 [allowButton setKeyEquivalent:@""]; // disallow as default |
| 62 [alert_ addButtonWithTitle: | 62 [alert_ addButtonWithTitle: |
| 63 l10n_util::GetNSStringWithFixup( | 63 l10n_util::GetNSStringWithFixup( |
| 64 IDS_EXTERNAL_PROTOCOL_CANCEL_BUTTON_TEXT)]; | 64 IDS_EXTERNAL_PROTOCOL_CANCEL_BUTTON_TEXT)]; |
| 65 | 65 |
| 66 const int kMaxUrlWithoutSchemeSize = 256; | 66 const int kMaxUrlWithoutSchemeSize = 256; |
| 67 string16 elided_url_without_scheme; | 67 string16 elided_url_without_scheme; |
| 68 ui::ElideString(ASCIIToUTF16(url_.possibly_invalid_spec()), | 68 gfx::ElideString(ASCIIToUTF16(url_.possibly_invalid_spec()), |
| 69 kMaxUrlWithoutSchemeSize, &elided_url_without_scheme); | 69 kMaxUrlWithoutSchemeSize, &elided_url_without_scheme); |
| 70 | 70 |
| 71 NSString* urlString = l10n_util::GetNSStringFWithFixup( | 71 NSString* urlString = l10n_util::GetNSStringFWithFixup( |
| 72 IDS_EXTERNAL_PROTOCOL_INFORMATION, | 72 IDS_EXTERNAL_PROTOCOL_INFORMATION, |
| 73 ASCIIToUTF16(url_.scheme() + ":"), | 73 ASCIIToUTF16(url_.scheme() + ":"), |
| 74 elided_url_without_scheme); | 74 elided_url_without_scheme); |
| 75 NSString* appString = l10n_util::GetNSStringFWithFixup( | 75 NSString* appString = l10n_util::GetNSStringFWithFixup( |
| 76 IDS_EXTERNAL_PROTOCOL_APPLICATION_TO_LAUNCH, | 76 IDS_EXTERNAL_PROTOCOL_APPLICATION_TO_LAUNCH, |
| 77 appName); | 77 appName); |
| 78 NSString* warningString = | 78 NSString* warningString = |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 147 } | 147 } |
| 148 NSString* appPath = [(NSURL*)openingApp path]; | 148 NSString* appPath = [(NSURL*)openingApp path]; |
| 149 CFRelease(openingApp); // NOT A BUG; LSGetApplicationForURL retains for us | 149 CFRelease(openingApp); // NOT A BUG; LSGetApplicationForURL retains for us |
| 150 NSString* appDisplayName = | 150 NSString* appDisplayName = |
| 151 [[NSFileManager defaultManager] displayNameAtPath:appPath]; | 151 [[NSFileManager defaultManager] displayNameAtPath:appPath]; |
| 152 | 152 |
| 153 return base::SysNSStringToUTF16(appDisplayName); | 153 return base::SysNSStringToUTF16(appDisplayName); |
| 154 } | 154 } |
| 155 | 155 |
| 156 @end | 156 @end |
| OLD | NEW |