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 "base/message_loop.h" | 11 #include "base/message_loop.h" |
12 #include "base/metrics/histogram.h" | 12 #include "base/metrics/histogram.h" |
13 #include "base/string_util.h" | 13 #include "base/string_util.h" |
14 #include "base/utf_string_conversions.h" | 14 #include "base/utf_string_conversions.h" |
15 #include "chrome/browser/external_protocol/external_protocol_handler.h" | 15 #include "chrome/browser/external_protocol/external_protocol_handler.h" |
16 #include "chrome/browser/tab_contents/tab_util.h" | 16 #include "chrome/browser/tab_contents/tab_util.h" |
17 #include "chrome/browser/ui/gtk/gtk_util.h" | 17 #include "chrome/browser/ui/gtk/gtk_util.h" |
18 #include "grit/chromium_strings.h" | 18 #include "grit/chromium_strings.h" |
19 #include "grit/generated_resources.h" | 19 #include "grit/generated_resources.h" |
20 #include "ui/base/gtk/gtk_hig_constants.h" | |
21 #include "ui/base/l10n/l10n_util.h" | 20 #include "ui/base/l10n/l10n_util.h" |
22 #include "ui/base/text/text_elider.h" | 21 #include "ui/base/text/text_elider.h" |
23 | 22 |
24 namespace { | 23 namespace { |
25 | 24 |
26 const int kMessageWidth = 400; | 25 const int kMessageWidth = 400; |
27 | 26 |
28 } // namespace | 27 } // namespace |
29 | 28 |
30 /////////////////////////////////////////////////////////////////////////////// | 29 /////////////////////////////////////////////////////////////////////////////// |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
73 IDS_EXTERNAL_PROTOCOL_INFORMATION, | 72 IDS_EXTERNAL_PROTOCOL_INFORMATION, |
74 ASCIIToUTF16(url.scheme() + ":"), | 73 ASCIIToUTF16(url.scheme() + ":"), |
75 elided_url_without_scheme) + "\n\n"; | 74 elided_url_without_scheme) + "\n\n"; |
76 | 75 |
77 message_text += l10n_util::GetStringFUTF8( | 76 message_text += l10n_util::GetStringFUTF8( |
78 IDS_EXTERNAL_PROTOCOL_APPLICATION_TO_LAUNCH, elided_command) + "\n\n"; | 77 IDS_EXTERNAL_PROTOCOL_APPLICATION_TO_LAUNCH, elided_command) + "\n\n"; |
79 | 78 |
80 message_text += l10n_util::GetStringUTF8(IDS_EXTERNAL_PROTOCOL_WARNING); | 79 message_text += l10n_util::GetStringUTF8(IDS_EXTERNAL_PROTOCOL_WARNING); |
81 | 80 |
82 // Create the content-holding vbox. | 81 // Create the content-holding vbox. |
83 GtkWidget* vbox = gtk_vbox_new(FALSE, ui::kControlSpacing); | 82 GtkWidget* vbox = gtk_vbox_new(FALSE, gtk_util::kControlSpacing); |
84 gtk_container_set_border_width(GTK_CONTAINER(vbox), | 83 gtk_container_set_border_width(GTK_CONTAINER(vbox), |
85 ui::kContentAreaBorder); | 84 gtk_util::kContentAreaBorder); |
86 | 85 |
87 // Add the message text. | 86 // Add the message text. |
88 GtkWidget* label = gtk_label_new(message_text.c_str()); | 87 GtkWidget* label = gtk_label_new(message_text.c_str()); |
89 gtk_util::SetLabelWidth(label, kMessageWidth); | 88 gtk_util::SetLabelWidth(label, kMessageWidth); |
90 gtk_box_pack_start(GTK_BOX(vbox), label, TRUE, TRUE, 0); | 89 gtk_box_pack_start(GTK_BOX(vbox), label, TRUE, TRUE, 0); |
91 | 90 |
92 // Add the checkbox. | 91 // Add the checkbox. |
93 checkbox_ = gtk_check_button_new_with_label( | 92 checkbox_ = gtk_check_button_new_with_label( |
94 l10n_util::GetStringUTF8(IDS_EXTERNAL_PROTOCOL_CHECKBOX_TEXT).c_str()); | 93 l10n_util::GetStringUTF8(IDS_EXTERNAL_PROTOCOL_CHECKBOX_TEXT).c_str()); |
95 gtk_box_pack_start(GTK_BOX(vbox), checkbox_, | 94 gtk_box_pack_start(GTK_BOX(vbox), checkbox_, |
(...skipping 28 matching lines...) Expand all Loading... |
124 if (response_id == GTK_RESPONSE_ACCEPT) { | 123 if (response_id == GTK_RESPONSE_ACCEPT) { |
125 UMA_HISTOGRAM_LONG_TIMES("clickjacking.launch_url", | 124 UMA_HISTOGRAM_LONG_TIMES("clickjacking.launch_url", |
126 base::TimeTicks::Now() - creation_time_); | 125 base::TimeTicks::Now() - creation_time_); |
127 | 126 |
128 ExternalProtocolHandler::LaunchUrlWithoutSecurityCheck(url_); | 127 ExternalProtocolHandler::LaunchUrlWithoutSecurityCheck(url_); |
129 } | 128 } |
130 | 129 |
131 gtk_widget_destroy(dialog_); | 130 gtk_widget_destroy(dialog_); |
132 delete this; | 131 delete this; |
133 } | 132 } |
OLD | NEW |