Chromium Code Reviews| 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> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/metrics/histogram_macros.h" | 9 #include "base/metrics/histogram_macros.h" |
| 10 #include "base/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 67 | 67 |
| 68 base::string16 ExternalProtocolDialog::GetWindowTitle() const { | 68 base::string16 ExternalProtocolDialog::GetWindowTitle() const { |
| 69 return delegate_->GetTitleText(); | 69 return delegate_->GetTitleText(); |
| 70 } | 70 } |
| 71 | 71 |
| 72 void ExternalProtocolDialog::DeleteDelegate() { | 72 void ExternalProtocolDialog::DeleteDelegate() { |
| 73 delete this; | 73 delete this; |
| 74 } | 74 } |
| 75 | 75 |
| 76 bool ExternalProtocolDialog::Cancel() { | 76 bool ExternalProtocolDialog::Cancel() { |
| 77 // We also get called back here if the user closes the dialog or presses | |
| 78 // escape. In these cases it would be preferable to ignore the state of the | |
| 79 // check box but MessageBox doesn't distinguish this from pressing the cancel | |
| 80 // button. | |
| 81 delegate_->DoCancel(delegate_->url(), | 77 delegate_->DoCancel(delegate_->url(), |
| 82 message_box_view_->IsCheckBoxSelected()); | 78 message_box_view_->IsCheckBoxSelected()); |
| 83 | 79 |
| 84 ExternalProtocolHandler::RecordMetrics( | 80 ExternalProtocolHandler::RecordMetrics( |
| 85 message_box_view_->IsCheckBoxSelected()); | 81 message_box_view_->IsCheckBoxSelected()); |
| 86 | 82 |
| 87 // Returning true closes the dialog. | 83 // Returning true closes the dialog. |
| 88 return true; | 84 return true; |
| 89 } | 85 } |
| 90 | 86 |
| 91 bool ExternalProtocolDialog::Accept() { | 87 bool ExternalProtocolDialog::Accept() { |
| 92 // We record how long it takes the user to accept an external protocol. If | 88 // We record how long it takes the user to accept an external protocol. If |
| 93 // users start accepting these dialogs too quickly, we should worry about | 89 // users start accepting these dialogs too quickly, we should worry about |
| 94 // clickjacking. | 90 // clickjacking. |
| 95 UMA_HISTOGRAM_LONG_TIMES("clickjacking.launch_url", | 91 UMA_HISTOGRAM_LONG_TIMES("clickjacking.launch_url", |
| 96 base::TimeTicks::Now() - creation_time_); | 92 base::TimeTicks::Now() - creation_time_); |
| 97 | 93 |
| 98 ExternalProtocolHandler::RecordMetrics( | 94 ExternalProtocolHandler::RecordMetrics( |
| 99 message_box_view_->IsCheckBoxSelected()); | 95 message_box_view_->IsCheckBoxSelected()); |
| 100 | 96 |
| 101 delegate_->DoAccept(delegate_->url(), | 97 delegate_->DoAccept(delegate_->url(), |
| 102 message_box_view_->IsCheckBoxSelected()); | 98 message_box_view_->IsCheckBoxSelected()); |
| 103 | 99 |
| 104 // Returning true closes the dialog. | 100 // Returning true closes the dialog. |
| 105 return true; | 101 return true; |
| 106 } | 102 } |
| 107 | 103 |
| 104 bool ExternalProtocolDialog::Close() { | |
|
msw
2016/12/08 21:37:48
Add a comment in the function body explaining why
| |
| 105 delegate_->DoCancel(delegate_->url(), false); | |
| 106 return true; | |
| 107 } | |
| 108 | |
| 108 views::View* ExternalProtocolDialog::GetContentsView() { | 109 views::View* ExternalProtocolDialog::GetContentsView() { |
| 109 return message_box_view_; | 110 return message_box_view_; |
| 110 } | 111 } |
| 111 | 112 |
| 112 views::Widget* ExternalProtocolDialog::GetWidget() { | 113 views::Widget* ExternalProtocolDialog::GetWidget() { |
| 113 return message_box_view_->GetWidget(); | 114 return message_box_view_->GetWidget(); |
| 114 } | 115 } |
| 115 | 116 |
| 116 const views::Widget* ExternalProtocolDialog::GetWidget() const { | 117 const views::Widget* ExternalProtocolDialog::GetWidget() const { |
| 117 return message_box_view_->GetWidget(); | 118 return message_box_view_->GetWidget(); |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 137 message_box_view_ = new views::MessageBoxView(params); | 138 message_box_view_ = new views::MessageBoxView(params); |
| 138 message_box_view_->SetCheckBoxLabel(delegate_->GetCheckboxText()); | 139 message_box_view_->SetCheckBoxLabel(delegate_->GetCheckboxText()); |
| 139 | 140 |
| 140 WebContents* web_contents = tab_util::GetWebContentsByID( | 141 WebContents* web_contents = tab_util::GetWebContentsByID( |
| 141 render_process_host_id_, routing_id_); | 142 render_process_host_id_, routing_id_); |
| 142 // Only launch the dialog if there is a web contents associated with the | 143 // Only launch the dialog if there is a web contents associated with the |
| 143 // request. | 144 // request. |
| 144 if (web_contents) | 145 if (web_contents) |
| 145 constrained_window::ShowWebModalDialogViews(this, web_contents); | 146 constrained_window::ShowWebModalDialogViews(this, web_contents); |
| 146 } | 147 } |
| OLD | NEW |