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/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
87 IDS_PAGE_INFO_SECURITY_TAB_UNKNOWN_PARTY)); | 87 IDS_PAGE_INFO_SECURITY_TAB_UNKNOWN_PARTY)); |
88 } else { | 88 } else { |
89 description.assign(l10n_util::GetStringFUTF16( | 89 description.assign(l10n_util::GetStringFUTF16( |
90 IDS_PAGE_INFO_SECURITY_TAB_SECURE_IDENTITY, issuer_name)); | 90 IDS_PAGE_INFO_SECURITY_TAB_SECURE_IDENTITY, issuer_name)); |
91 } | 91 } |
92 } | 92 } |
93 } else { | 93 } else { |
94 // HTTP or bad HTTPS. | 94 // HTTP or bad HTTPS. |
95 description.assign(l10n_util::GetStringUTF16( | 95 description.assign(l10n_util::GetStringUTF16( |
96 IDS_PAGE_INFO_SECURITY_TAB_INSECURE_IDENTITY)); | 96 IDS_PAGE_INFO_SECURITY_TAB_INSECURE_IDENTITY)); |
97 state = SECTION_STATE_ERROR; | 97 state = ssl.security_style() == SECURITY_STYLE_UNAUTHENTICATED ? |
| 98 SECTION_STATE_WARNING_MAJOR : SECTION_STATE_ERROR; |
98 } | 99 } |
99 sections_.push_back(SectionInfo( | 100 sections_.push_back(SectionInfo( |
100 state, | 101 state, |
101 l10n_util::GetStringUTF16(IDS_PAGE_INFO_SECURITY_TAB_IDENTITY_TITLE), | 102 l10n_util::GetStringUTF16(IDS_PAGE_INFO_SECURITY_TAB_IDENTITY_TITLE), |
102 headline, | 103 headline, |
103 description, | 104 description, |
104 SECTION_INFO_IDENTITY)); | 105 SECTION_INFO_IDENTITY)); |
105 | 106 |
106 // Connection section. | 107 // Connection section. |
107 // We consider anything less than 80 bits encryption to be weak encryption. | 108 // We consider anything less than 80 bits encryption to be weak encryption. |
108 // TODO(wtc): Bug 1198735: report mixed/unsafe content for unencrypted and | 109 // TODO(wtc): Bug 1198735: report mixed/unsafe content for unencrypted and |
109 // weakly encrypted connections. | 110 // weakly encrypted connections. |
110 state = SECTION_STATE_OK; | 111 state = SECTION_STATE_OK; |
111 headline.clear(); | 112 headline.clear(); |
112 description.clear(); | 113 description.clear(); |
113 if (ssl.security_bits() < 0) { | 114 if (ssl.security_bits() < 0) { |
114 // Security strength is unknown. Say nothing. | 115 // Security strength is unknown. Say nothing. |
115 state = SECTION_STATE_ERROR; | 116 state = SECTION_STATE_ERROR; |
116 } else if (ssl.security_bits() == 0) { | 117 } else if (ssl.security_bits() == 0) { |
117 state = SECTION_STATE_ERROR; | 118 state = ssl.security_style() == SECURITY_STYLE_UNAUTHENTICATED ? |
| 119 SECTION_STATE_WARNING_MAJOR : SECTION_STATE_ERROR; |
118 description.assign(l10n_util::GetStringFUTF16( | 120 description.assign(l10n_util::GetStringFUTF16( |
119 IDS_PAGE_INFO_SECURITY_TAB_NOT_ENCRYPTED_CONNECTION_TEXT, | 121 IDS_PAGE_INFO_SECURITY_TAB_NOT_ENCRYPTED_CONNECTION_TEXT, |
120 subject_name)); | 122 subject_name)); |
121 } else if (ssl.security_bits() < 80) { | 123 } else if (ssl.security_bits() < 80) { |
122 state = SECTION_STATE_ERROR; | 124 state = SECTION_STATE_ERROR; |
123 description.assign(l10n_util::GetStringFUTF16( | 125 description.assign(l10n_util::GetStringFUTF16( |
124 IDS_PAGE_INFO_SECURITY_TAB_WEAK_ENCRYPTION_CONNECTION_TEXT, | 126 IDS_PAGE_INFO_SECURITY_TAB_WEAK_ENCRYPTION_CONNECTION_TEXT, |
125 subject_name)); | 127 subject_name)); |
126 } else { | 128 } else { |
127 description.assign(l10n_util::GetStringFUTF16( | 129 description.assign(l10n_util::GetStringFUTF16( |
128 IDS_PAGE_INFO_SECURITY_TAB_ENCRYPTED_CONNECTION_TEXT, | 130 IDS_PAGE_INFO_SECURITY_TAB_ENCRYPTED_CONNECTION_TEXT, |
129 subject_name, | 131 subject_name, |
130 base::IntToString16(ssl.security_bits()))); | 132 base::IntToString16(ssl.security_bits()))); |
131 if (ssl.displayed_insecure_content() || ssl.ran_insecure_content()) { | 133 if (ssl.displayed_insecure_content() || ssl.ran_insecure_content()) { |
| 134 // The old SSL dialog only had good and bad state, so for the old |
| 135 // implementation we raise an error on finding mixed content. The new |
| 136 // SSL info bubble has a warning state for displaying insecure content, |
| 137 // so we check. The command line check will go away once we eliminate |
| 138 // the old dialogs. |
132 const CommandLine* command_line(CommandLine::ForCurrentProcess()); | 139 const CommandLine* command_line(CommandLine::ForCurrentProcess()); |
133 if (command_line->HasSwitch(switches::kEnableNewPageInfoBubble)) | 140 if (command_line->HasSwitch(switches::kEnableNewPageInfoBubble) && |
134 state = SECTION_STATE_WARNING; | 141 !ssl.ran_insecure_content()) { |
135 else | 142 state = SECTION_STATE_WARNING_MINOR; |
| 143 } else { |
136 state = SECTION_STATE_ERROR; | 144 state = SECTION_STATE_ERROR; |
| 145 } |
137 description.assign(l10n_util::GetStringFUTF16( | 146 description.assign(l10n_util::GetStringFUTF16( |
138 IDS_PAGE_INFO_SECURITY_TAB_ENCRYPTED_SENTENCE_LINK, | 147 IDS_PAGE_INFO_SECURITY_TAB_ENCRYPTED_SENTENCE_LINK, |
139 description, | 148 description, |
140 l10n_util::GetStringUTF16(ssl.ran_insecure_content() ? | 149 l10n_util::GetStringUTF16(ssl.ran_insecure_content() ? |
141 IDS_PAGE_INFO_SECURITY_TAB_ENCRYPTED_INSECURE_CONTENT_ERROR : | 150 IDS_PAGE_INFO_SECURITY_TAB_ENCRYPTED_INSECURE_CONTENT_ERROR : |
142 IDS_PAGE_INFO_SECURITY_TAB_ENCRYPTED_INSECURE_CONTENT_WARNING))); | 151 IDS_PAGE_INFO_SECURITY_TAB_ENCRYPTED_INSECURE_CONTENT_WARNING))); |
143 } | 152 } |
144 } | 153 } |
145 | 154 |
146 uint16 cipher_suite = | 155 uint16 cipher_suite = |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
228 return; | 237 return; |
229 } | 238 } |
230 | 239 |
231 bool visited_before_today = false; | 240 bool visited_before_today = false; |
232 if (count) { | 241 if (count) { |
233 base::Time today = base::Time::Now().LocalMidnight(); | 242 base::Time today = base::Time::Now().LocalMidnight(); |
234 base::Time first_visit_midnight = first_visit.LocalMidnight(); | 243 base::Time first_visit_midnight = first_visit.LocalMidnight(); |
235 visited_before_today = (first_visit_midnight < today); | 244 visited_before_today = (first_visit_midnight < today); |
236 } | 245 } |
237 | 246 |
| 247 // We only show the Site Information heading for the new dialogs. |
| 248 string16 title; |
| 249 const CommandLine* command_line(CommandLine::ForCurrentProcess()); |
| 250 if (command_line->HasSwitch(switches::kEnableNewPageInfoBubble)) |
| 251 title = l10n_util::GetStringUTF16(IDS_PAGE_INFO_SITE_INFO_TITLE); |
| 252 |
238 if (!visited_before_today) { | 253 if (!visited_before_today) { |
239 sections_.push_back(SectionInfo( | 254 sections_.push_back(SectionInfo( |
240 SECTION_STATE_ERROR, | 255 SECTION_STATE_ERROR, |
241 l10n_util::GetStringUTF16( | 256 l10n_util::GetStringUTF16( |
242 IDS_PAGE_INFO_SECURITY_TAB_PERSONAL_HISTORY_TITLE), | 257 IDS_PAGE_INFO_SECURITY_TAB_PERSONAL_HISTORY_TITLE), |
243 string16(), | 258 title, |
244 l10n_util::GetStringUTF16( | 259 l10n_util::GetStringUTF16( |
245 IDS_PAGE_INFO_SECURITY_TAB_FIRST_VISITED_TODAY), | 260 IDS_PAGE_INFO_SECURITY_TAB_FIRST_VISITED_TODAY), |
246 SECTION_INFO_FIRST_VISIT)); | 261 SECTION_INFO_FIRST_VISIT)); |
247 } else { | 262 } else { |
248 sections_.push_back(SectionInfo( | 263 sections_.push_back(SectionInfo( |
249 SECTION_STATE_OK, | 264 SECTION_STATE_OK, |
250 l10n_util::GetStringUTF16( | 265 l10n_util::GetStringUTF16( |
251 IDS_PAGE_INFO_SECURITY_TAB_PERSONAL_HISTORY_TITLE), | 266 IDS_PAGE_INFO_SECURITY_TAB_PERSONAL_HISTORY_TITLE), |
252 string16(), | 267 title, |
253 l10n_util::GetStringFUTF16( | 268 l10n_util::GetStringFUTF16( |
254 IDS_PAGE_INFO_SECURITY_TAB_VISITED_BEFORE_TODAY, | 269 IDS_PAGE_INFO_SECURITY_TAB_VISITED_BEFORE_TODAY, |
255 WideToUTF16(base::TimeFormatShortDate(first_visit))), | 270 WideToUTF16(base::TimeFormatShortDate(first_visit))), |
256 SECTION_INFO_FIRST_VISIT)); | 271 SECTION_INFO_FIRST_VISIT)); |
257 } | 272 } |
258 observer_->ModelChanged(); | 273 observer_->ModelChanged(); |
259 } | 274 } |
260 | 275 |
261 // static | 276 // static |
262 void PageInfoModel::RegisterPrefs(PrefService* prefs) { | 277 void PageInfoModel::RegisterPrefs(PrefService* prefs) { |
263 prefs->RegisterDictionaryPref(prefs::kPageInfoWindowPlacement); | 278 prefs->RegisterDictionaryPref(prefs::kPageInfoWindowPlacement); |
264 } | 279 } |
265 | 280 |
266 PageInfoModel::PageInfoModel() { | 281 PageInfoModel::PageInfoModel() { |
267 } | 282 } |
OLD | NEW |