| 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/chromeos/external_protocol_dialog.h" | 5 #include "chrome/browser/chromeos/external_protocol_dialog.h" |
| 6 | 6 |
| 7 #include "app/l10n_util.h" | 7 #include "app/l10n_util.h" |
| 8 #include "app/message_box_flags.h" | 8 #include "app/message_box_flags.h" |
| 9 #include "app/text_elider.h" |
| 9 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
| 10 #include "base/string_util.h" | 11 #include "base/string_util.h" |
| 11 #include "base/utf_string_conversions.h" | 12 #include "base/utf_string_conversions.h" |
| 12 #include "chrome/browser/external_protocol_handler.h" | 13 #include "chrome/browser/external_protocol_handler.h" |
| 13 #include "chrome/browser/tab_contents/tab_contents.h" | 14 #include "chrome/browser/tab_contents/tab_contents.h" |
| 14 #include "chrome/browser/tab_contents/tab_contents_view.h" | 15 #include "chrome/browser/tab_contents/tab_contents_view.h" |
| 15 #include "chrome/browser/tab_contents/tab_util.h" | 16 #include "chrome/browser/tab_contents/tab_util.h" |
| 16 #include "chrome/browser/views/window.h" | 17 #include "chrome/browser/views/window.h" |
| 17 #include "googleurl/src/gurl.h" | 18 #include "googleurl/src/gurl.h" |
| 18 #include "grit/chromium_strings.h" | 19 #include "grit/chromium_strings.h" |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 79 | 80 |
| 80 /////////////////////////////////////////////////////////////////////////////// | 81 /////////////////////////////////////////////////////////////////////////////// |
| 81 // ExternalProtocolDialog, private: | 82 // ExternalProtocolDialog, private: |
| 82 | 83 |
| 83 ExternalProtocolDialog::ExternalProtocolDialog(TabContents* tab_contents, | 84 ExternalProtocolDialog::ExternalProtocolDialog(TabContents* tab_contents, |
| 84 const GURL& url) | 85 const GURL& url) |
| 85 : creation_time_(base::TimeTicks::Now()), | 86 : creation_time_(base::TimeTicks::Now()), |
| 86 scheme_(url.scheme()) { | 87 scheme_(url.scheme()) { |
| 87 const int kMaxUrlWithoutSchemeSize = 256; | 88 const int kMaxUrlWithoutSchemeSize = 256; |
| 88 std::wstring elided_url_without_scheme; | 89 std::wstring elided_url_without_scheme; |
| 89 ElideString(ASCIIToWide(url.possibly_invalid_spec()), | 90 gfx::ElideString(ASCIIToWide(url.possibly_invalid_spec()), |
| 90 kMaxUrlWithoutSchemeSize, &elided_url_without_scheme); | 91 kMaxUrlWithoutSchemeSize, &elided_url_without_scheme); |
| 91 | 92 |
| 92 std::wstring message_text = l10n_util::GetStringF( | 93 std::wstring message_text = l10n_util::GetStringF( |
| 93 IDS_EXTERNAL_PROTOCOL_INFORMATION, | 94 IDS_EXTERNAL_PROTOCOL_INFORMATION, |
| 94 ASCIIToWide(url.scheme() + ":"), | 95 ASCIIToWide(url.scheme() + ":"), |
| 95 elided_url_without_scheme) + L"\n\n"; | 96 elided_url_without_scheme) + L"\n\n"; |
| 96 | 97 |
| 97 message_box_view_ = new MessageBoxView(MessageBoxFlags::kIsConfirmMessageBox, | 98 message_box_view_ = new MessageBoxView(MessageBoxFlags::kIsConfirmMessageBox, |
| 98 message_text, | 99 message_text, |
| 99 std::wstring(), | 100 std::wstring(), |
| 100 kMessageWidth); | 101 kMessageWidth); |
| 101 message_box_view_->SetCheckBoxLabel( | 102 message_box_view_->SetCheckBoxLabel( |
| 102 l10n_util::GetString(IDS_EXTERNAL_PROTOCOL_CHECKBOX_TEXT)); | 103 l10n_util::GetString(IDS_EXTERNAL_PROTOCOL_CHECKBOX_TEXT)); |
| 103 | 104 |
| 104 gfx::NativeWindow parent_window; | 105 gfx::NativeWindow parent_window; |
| 105 if (tab_contents) { | 106 if (tab_contents) { |
| 106 parent_window = tab_contents->view()->GetTopLevelNativeWindow(); | 107 parent_window = tab_contents->view()->GetTopLevelNativeWindow(); |
| 107 } else { | 108 } else { |
| 108 // Dialog is top level if we don't have a tab_contents associated with us. | 109 // Dialog is top level if we don't have a tab_contents associated with us. |
| 109 parent_window = NULL; | 110 parent_window = NULL; |
| 110 } | 111 } |
| 111 browser::CreateViewsWindow(parent_window, gfx::Rect(), this)->Show(); | 112 browser::CreateViewsWindow(parent_window, gfx::Rect(), this)->Show(); |
| 112 } | 113 } |
| OLD | NEW |