| 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 #include "chrome/browser/chromeos/external_protocol_dialog.h" | 5 #include "chrome/browser/chromeos/external_protocol_dialog.h" |
| 6 | 6 |
| 7 #include "base/metrics/histogram.h" | 7 #include "base/metrics/histogram.h" |
| 8 #include "base/strings/string_util.h" | 8 #include "base/strings/string_util.h" |
| 9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
| 10 #include "chrome/browser/external_protocol/external_protocol_handler.h" | 10 #include "chrome/browser/external_protocol/external_protocol_handler.h" |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 45 ExternalProtocolDialog::~ExternalProtocolDialog() { | 45 ExternalProtocolDialog::~ExternalProtocolDialog() { |
| 46 } | 46 } |
| 47 | 47 |
| 48 ////////////////////////////////////////////////////////////////////////////// | 48 ////////////////////////////////////////////////////////////////////////////// |
| 49 // ExternalProtocolDialog, views::DialogDelegate implementation: | 49 // ExternalProtocolDialog, views::DialogDelegate implementation: |
| 50 | 50 |
| 51 int ExternalProtocolDialog::GetDialogButtons() const { | 51 int ExternalProtocolDialog::GetDialogButtons() const { |
| 52 return ui::DIALOG_BUTTON_OK; | 52 return ui::DIALOG_BUTTON_OK; |
| 53 } | 53 } |
| 54 | 54 |
| 55 string16 ExternalProtocolDialog::GetDialogButtonLabel( | 55 base::string16 ExternalProtocolDialog::GetDialogButtonLabel( |
| 56 ui::DialogButton button) const { | 56 ui::DialogButton button) const { |
| 57 return l10n_util::GetStringUTF16(IDS_EXTERNAL_PROTOCOL_OK_BUTTON_TEXT); | 57 return l10n_util::GetStringUTF16(IDS_EXTERNAL_PROTOCOL_OK_BUTTON_TEXT); |
| 58 } | 58 } |
| 59 | 59 |
| 60 string16 ExternalProtocolDialog::GetWindowTitle() const { | 60 base::string16 ExternalProtocolDialog::GetWindowTitle() const { |
| 61 return l10n_util::GetStringUTF16(IDS_EXTERNAL_PROTOCOL_TITLE); | 61 return l10n_util::GetStringUTF16(IDS_EXTERNAL_PROTOCOL_TITLE); |
| 62 } | 62 } |
| 63 | 63 |
| 64 void ExternalProtocolDialog::DeleteDelegate() { | 64 void ExternalProtocolDialog::DeleteDelegate() { |
| 65 delete this; | 65 delete this; |
| 66 } | 66 } |
| 67 | 67 |
| 68 bool ExternalProtocolDialog::Accept() { | 68 bool ExternalProtocolDialog::Accept() { |
| 69 if (message_box_view_->IsCheckBoxSelected()) { | 69 if (message_box_view_->IsCheckBoxSelected()) { |
| 70 ExternalProtocolHandler::SetBlockState( | 70 ExternalProtocolHandler::SetBlockState( |
| (...skipping 16 matching lines...) Expand all Loading... |
| 87 } | 87 } |
| 88 | 88 |
| 89 /////////////////////////////////////////////////////////////////////////////// | 89 /////////////////////////////////////////////////////////////////////////////// |
| 90 // ExternalProtocolDialog, private: | 90 // ExternalProtocolDialog, private: |
| 91 | 91 |
| 92 ExternalProtocolDialog::ExternalProtocolDialog(WebContents* web_contents, | 92 ExternalProtocolDialog::ExternalProtocolDialog(WebContents* web_contents, |
| 93 const GURL& url) | 93 const GURL& url) |
| 94 : creation_time_(base::TimeTicks::Now()), | 94 : creation_time_(base::TimeTicks::Now()), |
| 95 scheme_(url.scheme()) { | 95 scheme_(url.scheme()) { |
| 96 const int kMaxUrlWithoutSchemeSize = 256; | 96 const int kMaxUrlWithoutSchemeSize = 256; |
| 97 string16 elided_url_without_scheme; | 97 base::string16 elided_url_without_scheme; |
| 98 gfx::ElideString(ASCIIToUTF16(url.possibly_invalid_spec()), | 98 gfx::ElideString(ASCIIToUTF16(url.possibly_invalid_spec()), |
| 99 kMaxUrlWithoutSchemeSize, &elided_url_without_scheme); | 99 kMaxUrlWithoutSchemeSize, &elided_url_without_scheme); |
| 100 | 100 |
| 101 views::MessageBoxView::InitParams params( | 101 views::MessageBoxView::InitParams params( |
| 102 l10n_util::GetStringFUTF16(IDS_EXTERNAL_PROTOCOL_INFORMATION, | 102 l10n_util::GetStringFUTF16(IDS_EXTERNAL_PROTOCOL_INFORMATION, |
| 103 ASCIIToUTF16(url.scheme() + ":"), | 103 ASCIIToUTF16(url.scheme() + ":"), |
| 104 elided_url_without_scheme) + ASCIIToUTF16("\n\n")); | 104 elided_url_without_scheme) + ASCIIToUTF16("\n\n")); |
| 105 params.message_width = kMessageWidth; | 105 params.message_width = kMessageWidth; |
| 106 message_box_view_ = new views::MessageBoxView(params); | 106 message_box_view_ = new views::MessageBoxView(params); |
| 107 message_box_view_->SetCheckBoxLabel( | 107 message_box_view_->SetCheckBoxLabel( |
| 108 l10n_util::GetStringUTF16(IDS_EXTERNAL_PROTOCOL_CHECKBOX_TEXT)); | 108 l10n_util::GetStringUTF16(IDS_EXTERNAL_PROTOCOL_CHECKBOX_TEXT)); |
| 109 | 109 |
| 110 gfx::NativeWindow parent_window; | 110 gfx::NativeWindow parent_window; |
| 111 if (web_contents) { | 111 if (web_contents) { |
| 112 parent_window = web_contents->GetView()->GetTopLevelNativeWindow(); | 112 parent_window = web_contents->GetView()->GetTopLevelNativeWindow(); |
| 113 } else { | 113 } else { |
| 114 // Dialog is top level if we don't have a web_contents associated with us. | 114 // Dialog is top level if we don't have a web_contents associated with us. |
| 115 parent_window = NULL; | 115 parent_window = NULL; |
| 116 } | 116 } |
| 117 views::DialogDelegate::CreateDialogWidget(this, NULL, parent_window)->Show(); | 117 views::DialogDelegate::CreateDialogWidget(this, NULL, parent_window)->Show(); |
| 118 } | 118 } |
| OLD | NEW |