| 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/ui/views/external_protocol_dialog.h" | 5 #include "chrome/browser/ui/views/external_protocol_dialog.h" |
| 6 | 6 |
| 7 #include <utility> |
| 8 |
| 7 #include "base/metrics/histogram.h" | 9 #include "base/metrics/histogram.h" |
| 8 #include "base/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
| 9 #include "base/strings/utf_string_conversions.h" | 11 #include "base/strings/utf_string_conversions.h" |
| 10 #include "chrome/browser/external_protocol/external_protocol_handler.h" | 12 #include "chrome/browser/external_protocol/external_protocol_handler.h" |
| 11 #include "chrome/browser/tab_contents/tab_util.h" | 13 #include "chrome/browser/tab_contents/tab_util.h" |
| 12 #include "chrome/browser/ui/external_protocol_dialog_delegate.h" | 14 #include "chrome/browser/ui/external_protocol_dialog_delegate.h" |
| 13 #include "chrome/grit/generated_resources.h" | 15 #include "chrome/grit/generated_resources.h" |
| 14 #include "components/constrained_window/constrained_window_views.h" | 16 #include "components/constrained_window/constrained_window_views.h" |
| 15 #include "content/public/browser/web_contents.h" | 17 #include "content/public/browser/web_contents.h" |
| 16 #include "ui/base/l10n/l10n_util.h" | 18 #include "ui/base/l10n/l10n_util.h" |
| (...skipping 19 matching lines...) Expand all Loading... |
| 36 scoped_ptr<ExternalProtocolDialogDelegate> delegate( | 38 scoped_ptr<ExternalProtocolDialogDelegate> delegate( |
| 37 new ExternalProtocolDialogDelegate(url, | 39 new ExternalProtocolDialogDelegate(url, |
| 38 render_process_host_id, | 40 render_process_host_id, |
| 39 routing_id)); | 41 routing_id)); |
| 40 if (delegate->program_name().empty()) { | 42 if (delegate->program_name().empty()) { |
| 41 // ShellExecute won't do anything. Don't bother warning the user. | 43 // ShellExecute won't do anything. Don't bother warning the user. |
| 42 return; | 44 return; |
| 43 } | 45 } |
| 44 | 46 |
| 45 // Windowing system takes ownership. | 47 // Windowing system takes ownership. |
| 46 new ExternalProtocolDialog( | 48 new ExternalProtocolDialog(std::move(delegate), render_process_host_id, |
| 47 delegate.Pass(), render_process_host_id, routing_id); | 49 routing_id); |
| 48 } | 50 } |
| 49 | 51 |
| 50 /////////////////////////////////////////////////////////////////////////////// | 52 /////////////////////////////////////////////////////////////////////////////// |
| 51 // ExternalProtocolDialog | 53 // ExternalProtocolDialog |
| 52 | 54 |
| 53 ExternalProtocolDialog::~ExternalProtocolDialog() { | 55 ExternalProtocolDialog::~ExternalProtocolDialog() { |
| 54 } | 56 } |
| 55 | 57 |
| 56 ////////////////////////////////////////////////////////////////////////////// | 58 ////////////////////////////////////////////////////////////////////////////// |
| 57 // ExternalProtocolDialog, views::DialogDelegate implementation: | 59 // ExternalProtocolDialog, views::DialogDelegate implementation: |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 118 return ui::MODAL_TYPE_CHILD; | 120 return ui::MODAL_TYPE_CHILD; |
| 119 } | 121 } |
| 120 | 122 |
| 121 /////////////////////////////////////////////////////////////////////////////// | 123 /////////////////////////////////////////////////////////////////////////////// |
| 122 // ExternalProtocolDialog, private: | 124 // ExternalProtocolDialog, private: |
| 123 | 125 |
| 124 ExternalProtocolDialog::ExternalProtocolDialog( | 126 ExternalProtocolDialog::ExternalProtocolDialog( |
| 125 scoped_ptr<const ProtocolDialogDelegate> delegate, | 127 scoped_ptr<const ProtocolDialogDelegate> delegate, |
| 126 int render_process_host_id, | 128 int render_process_host_id, |
| 127 int routing_id) | 129 int routing_id) |
| 128 : delegate_(delegate.Pass()), | 130 : delegate_(std::move(delegate)), |
| 129 render_process_host_id_(render_process_host_id), | 131 render_process_host_id_(render_process_host_id), |
| 130 routing_id_(routing_id), | 132 routing_id_(routing_id), |
| 131 creation_time_(base::TimeTicks::Now()) { | 133 creation_time_(base::TimeTicks::Now()) { |
| 132 views::MessageBoxView::InitParams params(delegate_->GetMessageText()); | 134 views::MessageBoxView::InitParams params(delegate_->GetMessageText()); |
| 133 params.message_width = kMessageWidth; | 135 params.message_width = kMessageWidth; |
| 134 message_box_view_ = new views::MessageBoxView(params); | 136 message_box_view_ = new views::MessageBoxView(params); |
| 135 message_box_view_->SetCheckBoxLabel(delegate_->GetCheckboxText()); | 137 message_box_view_->SetCheckBoxLabel(delegate_->GetCheckboxText()); |
| 136 | 138 |
| 137 WebContents* web_contents = tab_util::GetWebContentsByID( | 139 WebContents* web_contents = tab_util::GetWebContentsByID( |
| 138 render_process_host_id_, routing_id_); | 140 render_process_host_id_, routing_id_); |
| 139 // Only launch the dialog if there is a web contents associated with the | 141 // Only launch the dialog if there is a web contents associated with the |
| 140 // request. | 142 // request. |
| 141 if (web_contents) | 143 if (web_contents) |
| 142 constrained_window::ShowWebModalDialogViews(this, web_contents); | 144 constrained_window::ShowWebModalDialogViews(this, web_contents); |
| 143 } | 145 } |
| OLD | NEW |