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

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: " Created 8 years, 8 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/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 328 matching lines...) Expand 10 before | Expand all | Expand 10 after
406 } 394 }
407 permission_info_list.push_back(permission_info); 395 permission_info_list.push_back(permission_info);
408 } 396 }
409 } 397 }
410 398
411 ui_->SetPermissionInfo(permission_info_list); 399 ui_->SetPermissionInfo(permission_info_list);
412 } 400 }
413 401
414 void WebsiteSettings::PresentSiteData() { 402 void WebsiteSettings::PresentSiteData() {
415 CookieInfoList cookie_info_list; 403 CookieInfoList cookie_info_list;
404 const LocalSharedObjectsContainer& allowed_objects =
405 tab_specific_content_settings()->allowed_local_shared_objects();
406 const LocalSharedObjectsContainer& blocked_objects =
407 tab_specific_content_settings()->blocked_local_shared_objects();
408
409 // Add first party cookie and site data counts.
416 WebsiteSettingsUI::CookieInfo cookie_info; 410 WebsiteSettingsUI::CookieInfo cookie_info;
417 cookie_info.cookie_source = site_url_.host(); 411 std::string cookie_source =
418 cookie_info.allowed = GetLocalStoredObjectCount( 412 net::RegistryControlledDomainService::GetDomainAndRegistry(site_url_);
bauerb at google 2012/04/27 16:12:50 Doesn't SameDomainOrHost() do this internally?
markusheintz_ 2012/05/10 16:32:36 Yes it does. Here I need to get the domain of the
419 tab_specific_content_settings()->allowed_local_shared_objects()); 413 if (cookie_source.empty())
420 cookie_info.blocked = GetLocalStoredObjectCount( 414 cookie_source = site_url_.host();
421 tab_specific_content_settings()->blocked_local_shared_objects()); 415 cookie_info.cookie_source = cookie_source;
416 cookie_info.allowed = allowed_objects.GetObjectCountForDomain(site_url_);
417 cookie_info.blocked = blocked_objects.GetObjectCountForDomain(site_url_);
418 cookie_info_list.push_back(cookie_info);
419
420 // Add third party cookie counts.
421 // TODO(markusheintz): Localize the following string once we decided about
422 // the exact wording.
bauerb at google 2012/04/27 16:12:50 Usually, we add strings to the GRD file even if th
markusheintz_ 2012/05/10 16:32:36 Done.
423 cookie_info.cookie_source = "Others";
424 cookie_info.allowed = allowed_objects.Size() - cookie_info.allowed;
425 cookie_info.blocked = blocked_objects.Size() - cookie_info.blocked;
422 cookie_info_list.push_back(cookie_info); 426 cookie_info_list.push_back(cookie_info);
423 427
424 ui_->SetCookieInfo(cookie_info_list); 428 ui_->SetCookieInfo(cookie_info_list);
425 } 429 }
426 430
427 void WebsiteSettings::PresentSiteIdentity() { 431 void WebsiteSettings::PresentSiteIdentity() {
428 // After initialization the status about the site's connection 432 // After initialization the status about the site's connection
429 // and it's identity must be available. 433 // and it's identity must be available.
430 DCHECK_NE(site_identity_status_, SITE_IDENTITY_STATUS_UNKNOWN); 434 DCHECK_NE(site_identity_status_, SITE_IDENTITY_STATUS_UNKNOWN);
431 DCHECK_NE(site_connection_status_, SITE_CONNECTION_STATUS_UNKNOWN); 435 DCHECK_NE(site_connection_status_, SITE_CONNECTION_STATUS_UNKNOWN);
(...skipping 23 matching lines...) Expand all
455 new WebsiteSettings(new WebsiteSettingsPopupGtk(parent, 459 new WebsiteSettings(new WebsiteSettingsPopupGtk(parent,
456 profile, 460 profile,
457 tab_contents_wrapper), 461 tab_contents_wrapper),
458 profile, 462 profile,
459 tab_contents_wrapper->content_settings(), 463 tab_contents_wrapper->content_settings(),
460 url, 464 url,
461 ssl, 465 ssl,
462 content::CertStore::GetInstance()); 466 content::CertStore::GetInstance());
463 #endif 467 #endif
464 } 468 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698