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

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

Issue 10092013: Display third party cookies and site data counts in the WebsiteSettings UI. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: "Fix CannedBrowsingDataDatabaseHelperTest.*" 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
« no previous file with comments | « chrome/browser/content_settings/tab_specific_content_settings.cc ('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) 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/website_settings.h" 5 #include "chrome/browser/website_settings.h"
6 6
7 #include <string> 7 #include <string>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/string_number_conversions.h" 10 #include "base/string_number_conversions.h"
(...skipping 13 matching lines...) Expand all
24 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" 24 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h"
25 #include "chrome/browser/ui/website_settings_ui.h" 25 #include "chrome/browser/ui/website_settings_ui.h"
26 #include "chrome/common/content_settings_pattern.h" 26 #include "chrome/common/content_settings_pattern.h"
27 #include "content/public/browser/browser_thread.h" 27 #include "content/public/browser/browser_thread.h"
28 #include "content/public/browser/cert_store.h" 28 #include "content/public/browser/cert_store.h"
29 #include "content/public/common/ssl_status.h" 29 #include "content/public/common/ssl_status.h"
30 #include "content/public/common/url_constants.h" 30 #include "content/public/common/url_constants.h"
31 #include "grit/chromium_strings.h" 31 #include "grit/chromium_strings.h"
32 #include "grit/generated_resources.h" 32 #include "grit/generated_resources.h"
33 #include "net/base/cert_status_flags.h" 33 #include "net/base/cert_status_flags.h"
34 #include "net/base/registry_controlled_domain.h"
34 #include "net/base/ssl_cipher_suite_names.h" 35 #include "net/base/ssl_cipher_suite_names.h"
35 #include "net/base/ssl_connection_status_flags.h" 36 #include "net/base/ssl_connection_status_flags.h"
36 #include "net/base/x509_certificate.h" 37 #include "net/base/x509_certificate.h"
37 #include "ui/base/l10n/l10n_util.h" 38 #include "ui/base/l10n/l10n_util.h"
38 #include "ui/base/resource/resource_bundle.h" 39 #include "ui/base/resource/resource_bundle.h"
39 40
40 #if defined(TOOLKIT_GTK) 41 #if defined(TOOLKIT_GTK)
41 #include "chrome/browser/ui/gtk/website_settings_popup_gtk.h" 42 #include "chrome/browser/ui/gtk/website_settings_popup_gtk.h"
42 #endif 43 #endif
43 44
44 using content::BrowserThread; 45 using content::BrowserThread;
45 46
46 namespace { 47 namespace {
47 48
48 ContentSettingsType kPermissionType[] = { 49 ContentSettingsType kPermissionType[] = {
49 CONTENT_SETTINGS_TYPE_POPUPS, 50 CONTENT_SETTINGS_TYPE_POPUPS,
50 CONTENT_SETTINGS_TYPE_PLUGINS, 51 CONTENT_SETTINGS_TYPE_PLUGINS,
51 CONTENT_SETTINGS_TYPE_NOTIFICATIONS, 52 CONTENT_SETTINGS_TYPE_NOTIFICATIONS,
52 CONTENT_SETTINGS_TYPE_GEOLOCATION, 53 CONTENT_SETTINGS_TYPE_GEOLOCATION,
53 }; 54 };
54 55
55 size_t GetLocalStoredObjectCount(
56 const LocalSharedObjectsContainer& local_shared_objects) {
57 size_t count = 0;
58 count += local_shared_objects.cookies()->GetCookieCount();
59 count += local_shared_objects.databases()->GetDatabaseCount();
60 count += local_shared_objects.file_systems()->GetFileSystemCount();
61 count += local_shared_objects.indexed_dbs()->GetIndexedDBCount();
62 count += local_shared_objects.local_storages()->GetLocalStorageCount();
63 count += local_shared_objects.server_bound_certs()->GetCertCount();
64 count += local_shared_objects.session_storages()->GetLocalStorageCount();
65 return count;
66 }
67
68 } // namespace 56 } // namespace
69 57
70 WebsiteSettings::WebsiteSettings( 58 WebsiteSettings::WebsiteSettings(
71 WebsiteSettingsUI* ui, 59 WebsiteSettingsUI* ui,
72 Profile* profile, 60 Profile* profile,
73 TabSpecificContentSettings* tab_specific_content_settings, 61 TabSpecificContentSettings* tab_specific_content_settings,
74 const GURL& url, 62 const GURL& url,
75 const content::SSLStatus& ssl, 63 const content::SSLStatus& ssl,
76 content::CertStore* cert_store) 64 content::CertStore* cert_store)
77 : TabSpecificContentSettings::SiteDataObserver( 65 : TabSpecificContentSettings::SiteDataObserver(
(...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after
409 } 397 }
410 permission_info_list.push_back(permission_info); 398 permission_info_list.push_back(permission_info);
411 } 399 }
412 } 400 }
413 401
414 ui_->SetPermissionInfo(permission_info_list); 402 ui_->SetPermissionInfo(permission_info_list);
415 } 403 }
416 404
417 void WebsiteSettings::PresentSiteData() { 405 void WebsiteSettings::PresentSiteData() {
418 CookieInfoList cookie_info_list; 406 CookieInfoList cookie_info_list;
407 const LocalSharedObjectsContainer& allowed_objects =
408 tab_specific_content_settings()->allowed_local_shared_objects();
409 const LocalSharedObjectsContainer& blocked_objects =
410 tab_specific_content_settings()->blocked_local_shared_objects();
411
412 // Add first party cookie and site data counts.
419 WebsiteSettingsUI::CookieInfo cookie_info; 413 WebsiteSettingsUI::CookieInfo cookie_info;
420 cookie_info.cookie_source = site_url_.host(); 414 std::string cookie_source =
421 cookie_info.allowed = GetLocalStoredObjectCount( 415 net::RegistryControlledDomainService::GetDomainAndRegistry(site_url_);
422 tab_specific_content_settings()->allowed_local_shared_objects()); 416 if (cookie_source.empty())
423 cookie_info.blocked = GetLocalStoredObjectCount( 417 cookie_source = site_url_.host();
424 tab_specific_content_settings()->blocked_local_shared_objects()); 418 cookie_info.cookie_source = cookie_source;
419 cookie_info.allowed = allowed_objects.GetObjectCountForDomain(site_url_);
420 cookie_info.blocked = blocked_objects.GetObjectCountForDomain(site_url_);
421 cookie_info_list.push_back(cookie_info);
422
423 // Add third party cookie counts.
424 cookie_info.cookie_source = l10n_util::GetStringUTF8(
425 IDS_WEBSITE_SETTINGS_THIRD_PARTY_SITE_DATA);
426 cookie_info.allowed = allowed_objects.GetObjectCount() - cookie_info.allowed;
427 cookie_info.blocked = blocked_objects.GetObjectCount() - cookie_info.blocked;
425 cookie_info_list.push_back(cookie_info); 428 cookie_info_list.push_back(cookie_info);
426 429
427 ui_->SetCookieInfo(cookie_info_list); 430 ui_->SetCookieInfo(cookie_info_list);
428 } 431 }
429 432
430 void WebsiteSettings::PresentSiteIdentity() { 433 void WebsiteSettings::PresentSiteIdentity() {
431 // After initialization the status about the site's connection 434 // After initialization the status about the site's connection
432 // and it's identity must be available. 435 // and it's identity must be available.
433 DCHECK_NE(site_identity_status_, SITE_IDENTITY_STATUS_UNKNOWN); 436 DCHECK_NE(site_identity_status_, SITE_IDENTITY_STATUS_UNKNOWN);
434 DCHECK_NE(site_connection_status_, SITE_CONNECTION_STATUS_UNKNOWN); 437 DCHECK_NE(site_connection_status_, SITE_CONNECTION_STATUS_UNKNOWN);
(...skipping 24 matching lines...) Expand all
459 new WebsiteSettings(new WebsiteSettingsPopupGtk(parent, 462 new WebsiteSettings(new WebsiteSettingsPopupGtk(parent,
460 profile, 463 profile,
461 tab_contents_wrapper), 464 tab_contents_wrapper),
462 profile, 465 profile,
463 tab_contents_wrapper->content_settings(), 466 tab_contents_wrapper->content_settings(),
464 url, 467 url,
465 ssl, 468 ssl,
466 content::CertStore::GetInstance()); 469 content::CertStore::GetInstance());
467 #endif 470 #endif
468 } 471 }
OLDNEW
« no previous file with comments | « chrome/browser/content_settings/tab_specific_content_settings.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698