Commit 4c2da3a6 authored by estade@chromium.org's avatar estade@chromium.org

Add "remember my choice" checkbox for windows external protocol dialog.

BUG=24085

Review URL: http://codereview.chromium.org/332039

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@30225 0039d316-1c4b-4281-b951-d872f2087c98
parent e4056b93
...@@ -60,9 +60,8 @@ std::wstring ExternalProtocolDialog::GetDialogButtonLabel( ...@@ -60,9 +60,8 @@ std::wstring ExternalProtocolDialog::GetDialogButtonLabel(
MessageBoxFlags::DialogButton button) const { MessageBoxFlags::DialogButton button) const {
if (button == MessageBoxFlags::DIALOGBUTTON_OK) if (button == MessageBoxFlags::DIALOGBUTTON_OK)
return l10n_util::GetString(IDS_EXTERNAL_PROTOCOL_OK_BUTTON_TEXT); return l10n_util::GetString(IDS_EXTERNAL_PROTOCOL_OK_BUTTON_TEXT);
else
// Set the button to have a default name. return l10n_util::GetString(IDS_EXTERNAL_PROTOCOL_CANCEL_BUTTON_TEXT);
return L"";
} }
std::wstring ExternalProtocolDialog::GetWindowTitle() const { std::wstring ExternalProtocolDialog::GetWindowTitle() const {
...@@ -73,6 +72,20 @@ void ExternalProtocolDialog::DeleteDelegate() { ...@@ -73,6 +72,20 @@ void ExternalProtocolDialog::DeleteDelegate() {
delete this; delete this;
} }
bool ExternalProtocolDialog::Cancel() {
// We also get called back here if the user closes the dialog or presses
// escape. In these cases it would be preferable to ignore the state of the
// check box but MessageBox doesn't distinguish this from pressing the cancel
// button.
if (message_box_view_->IsCheckBoxSelected()) {
ExternalProtocolHandler::SetBlockState(
UTF8ToWide(url_.scheme()), ExternalProtocolHandler::BLOCK);
}
// Returning true closes the dialog.
return true;
}
bool ExternalProtocolDialog::Accept() { bool ExternalProtocolDialog::Accept() {
// We record how long it takes the user to accept an external protocol. If // We record how long it takes the user to accept an external protocol. If
// users start accepting these dialogs too quickly, we should worry about // users start accepting these dialogs too quickly, we should worry about
...@@ -80,6 +93,11 @@ bool ExternalProtocolDialog::Accept() { ...@@ -80,6 +93,11 @@ bool ExternalProtocolDialog::Accept() {
UMA_HISTOGRAM_LONG_TIMES("clickjacking.launch_url", UMA_HISTOGRAM_LONG_TIMES("clickjacking.launch_url",
base::Time::Now() - creation_time_); base::Time::Now() - creation_time_);
if (message_box_view_->IsCheckBoxSelected()) {
ExternalProtocolHandler::SetBlockState(
UTF8ToWide(url_.scheme()), ExternalProtocolHandler::DONT_BLOCK);
}
ExternalProtocolHandler::LaunchUrlWithoutSecurityCheck(url_); ExternalProtocolHandler::LaunchUrlWithoutSecurityCheck(url_);
// Returning true closes the dialog. // Returning true closes the dialog.
return true; return true;
...@@ -112,6 +130,9 @@ ExternalProtocolDialog::ExternalProtocolDialog(TabContents* tab_contents, ...@@ -112,6 +130,9 @@ ExternalProtocolDialog::ExternalProtocolDialog(TabContents* tab_contents,
message_text, message_text,
L"", L"",
kMessageWidth); kMessageWidth);
message_box_view_->SetCheckBoxLabel(
l10n_util::GetString(IDS_EXTERNAL_PROTOCOL_CHECKBOX_TEXT));
HWND root_hwnd; HWND root_hwnd;
if (tab_contents_) { if (tab_contents_) {
root_hwnd = GetAncestor(tab_contents_->GetContentNativeView(), GA_ROOT); root_hwnd = GetAncestor(tab_contents_->GetContentNativeView(), GA_ROOT);
......
...@@ -31,6 +31,7 @@ class ExternalProtocolDialog : public views::DialogDelegate { ...@@ -31,6 +31,7 @@ class ExternalProtocolDialog : public views::DialogDelegate {
MessageBoxFlags::DialogButton button) const; MessageBoxFlags::DialogButton button) const;
virtual std::wstring GetWindowTitle() const; virtual std::wstring GetWindowTitle() const;
virtual void DeleteDelegate(); virtual void DeleteDelegate();
virtual bool Cancel();
virtual bool Accept(); virtual bool Accept();
virtual views::View* GetContentsView(); virtual views::View* GetContentsView();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment