| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 "app/l10n_util.h" | 9 #include "app/l10n_util.h" |
| 10 #include "base/histogram.h" | 10 #include "base/histogram.h" |
| 11 #include "base/message_loop.h" |
| 11 #include "chrome/browser/external_protocol_handler.h" | 12 #include "chrome/browser/external_protocol_handler.h" |
| 12 #include "chrome/browser/tab_contents/tab_contents.h" | 13 #include "chrome/browser/tab_contents/tab_contents.h" |
| 13 #include "chrome/browser/tab_contents/tab_contents_view.h" | 14 #include "chrome/browser/tab_contents/tab_contents_view.h" |
| 14 #include "chrome/browser/tab_contents/tab_util.h" | 15 #include "chrome/browser/tab_contents/tab_util.h" |
| 15 #include "chrome/common/gtk_util.h" | 16 #include "chrome/common/gtk_util.h" |
| 16 #include "grit/chromium_strings.h" | 17 #include "grit/chromium_strings.h" |
| 17 #include "grit/generated_resources.h" | 18 #include "grit/generated_resources.h" |
| 18 | 19 |
| 19 namespace { | 20 namespace { |
| 20 | 21 |
| 21 const int kMessageWidth = 400; | 22 const int kMessageWidth = 400; |
| 22 | 23 |
| 23 } // namespace | 24 } // namespace |
| 24 | 25 |
| 25 /////////////////////////////////////////////////////////////////////////////// | 26 /////////////////////////////////////////////////////////////////////////////// |
| 26 // ExternalProtocolHandler | 27 // ExternalProtocolHandler |
| 27 | 28 |
| 28 // static | 29 // static |
| 29 void ExternalProtocolHandler::RunExternalProtocolDialog( | 30 void ExternalProtocolHandler::RunExternalProtocolDialog( |
| 30 const GURL& url, int render_process_host_id, int routing_id) { | 31 const GURL& url, int render_process_host_id, int routing_id) { |
| 31 new ExternalProtocolDialogGtk(url); | 32 new ExternalProtocolDialogGtk(url); |
| 32 } | 33 } |
| 33 | 34 |
| 34 /////////////////////////////////////////////////////////////////////////////// | 35 /////////////////////////////////////////////////////////////////////////////// |
| 35 // ExternalProtocolDialogGtk | 36 // ExternalProtocolDialogGtk |
| 36 | 37 |
| 37 ExternalProtocolDialogGtk::ExternalProtocolDialogGtk(const GURL& url) | 38 ExternalProtocolDialogGtk::ExternalProtocolDialogGtk(const GURL& url) |
| 38 : url_(url), | 39 : url_(url), |
| 39 creation_time_(base::Time::Now()) { | 40 creation_time_(base::Time::Now()) { |
| 41 DCHECK_EQ(MessageLoop::TYPE_UI, MessageLoop::current()->type()); |
| 40 | 42 |
| 41 dialog_ = gtk_dialog_new_with_buttons( | 43 dialog_ = gtk_dialog_new_with_buttons( |
| 42 l10n_util::GetStringUTF8(IDS_EXTERNAL_PROTOCOL_TITLE).c_str(), | 44 l10n_util::GetStringUTF8(IDS_EXTERNAL_PROTOCOL_TITLE).c_str(), |
| 43 NULL, | 45 NULL, |
| 44 GTK_DIALOG_NO_SEPARATOR, | 46 GTK_DIALOG_NO_SEPARATOR, |
| 45 GTK_STOCK_CANCEL, | 47 GTK_STOCK_CANCEL, |
| 46 GTK_RESPONSE_REJECT, | 48 GTK_RESPONSE_REJECT, |
| 47 NULL); | 49 NULL); |
| 48 | 50 |
| 49 gtk_util::AddButtonToDialog(dialog_, | 51 gtk_util::AddButtonToDialog(dialog_, |
| (...skipping 28 matching lines...) Expand all Loading... |
| 78 if (response == GTK_RESPONSE_ACCEPT) { | 80 if (response == GTK_RESPONSE_ACCEPT) { |
| 79 UMA_HISTOGRAM_LONG_TIMES("clickjacking.launch_url", | 81 UMA_HISTOGRAM_LONG_TIMES("clickjacking.launch_url", |
| 80 base::Time::Now() - dialog->creation_time_); | 82 base::Time::Now() - dialog->creation_time_); |
| 81 | 83 |
| 82 ExternalProtocolHandler::LaunchUrlWithoutSecurityCheck(dialog->url_); | 84 ExternalProtocolHandler::LaunchUrlWithoutSecurityCheck(dialog->url_); |
| 83 } | 85 } |
| 84 | 86 |
| 85 gtk_widget_destroy(widget); | 87 gtk_widget_destroy(widget); |
| 86 delete dialog; | 88 delete dialog; |
| 87 } | 89 } |
| OLD | NEW |