OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/page_info_model.h" | 5 #include "chrome/browser/page_info_model.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "app/l10n_util.h" | 9 #include "app/l10n_util.h" |
10 #include "base/callback.h" | 10 #include "base/command_line.h" |
11 #include "base/i18n/time_formatting.h" | 11 #include "base/i18n/time_formatting.h" |
12 #include "base/string_number_conversions.h" | 12 #include "base/string_number_conversions.h" |
13 #include "base/utf_string_conversions.h" | 13 #include "base/utf_string_conversions.h" |
14 #include "chrome/browser/cert_store.h" | 14 #include "chrome/browser/cert_store.h" |
15 #include "chrome/browser/prefs/pref_service.h" | 15 #include "chrome/browser/prefs/pref_service.h" |
16 #include "chrome/browser/profile.h" | 16 #include "chrome/browser/profile.h" |
17 #include "chrome/browser/ssl/ssl_manager.h" | 17 #include "chrome/browser/ssl/ssl_manager.h" |
| 18 #include "chrome/common/chrome_switches.h" |
18 #include "chrome/common/pref_names.h" | 19 #include "chrome/common/pref_names.h" |
19 #include "grit/generated_resources.h" | 20 #include "grit/generated_resources.h" |
20 #include "net/base/cert_status_flags.h" | 21 #include "net/base/cert_status_flags.h" |
21 #include "net/base/ssl_connection_status_flags.h" | 22 #include "net/base/ssl_connection_status_flags.h" |
22 #include "net/base/ssl_cipher_suite_names.h" | 23 #include "net/base/ssl_cipher_suite_names.h" |
23 #include "net/base/x509_certificate.h" | 24 #include "net/base/x509_certificate.h" |
24 | 25 |
25 PageInfoModel::PageInfoModel(Profile* profile, | 26 PageInfoModel::PageInfoModel(Profile* profile, |
26 const GURL& url, | 27 const GURL& url, |
27 const NavigationEntry::SSLStatus& ssl, | 28 const NavigationEntry::SSLStatus& ssl, |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
118 state = SECTION_STATE_ERROR; | 119 state = SECTION_STATE_ERROR; |
119 description.assign(l10n_util::GetStringFUTF16( | 120 description.assign(l10n_util::GetStringFUTF16( |
120 IDS_PAGE_INFO_SECURITY_TAB_WEAK_ENCRYPTION_CONNECTION_TEXT, | 121 IDS_PAGE_INFO_SECURITY_TAB_WEAK_ENCRYPTION_CONNECTION_TEXT, |
121 subject_name)); | 122 subject_name)); |
122 } else { | 123 } else { |
123 description.assign(l10n_util::GetStringFUTF16( | 124 description.assign(l10n_util::GetStringFUTF16( |
124 IDS_PAGE_INFO_SECURITY_TAB_ENCRYPTED_CONNECTION_TEXT, | 125 IDS_PAGE_INFO_SECURITY_TAB_ENCRYPTED_CONNECTION_TEXT, |
125 subject_name, | 126 subject_name, |
126 base::IntToString16(ssl.security_bits()))); | 127 base::IntToString16(ssl.security_bits()))); |
127 if (ssl.displayed_insecure_content() || ssl.ran_insecure_content()) { | 128 if (ssl.displayed_insecure_content() || ssl.ran_insecure_content()) { |
128 state = SECTION_STATE_ERROR; | 129 const CommandLine* command_line(CommandLine::ForCurrentProcess()); |
| 130 if (command_line->HasSwitch(switches::kEnableNewPageInfoBubble)) |
| 131 state = SECTION_STATE_WARNING; |
| 132 else |
| 133 state = SECTION_STATE_ERROR; |
129 description.assign(l10n_util::GetStringFUTF16( | 134 description.assign(l10n_util::GetStringFUTF16( |
130 IDS_PAGE_INFO_SECURITY_TAB_ENCRYPTED_SENTENCE_LINK, | 135 IDS_PAGE_INFO_SECURITY_TAB_ENCRYPTED_SENTENCE_LINK, |
131 description, | 136 description, |
132 l10n_util::GetStringUTF16(ssl.ran_insecure_content() ? | 137 l10n_util::GetStringUTF16(ssl.ran_insecure_content() ? |
133 IDS_PAGE_INFO_SECURITY_TAB_ENCRYPTED_INSECURE_CONTENT_ERROR : | 138 IDS_PAGE_INFO_SECURITY_TAB_ENCRYPTED_INSECURE_CONTENT_ERROR : |
134 IDS_PAGE_INFO_SECURITY_TAB_ENCRYPTED_INSECURE_CONTENT_WARNING))); | 139 IDS_PAGE_INFO_SECURITY_TAB_ENCRYPTED_INSECURE_CONTENT_WARNING))); |
135 } | 140 } |
136 } | 141 } |
137 | 142 |
138 if (state == SECTION_STATE_OK && ssl.displayed_insecure_content()) { | |
139 state = SECTION_STATE_WARNING; // Mixed content warrants a warning. | |
140 headline.clear(); | |
141 description.assign(l10n_util::GetStringUTF16( | |
142 IDS_PAGE_INFO_SECURITY_MIXED_CONTENT)); | |
143 } | |
144 | |
145 uint16 cipher_suite = | 143 uint16 cipher_suite = |
146 net::SSLConnectionStatusToCipherSuite(ssl.connection_status()); | 144 net::SSLConnectionStatusToCipherSuite(ssl.connection_status()); |
147 if (ssl.security_bits() > 0 && cipher_suite) { | 145 if (ssl.security_bits() > 0 && cipher_suite) { |
148 bool did_fallback = (ssl.connection_status() & | 146 bool did_fallback = (ssl.connection_status() & |
149 net::SSL_CONNECTION_SSL3_FALLBACK) != 0; | 147 net::SSL_CONNECTION_SSL3_FALLBACK) != 0; |
150 bool no_renegotiation = | 148 bool no_renegotiation = |
151 (ssl.connection_status() & | 149 (ssl.connection_status() & |
152 net::SSL_CONNECTION_NO_RENEGOTIATION_EXTENSION) != 0; | 150 net::SSL_CONNECTION_NO_RENEGOTIATION_EXTENSION) != 0; |
153 const char *key_exchange, *cipher, *mac; | 151 const char *key_exchange, *cipher, *mac; |
154 net::SSLCipherSuiteToStrings(&key_exchange, &cipher, &mac, cipher_suite); | 152 net::SSLCipherSuiteToStrings(&key_exchange, &cipher, &mac, cipher_suite); |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
249 WideToUTF16(base::TimeFormatShortDate(first_visit))), | 247 WideToUTF16(base::TimeFormatShortDate(first_visit))), |
250 SECTION_INFO_FIRST_VISIT)); | 248 SECTION_INFO_FIRST_VISIT)); |
251 } | 249 } |
252 observer_->ModelChanged(); | 250 observer_->ModelChanged(); |
253 } | 251 } |
254 | 252 |
255 // static | 253 // static |
256 void PageInfoModel::RegisterPrefs(PrefService* prefs) { | 254 void PageInfoModel::RegisterPrefs(PrefService* prefs) { |
257 prefs->RegisterDictionaryPref(prefs::kPageInfoWindowPlacement); | 255 prefs->RegisterDictionaryPref(prefs::kPageInfoWindowPlacement); |
258 } | 256 } |
OLD | NEW |