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