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 #include "chrome/browser/gtk/external_protocol_dialog_gtk.h" | 5 #include "chrome/browser/gtk/external_protocol_dialog_gtk.h" |
6 | 6 |
7 #include <gtk/gtk.h> | 7 #include <gtk/gtk.h> |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 | 10 |
11 #include "app/l10n_util.h" | 11 #include "app/l10n_util.h" |
| 12 #include "app/text_elider.h" |
12 #include "base/metrics/histogram.h" | 13 #include "base/metrics/histogram.h" |
13 #include "base/message_loop.h" | 14 #include "base/message_loop.h" |
14 #include "base/string_util.h" | 15 #include "base/string_util.h" |
15 #include "base/utf_string_conversions.h" | 16 #include "base/utf_string_conversions.h" |
16 #include "chrome/browser/external_protocol_handler.h" | 17 #include "chrome/browser/external_protocol_handler.h" |
17 #include "chrome/browser/gtk/gtk_util.h" | 18 #include "chrome/browser/gtk/gtk_util.h" |
18 #include "chrome/browser/tab_contents/tab_util.h" | 19 #include "chrome/browser/tab_contents/tab_util.h" |
19 #include "grit/chromium_strings.h" | 20 #include "grit/chromium_strings.h" |
20 #include "grit/generated_resources.h" | 21 #include "grit/generated_resources.h" |
21 | 22 |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
55 GTK_STOCK_CANCEL, GTK_RESPONSE_REJECT); | 56 GTK_STOCK_CANCEL, GTK_RESPONSE_REJECT); |
56 gtk_util::AddButtonToDialog(dialog_, | 57 gtk_util::AddButtonToDialog(dialog_, |
57 l10n_util::GetStringUTF8(IDS_EXTERNAL_PROTOCOL_OK_BUTTON_TEXT).c_str(), | 58 l10n_util::GetStringUTF8(IDS_EXTERNAL_PROTOCOL_OK_BUTTON_TEXT).c_str(), |
58 GTK_STOCK_OK, GTK_RESPONSE_ACCEPT); | 59 GTK_STOCK_OK, GTK_RESPONSE_ACCEPT); |
59 | 60 |
60 // Construct the message text. | 61 // Construct the message text. |
61 const int kMaxUrlWithoutSchemeSize = 256; | 62 const int kMaxUrlWithoutSchemeSize = 256; |
62 const int kMaxCommandSize = 256; | 63 const int kMaxCommandSize = 256; |
63 std::wstring elided_url_without_scheme; | 64 std::wstring elided_url_without_scheme; |
64 std::wstring elided_command; | 65 std::wstring elided_command; |
65 ElideString(ASCIIToWide(url.possibly_invalid_spec()), | 66 gfx::ElideString(ASCIIToWide(url.possibly_invalid_spec()), |
66 kMaxUrlWithoutSchemeSize, &elided_url_without_scheme); | 67 kMaxUrlWithoutSchemeSize, &elided_url_without_scheme); |
67 ElideString(ASCIIToWide(std::string("xdg-open ") + url.spec()), | 68 gfx::ElideString(ASCIIToWide(std::string("xdg-open ") + url.spec()), |
68 kMaxCommandSize, &elided_command); | 69 kMaxCommandSize, &elided_command); |
69 | 70 |
70 std::string message_text = l10n_util::GetStringFUTF8( | 71 std::string message_text = l10n_util::GetStringFUTF8( |
71 IDS_EXTERNAL_PROTOCOL_INFORMATION, | 72 IDS_EXTERNAL_PROTOCOL_INFORMATION, |
72 ASCIIToUTF16(url.scheme() + ":"), | 73 ASCIIToUTF16(url.scheme() + ":"), |
73 WideToUTF16(elided_url_without_scheme)) + "\n\n"; | 74 WideToUTF16(elided_url_without_scheme)) + "\n\n"; |
74 | 75 |
75 message_text += l10n_util::GetStringFUTF8( | 76 message_text += l10n_util::GetStringFUTF8( |
76 IDS_EXTERNAL_PROTOCOL_APPLICATION_TO_LAUNCH, | 77 IDS_EXTERNAL_PROTOCOL_APPLICATION_TO_LAUNCH, |
77 WideToUTF16(elided_command)) + "\n\n"; | 78 WideToUTF16(elided_command)) + "\n\n"; |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
123 if (response == GTK_RESPONSE_ACCEPT) { | 124 if (response == GTK_RESPONSE_ACCEPT) { |
124 UMA_HISTOGRAM_LONG_TIMES("clickjacking.launch_url", | 125 UMA_HISTOGRAM_LONG_TIMES("clickjacking.launch_url", |
125 base::TimeTicks::Now() - creation_time_); | 126 base::TimeTicks::Now() - creation_time_); |
126 | 127 |
127 ExternalProtocolHandler::LaunchUrlWithoutSecurityCheck(url_); | 128 ExternalProtocolHandler::LaunchUrlWithoutSecurityCheck(url_); |
128 } | 129 } |
129 | 130 |
130 gtk_widget_destroy(dialog_); | 131 gtk_widget_destroy(dialog_); |
131 delete this; | 132 delete this; |
132 } | 133 } |
OLD | NEW |