Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(568)

Side by Side Diff: chrome/browser/views/external_protocol_dialog.cc

Issue 332039: Add "remember my choice" checkbox for windows external protocol dialog.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 11 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/views/external_protocol_dialog.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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/views/external_protocol_dialog.h" 5 #include "chrome/browser/views/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 "base/histogram.h" 9 #include "base/histogram.h"
10 #include "base/registry.h" 10 #include "base/registry.h"
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 // ExternalProtocolDialog, views::DialogDelegate implementation: 53 // ExternalProtocolDialog, views::DialogDelegate implementation:
54 54
55 int ExternalProtocolDialog::GetDefaultDialogButton() const { 55 int ExternalProtocolDialog::GetDefaultDialogButton() const {
56 return MessageBoxFlags::DIALOGBUTTON_CANCEL; 56 return MessageBoxFlags::DIALOGBUTTON_CANCEL;
57 } 57 }
58 58
59 std::wstring ExternalProtocolDialog::GetDialogButtonLabel( 59 std::wstring ExternalProtocolDialog::GetDialogButtonLabel(
60 MessageBoxFlags::DialogButton button) const { 60 MessageBoxFlags::DialogButton button) const {
61 if (button == MessageBoxFlags::DIALOGBUTTON_OK) 61 if (button == MessageBoxFlags::DIALOGBUTTON_OK)
62 return l10n_util::GetString(IDS_EXTERNAL_PROTOCOL_OK_BUTTON_TEXT); 62 return l10n_util::GetString(IDS_EXTERNAL_PROTOCOL_OK_BUTTON_TEXT);
63 63 else
64 // Set the button to have a default name. 64 return l10n_util::GetString(IDS_EXTERNAL_PROTOCOL_CANCEL_BUTTON_TEXT);
65 return L"";
66 } 65 }
67 66
68 std::wstring ExternalProtocolDialog::GetWindowTitle() const { 67 std::wstring ExternalProtocolDialog::GetWindowTitle() const {
69 return l10n_util::GetString(IDS_EXTERNAL_PROTOCOL_TITLE); 68 return l10n_util::GetString(IDS_EXTERNAL_PROTOCOL_TITLE);
70 } 69 }
71 70
72 void ExternalProtocolDialog::DeleteDelegate() { 71 void ExternalProtocolDialog::DeleteDelegate() {
73 delete this; 72 delete this;
74 } 73 }
75 74
75 bool ExternalProtocolDialog::Cancel() {
76 // We also get called back here if the user closes the dialog or presses
77 // escape. In these cases it would be preferable to ignore the state of the
78 // check box but MessageBox doesn't distinguish this from pressing the cancel
79 // button.
80 if (message_box_view_->IsCheckBoxSelected()) {
81 ExternalProtocolHandler::SetBlockState(
82 UTF8ToWide(url_.scheme()), ExternalProtocolHandler::BLOCK);
83 }
84
85 // Returning true closes the dialog.
86 return true;
87 }
88
76 bool ExternalProtocolDialog::Accept() { 89 bool ExternalProtocolDialog::Accept() {
77 // We record how long it takes the user to accept an external protocol. If 90 // We record how long it takes the user to accept an external protocol. If
78 // users start accepting these dialogs too quickly, we should worry about 91 // users start accepting these dialogs too quickly, we should worry about
79 // clickjacking. 92 // clickjacking.
80 UMA_HISTOGRAM_LONG_TIMES("clickjacking.launch_url", 93 UMA_HISTOGRAM_LONG_TIMES("clickjacking.launch_url",
81 base::Time::Now() - creation_time_); 94 base::Time::Now() - creation_time_);
82 95
96 if (message_box_view_->IsCheckBoxSelected()) {
97 ExternalProtocolHandler::SetBlockState(
98 UTF8ToWide(url_.scheme()), ExternalProtocolHandler::DONT_BLOCK);
99 }
100
83 ExternalProtocolHandler::LaunchUrlWithoutSecurityCheck(url_); 101 ExternalProtocolHandler::LaunchUrlWithoutSecurityCheck(url_);
84 // Returning true closes the dialog. 102 // Returning true closes the dialog.
85 return true; 103 return true;
86 } 104 }
87 105
88 views::View* ExternalProtocolDialog::GetContentsView() { 106 views::View* ExternalProtocolDialog::GetContentsView() {
89 return message_box_view_; 107 return message_box_view_;
90 } 108 }
91 109
92 /////////////////////////////////////////////////////////////////////////////// 110 ///////////////////////////////////////////////////////////////////////////////
(...skipping 12 matching lines...) Expand all
105 123
106 message_text += l10n_util::GetStringF( 124 message_text += l10n_util::GetStringF(
107 IDS_EXTERNAL_PROTOCOL_APPLICATION_TO_LAUNCH, command) + L"\n\n"; 125 IDS_EXTERNAL_PROTOCOL_APPLICATION_TO_LAUNCH, command) + L"\n\n";
108 126
109 message_text += l10n_util::GetString(IDS_EXTERNAL_PROTOCOL_WARNING); 127 message_text += l10n_util::GetString(IDS_EXTERNAL_PROTOCOL_WARNING);
110 128
111 message_box_view_ = new MessageBoxView(MessageBoxFlags::kIsConfirmMessageBox, 129 message_box_view_ = new MessageBoxView(MessageBoxFlags::kIsConfirmMessageBox,
112 message_text, 130 message_text,
113 L"", 131 L"",
114 kMessageWidth); 132 kMessageWidth);
133 message_box_view_->SetCheckBoxLabel(
134 l10n_util::GetString(IDS_EXTERNAL_PROTOCOL_CHECKBOX_TEXT));
135
115 HWND root_hwnd; 136 HWND root_hwnd;
116 if (tab_contents_) { 137 if (tab_contents_) {
117 root_hwnd = GetAncestor(tab_contents_->GetContentNativeView(), GA_ROOT); 138 root_hwnd = GetAncestor(tab_contents_->GetContentNativeView(), GA_ROOT);
118 } else { 139 } else {
119 // Dialog is top level if we don't have a tab_contents associated with us. 140 // Dialog is top level if we don't have a tab_contents associated with us.
120 root_hwnd = NULL; 141 root_hwnd = NULL;
121 } 142 }
122 143
123 views::Window::CreateChromeWindow(root_hwnd, gfx::Rect(), this)->Show(); 144 views::Window::CreateChromeWindow(root_hwnd, gfx::Rect(), this)->Show();
124 } 145 }
(...skipping 11 matching lines...) Expand all
136 std::wstring parameters = url_spec.substr(split_offset + 1, 157 std::wstring parameters = url_spec.substr(split_offset + 1,
137 url_spec.length() - 1); 158 url_spec.length() - 1);
138 std::wstring application_to_launch; 159 std::wstring application_to_launch;
139 if (cmd_key.ReadValue(NULL, &application_to_launch)) { 160 if (cmd_key.ReadValue(NULL, &application_to_launch)) {
140 ReplaceSubstringsAfterOffset(&application_to_launch, 0, L"%1", parameters); 161 ReplaceSubstringsAfterOffset(&application_to_launch, 0, L"%1", parameters);
141 return application_to_launch; 162 return application_to_launch;
142 } else { 163 } else {
143 return std::wstring(); 164 return std::wstring();
144 } 165 }
145 } 166 }
OLDNEW
« no previous file with comments | « chrome/browser/views/external_protocol_dialog.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698