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

Side by Side Diff: chrome/browser/website_settings.cc

Issue 10440092: Remove any platform specific code from the chrome/browser/website_settings.* . (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: sort includes Created 8 years, 6 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
« no previous file with comments | « chrome/browser/website_settings.h ('k') | chrome/browser/website_settings_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "chrome/browser/website_settings.h"
6
7 #include <string>
8 #include <vector>
9
10 #include "base/bind.h"
11 #include "base/bind_helpers.h"
12 #include "base/i18n/time_formatting.h"
13 #include "base/string_number_conversions.h"
14 #include "base/utf_string_conversions.h"
15 #include "base/values.h"
16 #include "chrome/browser/browsing_data_cookie_helper.h"
17 #include "chrome/browser/browsing_data_database_helper.h"
18 #include "chrome/browser/browsing_data_local_storage_helper.h"
19 #include "chrome/browser/browsing_data_indexed_db_helper.h"
20 #include "chrome/browser/browsing_data_file_system_helper.h"
21 #include "chrome/browser/browsing_data_server_bound_cert_helper.h"
22 #include "chrome/browser/content_settings/content_settings_utils.h"
23 #include "chrome/browser/content_settings/host_content_settings_map.h"
24 #include "chrome/browser/content_settings/local_shared_objects_container.h"
25 #include "chrome/browser/profiles/profile.h"
26 #include "chrome/browser/ssl/ssl_error_info.h"
27 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h"
28 #include "chrome/browser/ui/website_settings_ui.h"
29 #include "chrome/common/content_settings_pattern.h"
30 #include "content/public/browser/browser_thread.h"
31 #include "content/public/browser/cert_store.h"
32 #include "content/public/common/ssl_status.h"
33 #include "content/public/common/url_constants.h"
34 #include "grit/chromium_strings.h"
35 #include "grit/generated_resources.h"
36 #include "net/base/cert_status_flags.h"
37 #include "net/base/registry_controlled_domain.h"
38 #include "net/base/ssl_cipher_suite_names.h"
39 #include "net/base/ssl_connection_status_flags.h"
40 #include "net/base/x509_certificate.h"
41 #include "ui/base/l10n/l10n_util.h"
42 #include "ui/base/resource/resource_bundle.h"
43
44 #if defined(TOOLKIT_GTK)
45 #include "chrome/browser/ui/gtk/website_settings_popup_gtk.h"
46 #endif
47
48 using content::BrowserThread;
49
50 namespace {
51
52 ContentSettingsType kPermissionType[] = {
53 CONTENT_SETTINGS_TYPE_POPUPS,
54 CONTENT_SETTINGS_TYPE_PLUGINS,
55 CONTENT_SETTINGS_TYPE_NOTIFICATIONS,
56 CONTENT_SETTINGS_TYPE_GEOLOCATION,
57 };
58
59 } // namespace
60
61 WebsiteSettings::WebsiteSettings(
62 WebsiteSettingsUI* ui,
63 Profile* profile,
64 TabSpecificContentSettings* tab_specific_content_settings,
65 const GURL& url,
66 const content::SSLStatus& ssl,
67 content::CertStore* cert_store)
68 : TabSpecificContentSettings::SiteDataObserver(
69 tab_specific_content_settings),
70 ui_(ui),
71 site_url_(url),
72 site_identity_status_(SITE_IDENTITY_STATUS_UNKNOWN),
73 cert_id_(0),
74 site_connection_status_(SITE_CONNECTION_STATUS_UNKNOWN),
75 cert_store_(cert_store),
76 content_settings_(profile->GetHostContentSettingsMap()) {
77 ui_->SetPresenter(this);
78 Init(profile, url, ssl);
79
80 HistoryService* history_service =
81 profile->GetHistoryService(Profile::EXPLICIT_ACCESS);
82 if (history_service) {
83 history_service->GetVisibleVisitCountToHost(
84 site_url_,
85 &visit_count_request_consumer_,
86 base::Bind(&WebsiteSettings::OnGotVisitCountToHost,
87 base::Unretained(this)));
88 }
89
90 PresentSitePermissions();
91 PresentSiteData();
92 PresentSiteIdentity();
93 PresentHistoryInfo(base::Time());
94 }
95
96 WebsiteSettings::~WebsiteSettings() {
97 }
98
99 void WebsiteSettings::OnUIClosing() {
100 ui_->SetPresenter(NULL);
101 delete this;
102 }
103
104 void WebsiteSettings::OnSitePermissionChanged(ContentSettingsType type,
105 ContentSetting setting) {
106 ContentSettingsPattern primary_pattern;
107 ContentSettingsPattern secondary_pattern;
108 switch (type) {
109 case CONTENT_SETTINGS_TYPE_GEOLOCATION:
110 // TODO(markusheintz): The rule we create here should also change the
111 // location permission for iframed content.
112 primary_pattern = ContentSettingsPattern::FromURLNoWildcard(site_url_);
113 secondary_pattern = ContentSettingsPattern::FromURLNoWildcard(site_url_);
114 break;
115 case CONTENT_SETTINGS_TYPE_NOTIFICATIONS:
116 primary_pattern = ContentSettingsPattern::FromURLNoWildcard(site_url_);
117 secondary_pattern = ContentSettingsPattern::Wildcard();
118 break;
119 case CONTENT_SETTINGS_TYPE_PLUGINS:
120 case CONTENT_SETTINGS_TYPE_POPUPS:
121 primary_pattern = ContentSettingsPattern::FromURL(site_url_);
122 secondary_pattern = ContentSettingsPattern::Wildcard();
123 break;
124 default:
125 NOTREACHED() << "ContentSettingsType " << type << "is not supported.";
126 break;
127 }
128
129 // Permission settings are specified via rules. There exists always at least
130 // one rule for the default setting. Get the rule that currently defines
131 // the permission for the given permission |type|. Then test whether the
132 // existing rule is more specific than the rule we are about to create. If
133 // the existing rule is more specific, than change the existing rule instead
134 // of creating a new rule that would be hidden behind the existing rule.
135 content_settings::SettingInfo info;
136 scoped_ptr<Value> v(content_settings_->GetWebsiteSetting(
137 site_url_, site_url_, type, "", &info));
138 DCHECK(info.source == content_settings::SETTING_SOURCE_USER);
139 ContentSettingsPattern::Relation r1 =
140 info.primary_pattern.Compare(primary_pattern);
141 DCHECK(r1 != ContentSettingsPattern::DISJOINT_ORDER_POST &&
142 r1 != ContentSettingsPattern::DISJOINT_ORDER_PRE);
143 if (r1 == ContentSettingsPattern::PREDECESSOR) {
144 primary_pattern = info.primary_pattern;
145 } else if (r1 == ContentSettingsPattern::IDENTITY) {
146 ContentSettingsPattern::Relation r2 =
147 info.secondary_pattern.Compare(secondary_pattern);
148 DCHECK(r2 != ContentSettingsPattern::DISJOINT_ORDER_POST &&
149 r2 != ContentSettingsPattern::DISJOINT_ORDER_PRE);
150 if (r2 == ContentSettingsPattern::PREDECESSOR)
151 secondary_pattern = info.secondary_pattern;
152 }
153
154 Value* value = NULL;
155 if (setting != CONTENT_SETTING_DEFAULT)
156 value = Value::CreateIntegerValue(setting);
157 content_settings_->SetWebsiteSetting(
158 primary_pattern, secondary_pattern, type, "", value);
159 }
160
161 void WebsiteSettings::OnGotVisitCountToHost(HistoryService::Handle handle,
162 bool found_visits,
163 int visit_count,
164 base::Time first_visit) {
165 if (!found_visits) {
166 // This indicates an error, such as the page's URL scheme wasn't
167 // http/https.
168 first_visit = base::Time();
169 } else if (visit_count == 0) {
170 first_visit = base::Time::Now();
171 }
172 PresentHistoryInfo(first_visit);
173 }
174
175 void WebsiteSettings::OnSiteDataAccessed() {
176 PresentSiteData();
177 }
178
179 void WebsiteSettings::Init(Profile* profile,
180 const GURL& url,
181 const content::SSLStatus& ssl) {
182 if (url.SchemeIs(chrome::kChromeUIScheme)) {
183 site_identity_status_ = SITE_IDENTITY_STATUS_INTERNAL_PAGE;
184 site_identity_details_ =
185 l10n_util::GetStringUTF16(IDS_PAGE_INFO_INTERNAL_PAGE);
186 site_connection_status_ = SITE_CONNECTION_STATUS_INTERNAL_PAGE;
187 return;
188 }
189
190 scoped_refptr<net::X509Certificate> cert;
191
192 // Identity section.
193 string16 subject_name(UTF8ToUTF16(url.host()));
194 if (subject_name.empty()) {
195 subject_name.assign(
196 l10n_util::GetStringUTF16(IDS_PAGE_INFO_SECURITY_TAB_UNKNOWN_PARTY));
197 }
198
199 cert_id_ = ssl.cert_id;
200
201 if (ssl.cert_id &&
202 cert_store_->RetrieveCert(ssl.cert_id, &cert) &&
203 (!net::IsCertStatusError(ssl.cert_status) ||
204 net::IsCertStatusMinorError(ssl.cert_status))) {
205 // There are no major errors. Check for minor errors.
206 if (net::IsCertStatusMinorError(ssl.cert_status)) {
207 site_identity_status_ = SITE_IDENTITY_STATUS_CERT_REVOCATION_UNKNOWN;
208 string16 issuer_name(UTF8ToUTF16(cert->issuer().GetDisplayName()));
209 if (issuer_name.empty()) {
210 issuer_name.assign(l10n_util::GetStringUTF16(
211 IDS_PAGE_INFO_SECURITY_TAB_UNKNOWN_PARTY));
212 }
213 site_identity_details_.assign(l10n_util::GetStringFUTF16(
214 IDS_PAGE_INFO_SECURITY_TAB_SECURE_IDENTITY, issuer_name));
215
216 site_identity_details_ += ASCIIToUTF16("\n\n");
217 if (ssl.cert_status & net::CERT_STATUS_UNABLE_TO_CHECK_REVOCATION) {
218 site_identity_details_ += l10n_util::GetStringUTF16(
219 IDS_PAGE_INFO_SECURITY_TAB_UNABLE_TO_CHECK_REVOCATION);
220 } else if (ssl.cert_status & net::CERT_STATUS_NO_REVOCATION_MECHANISM) {
221 site_identity_details_ += l10n_util::GetStringUTF16(
222 IDS_PAGE_INFO_SECURITY_TAB_NO_REVOCATION_MECHANISM);
223 } else {
224 NOTREACHED() << "Need to specify string for this warning";
225 }
226 } else if (ssl.cert_status & net::CERT_STATUS_IS_EV) {
227 // EV HTTPS page.
228 site_identity_status_ = SITE_IDENTITY_STATUS_EV_CERT;
229 DCHECK(!cert->subject().organization_names.empty());
230 organization_name_ = UTF8ToUTF16(cert->subject().organization_names[0]);
231 // An EV Cert is required to have a city (localityName) and country but
232 // state is "if any".
233 DCHECK(!cert->subject().locality_name.empty());
234 DCHECK(!cert->subject().country_name.empty());
235 string16 locality;
236 if (!cert->subject().state_or_province_name.empty()) {
237 locality = l10n_util::GetStringFUTF16(
238 IDS_PAGEINFO_ADDRESS,
239 UTF8ToUTF16(cert->subject().locality_name),
240 UTF8ToUTF16(cert->subject().state_or_province_name),
241 UTF8ToUTF16(cert->subject().country_name));
242 } else {
243 locality = l10n_util::GetStringFUTF16(
244 IDS_PAGEINFO_PARTIAL_ADDRESS,
245 UTF8ToUTF16(cert->subject().locality_name),
246 UTF8ToUTF16(cert->subject().country_name));
247 }
248 DCHECK(!cert->subject().organization_names.empty());
249 site_identity_details_.assign(l10n_util::GetStringFUTF16(
250 IDS_PAGE_INFO_SECURITY_TAB_SECURE_IDENTITY_EV,
251 UTF8ToUTF16(cert->subject().organization_names[0]),
252 locality,
253 UTF8ToUTF16(cert->issuer().GetDisplayName())));
254 } else if (ssl.cert_status & net::CERT_STATUS_IS_DNSSEC) {
255 // DNSSEC authenticated page.
256 site_identity_status_ = SITE_IDENTITY_STATUS_DNSSEC_CERT;
257 site_identity_details_.assign(l10n_util::GetStringFUTF16(
258 IDS_PAGE_INFO_SECURITY_TAB_SECURE_IDENTITY, UTF8ToUTF16("DNSSEC")));
259 } else {
260 // Non-EV OK HTTPS page.
261 site_identity_status_ = SITE_IDENTITY_STATUS_CERT;
262 string16 issuer_name(UTF8ToUTF16(cert->issuer().GetDisplayName()));
263 if (issuer_name.empty()) {
264 issuer_name.assign(l10n_util::GetStringUTF16(
265 IDS_PAGE_INFO_SECURITY_TAB_UNKNOWN_PARTY));
266 }
267 site_identity_details_.assign(l10n_util::GetStringFUTF16(
268 IDS_PAGE_INFO_SECURITY_TAB_SECURE_IDENTITY, issuer_name));
269 }
270 } else {
271 // HTTP or HTTPS with errors (not warnings).
272 site_identity_details_.assign(l10n_util::GetStringUTF16(
273 IDS_PAGE_INFO_SECURITY_TAB_INSECURE_IDENTITY));
274 if (ssl.security_style == content::SECURITY_STYLE_UNAUTHENTICATED)
275 site_identity_status_ = SITE_IDENTITY_STATUS_NO_CERT;
276 else
277 site_identity_status_ = SITE_IDENTITY_STATUS_ERROR;
278
279 const string16 bullet = UTF8ToUTF16("\n • ");
280 std::vector<SSLErrorInfo> errors;
281 SSLErrorInfo::GetErrorsForCertStatus(ssl.cert_id, ssl.cert_status,
282 url, &errors);
283 for (size_t i = 0; i < errors.size(); ++i) {
284 site_identity_details_ += bullet;
285 site_identity_details_ += errors[i].short_description();
286 }
287
288 if (ssl.cert_status & net::CERT_STATUS_NON_UNIQUE_NAME) {
289 site_identity_details_ += ASCIIToUTF16("\n\n");
290 site_identity_details_ += l10n_util::GetStringUTF16(
291 IDS_PAGE_INFO_SECURITY_TAB_NON_UNIQUE_NAME);
292 }
293 }
294
295 // Site Connection
296 // We consider anything less than 80 bits encryption to be weak encryption.
297 // TODO(wtc): Bug 1198735: report mixed/unsafe content for unencrypted and
298 // weakly encrypted connections.
299 site_connection_status_ = SITE_CONNECTION_STATUS_UNKNOWN;
300
301 if (!ssl.cert_id) {
302 // Not HTTPS.
303 DCHECK_EQ(ssl.security_style, content::SECURITY_STYLE_UNAUTHENTICATED);
304 if (ssl.security_style == content::SECURITY_STYLE_UNAUTHENTICATED)
305 site_connection_status_ = SITE_CONNECTION_STATUS_UNENCRYPTED;
306 else
307 site_connection_status_ = SITE_CONNECTION_STATUS_ENCRYPTED_ERROR;
308
309 site_connection_details_.assign(l10n_util::GetStringFUTF16(
310 IDS_PAGE_INFO_SECURITY_TAB_NOT_ENCRYPTED_CONNECTION_TEXT,
311 subject_name));
312 } else if (ssl.security_bits < 0) {
313 // Security strength is unknown. Say nothing.
314 site_connection_status_ = SITE_CONNECTION_STATUS_ENCRYPTED_ERROR;
315 } else if (ssl.security_bits == 0) {
316 DCHECK_NE(ssl.security_style, content::SECURITY_STYLE_UNAUTHENTICATED);
317 site_connection_status_ = SITE_CONNECTION_STATUS_ENCRYPTED_ERROR;
318 site_connection_details_.assign(l10n_util::GetStringFUTF16(
319 IDS_PAGE_INFO_SECURITY_TAB_NOT_ENCRYPTED_CONNECTION_TEXT,
320 subject_name));
321 } else if (ssl.security_bits < 80) {
322 site_connection_status_ = SITE_CONNECTION_STATUS_ENCRYPTED_ERROR;
323 site_connection_details_.assign(l10n_util::GetStringFUTF16(
324 IDS_PAGE_INFO_SECURITY_TAB_WEAK_ENCRYPTION_CONNECTION_TEXT,
325 subject_name));
326 } else {
327 site_connection_status_ = SITE_CONNECTION_STATUS_ENCRYPTED;
328 site_connection_details_.assign(l10n_util::GetStringFUTF16(
329 IDS_PAGE_INFO_SECURITY_TAB_ENCRYPTED_CONNECTION_TEXT,
330 subject_name,
331 base::IntToString16(ssl.security_bits)));
332 if (ssl.content_status) {
333 bool ran_insecure_content =
334 !!(ssl.content_status & content::SSLStatus::RAN_INSECURE_CONTENT);
335 site_connection_status_ = ran_insecure_content ?
336 SITE_CONNECTION_STATUS_ENCRYPTED_ERROR
337 : SITE_CONNECTION_STATUS_MIXED_CONTENT;
338 site_connection_details_.assign(l10n_util::GetStringFUTF16(
339 IDS_PAGE_INFO_SECURITY_TAB_ENCRYPTED_SENTENCE_LINK,
340 site_connection_details_,
341 l10n_util::GetStringUTF16(ran_insecure_content ?
342 IDS_PAGE_INFO_SECURITY_TAB_ENCRYPTED_INSECURE_CONTENT_ERROR :
343 IDS_PAGE_INFO_SECURITY_TAB_ENCRYPTED_INSECURE_CONTENT_WARNING)));
344 }
345 }
346
347 uint16 cipher_suite =
348 net::SSLConnectionStatusToCipherSuite(ssl.connection_status);
349 if (ssl.security_bits > 0 && cipher_suite) {
350 int ssl_version =
351 net::SSLConnectionStatusToVersion(ssl.connection_status);
352 const char* ssl_version_str;
353 net::SSLVersionToString(&ssl_version_str, ssl_version);
354 site_connection_details_ += ASCIIToUTF16("\n\n");
355 site_connection_details_ += l10n_util::GetStringFUTF16(
356 IDS_PAGE_INFO_SECURITY_TAB_SSL_VERSION,
357 ASCIIToUTF16(ssl_version_str));
358
359 bool did_fallback = (ssl.connection_status &
360 net::SSL_CONNECTION_VERSION_FALLBACK) != 0;
361 bool no_renegotiation =
362 (ssl.connection_status &
363 net::SSL_CONNECTION_NO_RENEGOTIATION_EXTENSION) != 0;
364 const char *key_exchange, *cipher, *mac;
365 net::SSLCipherSuiteToStrings(&key_exchange, &cipher, &mac, cipher_suite);
366
367 site_connection_details_ += ASCIIToUTF16("\n\n");
368 site_connection_details_ += l10n_util::GetStringFUTF16(
369 IDS_PAGE_INFO_SECURITY_TAB_ENCRYPTION_DETAILS,
370 ASCIIToUTF16(cipher), ASCIIToUTF16(mac), ASCIIToUTF16(key_exchange));
371
372 site_connection_details_ += ASCIIToUTF16("\n\n");
373 uint8 compression_id =
374 net::SSLConnectionStatusToCompression(ssl.connection_status);
375 if (compression_id) {
376 const char* compression;
377 net::SSLCompressionToString(&compression, compression_id);
378 site_connection_details_ += l10n_util::GetStringFUTF16(
379 IDS_PAGE_INFO_SECURITY_TAB_COMPRESSION_DETAILS,
380 ASCIIToUTF16(compression));
381 } else {
382 site_connection_details_ += l10n_util::GetStringUTF16(
383 IDS_PAGE_INFO_SECURITY_TAB_NO_COMPRESSION);
384 }
385
386 if (did_fallback) {
387 // For now, only SSLv3 fallback will trigger a warning icon.
388 if (site_connection_status_ < SITE_CONNECTION_STATUS_MIXED_CONTENT)
389 site_connection_status_ = SITE_CONNECTION_STATUS_MIXED_CONTENT;
390 site_connection_details_ += ASCIIToUTF16("\n\n");
391 site_connection_details_ += l10n_util::GetStringUTF16(
392 IDS_PAGE_INFO_SECURITY_TAB_FALLBACK_MESSAGE);
393 }
394 if (no_renegotiation) {
395 site_connection_details_ += ASCIIToUTF16("\n\n");
396 site_connection_details_ += l10n_util::GetStringUTF16(
397 IDS_PAGE_INFO_SECURITY_TAB_RENEGOTIATION_MESSAGE);
398 }
399 }
400 }
401
402 void WebsiteSettings::PresentSitePermissions() {
403 PermissionInfoList permission_info_list;
404
405 WebsiteSettingsUI::PermissionInfo permission_info;
406 for (size_t i = 0; i < arraysize(kPermissionType); ++i) {
407 permission_info.type = kPermissionType[i];
408
409 content_settings::SettingInfo info;
410 scoped_ptr<Value> value(content_settings_->GetWebsiteSetting(
411 site_url_, site_url_, permission_info.type, "", &info));
412 DCHECK(value.get());
413 permission_info.setting =
414 content_settings::ValueToContentSetting(value.get());
415
416 if (permission_info.setting != CONTENT_SETTING_ASK) {
417 if (info.primary_pattern == ContentSettingsPattern::Wildcard() &&
418 info.secondary_pattern == ContentSettingsPattern::Wildcard()) {
419 permission_info.default_setting = permission_info.setting;
420 permission_info.setting = CONTENT_SETTING_DEFAULT;
421 } else {
422 permission_info.default_setting =
423 content_settings_->GetDefaultContentSetting(permission_info.type,
424 NULL);
425 }
426 permission_info_list.push_back(permission_info);
427 }
428 }
429
430 ui_->SetPermissionInfo(permission_info_list);
431 }
432
433 void WebsiteSettings::PresentSiteData() {
434 CookieInfoList cookie_info_list;
435 const LocalSharedObjectsContainer& allowed_objects =
436 tab_specific_content_settings()->allowed_local_shared_objects();
437 const LocalSharedObjectsContainer& blocked_objects =
438 tab_specific_content_settings()->blocked_local_shared_objects();
439
440 // Add first party cookie and site data counts.
441 WebsiteSettingsUI::CookieInfo cookie_info;
442 std::string cookie_source =
443 net::RegistryControlledDomainService::GetDomainAndRegistry(site_url_);
444 if (cookie_source.empty())
445 cookie_source = site_url_.host();
446 cookie_info.cookie_source = cookie_source;
447 cookie_info.allowed = allowed_objects.GetObjectCountForDomain(site_url_);
448 cookie_info.blocked = blocked_objects.GetObjectCountForDomain(site_url_);
449 cookie_info_list.push_back(cookie_info);
450
451 // Add third party cookie counts.
452 cookie_info.cookie_source = l10n_util::GetStringUTF8(
453 IDS_WEBSITE_SETTINGS_THIRD_PARTY_SITE_DATA);
454 cookie_info.allowed = allowed_objects.GetObjectCount() - cookie_info.allowed;
455 cookie_info.blocked = blocked_objects.GetObjectCount() - cookie_info.blocked;
456 cookie_info_list.push_back(cookie_info);
457
458 ui_->SetCookieInfo(cookie_info_list);
459 }
460
461 void WebsiteSettings::PresentSiteIdentity() {
462 // After initialization the status about the site's connection
463 // and it's identity must be available.
464 DCHECK_NE(site_identity_status_, SITE_IDENTITY_STATUS_UNKNOWN);
465 DCHECK_NE(site_connection_status_, SITE_CONNECTION_STATUS_UNKNOWN);
466 WebsiteSettingsUI::IdentityInfo info;
467 if (site_identity_status_ == SITE_IDENTITY_STATUS_EV_CERT)
468 info.site_identity = UTF16ToUTF8(organization_name());
469 else
470 info.site_identity = site_url_.host();
471
472 info.connection_status = site_connection_status_;
473 info.connection_status_description =
474 UTF16ToUTF8(site_connection_details_);
475 info.identity_status = site_identity_status_;
476 info.identity_status_description =
477 UTF16ToUTF8(site_identity_details_);
478 info.cert_id = cert_id_;
479 ui_->SetIdentityInfo(info);
480 }
481
482 void WebsiteSettings::PresentHistoryInfo(base::Time first_visit) {
483 if (first_visit == base::Time()) {
484 ui_->SetFirstVisit(string16());
485 return;
486 }
487
488 bool visited_before_today = false;
489 base::Time today = base::Time::Now().LocalMidnight();
490 base::Time first_visit_midnight = first_visit.LocalMidnight();
491 visited_before_today = (first_visit_midnight < today);
492
493 string16 first_visit_text;
494 if (visited_before_today) {
495 first_visit_text = l10n_util::GetStringFUTF16(
496 IDS_PAGE_INFO_SECURITY_TAB_VISITED_BEFORE_TODAY,
497 base::TimeFormatShortDate(first_visit));
498 } else {
499 first_visit_text = l10n_util::GetStringUTF16(
500 IDS_PAGE_INFO_SECURITY_TAB_FIRST_VISITED_TODAY);
501
502 }
503 ui_->SetFirstVisit(first_visit_text);
504 }
505
506 // static
507 void WebsiteSettings::Show(gfx::NativeWindow parent,
508 Profile* profile,
509 TabContentsWrapper* tab_contents_wrapper,
510 const GURL& url,
511 const content::SSLStatus& ssl) {
512 #if defined(TOOLKIT_GTK)
513 // The WebsiteSettingsModel will delete itself after the UI is closed.
514 new WebsiteSettings(new WebsiteSettingsPopupGtk(parent,
515 profile,
516 tab_contents_wrapper),
517 profile,
518 tab_contents_wrapper->content_settings(),
519 url,
520 ssl,
521 content::CertStore::GetInstance());
522 #endif
523 }
OLDNEW
« no previous file with comments | « chrome/browser/website_settings.h ('k') | chrome/browser/website_settings_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698