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

Side by Side Diff: chrome/browser/ssl/ssl_blocking_page.cc

Issue 10381051: Show the "cannot proceed" text only when appropriate. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 7 months 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
OLDNEW
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/ssl/ssl_blocking_page.h" 5 #include "chrome/browser/ssl/ssl_blocking_page.h"
6 6
7 #include "base/i18n/rtl.h" 7 #include "base/i18n/rtl.h"
8 #include "base/metrics/histogram.h" 8 #include "base/metrics/histogram.h"
9 #include "base/string_piece.h" 9 #include "base/string_piece.h"
10 #include "base/utf_string_conversions.h" 10 #include "base/utf_string_conversions.h"
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 } // namespace 48 } // namespace
49 49
50 // Note that we always create a navigation entry with SSL errors. 50 // Note that we always create a navigation entry with SSL errors.
51 // No error happening loading a sub-resource triggers an interstitial so far. 51 // No error happening loading a sub-resource triggers an interstitial so far.
52 SSLBlockingPage::SSLBlockingPage( 52 SSLBlockingPage::SSLBlockingPage(
53 content::WebContents* web_contents, 53 content::WebContents* web_contents,
54 int cert_error, 54 int cert_error,
55 const net::SSLInfo& ssl_info, 55 const net::SSLInfo& ssl_info,
56 const GURL& request_url, 56 const GURL& request_url,
57 bool overridable, 57 bool overridable,
58 bool strict_enforcement,
58 const base::Callback<void(bool)>& callback) 59 const base::Callback<void(bool)>& callback)
59 : callback_(callback), 60 : callback_(callback),
60 web_contents_(web_contents), 61 web_contents_(web_contents),
61 cert_error_(cert_error), 62 cert_error_(cert_error),
62 ssl_info_(ssl_info), 63 ssl_info_(ssl_info),
63 request_url_(request_url), 64 request_url_(request_url),
64 overridable_(overridable) { 65 overridable_(overridable),
66 strict_enforcement_(strict_enforcement) {
65 RecordSSLBlockingPageStats(SHOW); 67 RecordSSLBlockingPageStats(SHOW);
66 interstitial_page_ = InterstitialPage::Create( 68 interstitial_page_ = InterstitialPage::Create(
67 web_contents_, true, request_url, this); 69 web_contents_, true, request_url, this);
68 interstitial_page_->Show(); 70 interstitial_page_->Show();
69 } 71 }
70 72
71 SSLBlockingPage::~SSLBlockingPage() { 73 SSLBlockingPage::~SSLBlockingPage() {
72 if (!callback_.is_null()) { 74 if (!callback_.is_null()) {
73 // The page is closed without the user having chosen what to do, default to 75 // The page is closed without the user having chosen what to do, default to
74 // deny. 76 // deny.
75 NotifyDenyCertificate(); 77 NotifyDenyCertificate();
76 } 78 }
77 } 79 }
78 80
79 std::string SSLBlockingPage::GetHTMLContents() { 81 std::string SSLBlockingPage::GetHTMLContents() {
80 // Let's build the html error page. 82 // Let's build the html error page.
81 DictionaryValue strings; 83 DictionaryValue strings;
82 SSLErrorInfo error_info = SSLErrorInfo::CreateError( 84 SSLErrorInfo error_info = SSLErrorInfo::CreateError(
83 SSLErrorInfo::NetErrorToErrorType(cert_error_), ssl_info_.cert, 85 SSLErrorInfo::NetErrorToErrorType(cert_error_), ssl_info_.cert,
84 request_url_); 86 request_url_);
85 87
86 strings.SetString("headLine", error_info.title()); 88 strings.SetString("headLine", error_info.title());
87 strings.SetString("description", error_info.details()); 89 strings.SetString("description", error_info.details());
88 90
89 strings.SetString("moreInfoTitle", 91 strings.SetString("moreInfoTitle",
90 l10n_util::GetStringUTF16(IDS_CERT_ERROR_EXTRA_INFO_TITLE)); 92 l10n_util::GetStringUTF16(IDS_CERT_ERROR_EXTRA_INFO_TITLE));
91 SetExtraInfo(&strings, error_info.extra_information()); 93 SetExtraInfo(&strings, error_info.extra_information());
92 94
93 int resource_id; 95 int resource_id;
94 if (overridable_) { 96 if (overridable_ && !strict_enforcement_) {
95 resource_id = IDR_SSL_ROAD_BLOCK_HTML; 97 resource_id = IDR_SSL_ROAD_BLOCK_HTML;
96 strings.SetString("title", 98 strings.SetString("title",
97 l10n_util::GetStringUTF16(IDS_SSL_BLOCKING_PAGE_TITLE)); 99 l10n_util::GetStringUTF16(IDS_SSL_BLOCKING_PAGE_TITLE));
98 strings.SetString("proceed", 100 strings.SetString("proceed",
99 l10n_util::GetStringUTF16(IDS_SSL_BLOCKING_PAGE_PROCEED)); 101 l10n_util::GetStringUTF16(IDS_SSL_BLOCKING_PAGE_PROCEED));
100 strings.SetString("exit", 102 strings.SetString("exit",
101 l10n_util::GetStringUTF16(IDS_SSL_BLOCKING_PAGE_EXIT)); 103 l10n_util::GetStringUTF16(IDS_SSL_BLOCKING_PAGE_EXIT));
102 strings.SetString("shouldNotProceed", 104 strings.SetString("shouldNotProceed",
103 l10n_util::GetStringUTF16( 105 l10n_util::GetStringUTF16(
104 IDS_SSL_BLOCKING_PAGE_SHOULD_NOT_PROCEED)); 106 IDS_SSL_BLOCKING_PAGE_SHOULD_NOT_PROCEED));
105 } else { 107 } else {
106 resource_id = IDR_SSL_ERROR_HTML; 108 resource_id = IDR_SSL_ERROR_HTML;
107 strings.SetString("title", 109 strings.SetString("title",
108 l10n_util::GetStringUTF16(IDS_SSL_ERROR_PAGE_TITLE)); 110 l10n_util::GetStringUTF16(IDS_SSL_ERROR_PAGE_TITLE));
109 strings.SetString("back", 111 strings.SetString("back",
110 l10n_util::GetStringUTF16(IDS_SSL_ERROR_PAGE_BACK)); 112 l10n_util::GetStringUTF16(IDS_SSL_ERROR_PAGE_BACK));
111 strings.SetString("cannotProceed", 113 if (strict_enforcement_)
112 l10n_util::GetStringUTF16( 114 strings.SetString("cannotProceed",
Ryan Sleevi 2012/05/08 17:53:49 nit { }
palmer 2012/05/08 18:40:43 Done.
113 IDS_SSL_ERROR_PAGE_CANNOT_PROCEED)); 115 l10n_util::GetStringUTF16(
116 IDS_SSL_ERROR_PAGE_CANNOT_PROCEED));
114 } 117 }
115 118
116 strings.SetString("textdirection", base::i18n::IsRTL() ? "rtl" : "ltr"); 119 strings.SetString("textdirection", base::i18n::IsRTL() ? "rtl" : "ltr");
117 120
118 base::StringPiece html( 121 base::StringPiece html(
119 ResourceBundle::GetSharedInstance().GetRawDataResource(resource_id)); 122 ResourceBundle::GetSharedInstance().GetRawDataResource(resource_id));
120 123
121 return jstemplate_builder::GetI18nTemplateHtml(html, &strings); 124 return jstemplate_builder::GetI18nTemplateHtml(html, &strings);
122 } 125 }
123 126
(...skipping 18 matching lines...) Expand all
142 } else { 145 } else {
143 interstitial_page_->DontProceed(); 146 interstitial_page_->DontProceed();
144 } 147 }
145 } 148 }
146 149
147 void SSLBlockingPage::OverrideRendererPrefs( 150 void SSLBlockingPage::OverrideRendererPrefs(
148 content::RendererPreferences* prefs) { 151 content::RendererPreferences* prefs) {
149 Profile* profile = Profile::FromBrowserContext( 152 Profile* profile = Profile::FromBrowserContext(
150 web_contents_->GetBrowserContext()); 153 web_contents_->GetBrowserContext());
151 renderer_preferences_util::UpdateFromSystemSettings(prefs, profile); 154 renderer_preferences_util::UpdateFromSystemSettings(prefs, profile);
152 } 155 }
153 156
154 void SSLBlockingPage::OnProceed() { 157 void SSLBlockingPage::OnProceed() {
155 RecordSSLBlockingPageStats(PROCEED); 158 RecordSSLBlockingPageStats(PROCEED);
156 159
157 // Accepting the certificate resumes the loading of the page. 160 // Accepting the certificate resumes the loading of the page.
158 NotifyAllowCertificate(); 161 NotifyAllowCertificate();
159 } 162 }
160 163
161 void SSLBlockingPage::OnDontProceed() { 164 void SSLBlockingPage::OnDontProceed() {
162 RecordSSLBlockingPageStats(DONT_PROCEED); 165 RecordSSLBlockingPageStats(DONT_PROCEED);
(...skipping 28 matching lines...) Expand all
191 "moreInfo1", "moreInfo2", "moreInfo3", "moreInfo4", "moreInfo5" 194 "moreInfo1", "moreInfo2", "moreInfo3", "moreInfo4", "moreInfo5"
192 }; 195 };
193 int i; 196 int i;
194 for (i = 0; i < static_cast<int>(extra_info.size()); i++) { 197 for (i = 0; i < static_cast<int>(extra_info.size()); i++) {
195 strings->SetString(keys[i], extra_info[i]); 198 strings->SetString(keys[i], extra_info[i]);
196 } 199 }
197 for (; i < 5; i++) { 200 for (; i < 5; i++) {
198 strings->SetString(keys[i], ""); 201 strings->SetString(keys[i], "");
199 } 202 }
200 } 203 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698