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

Side by Side Diff: chrome/browser/content_settings/tab_specific_content_settings.cc

Issue 7355025: Creat BrowsingDataCookieHelper and CannedBrowsingDataCookieHelper for logging cookies at UI thread. (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: '' Created 9 years, 4 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/content_settings/tab_specific_content_settings.h" 5 #include "chrome/browser/content_settings/tab_specific_content_settings.h"
6 6
7 #include <list> 7 #include <list>
8 8
9 #include "base/lazy_instance.h" 9 #include "base/lazy_instance.h"
10 #include "base/utf_string_conversions.h" 10 #include "base/utf_string_conversions.h"
11 #include "chrome/browser/browsing_data_appcache_helper.h" 11 #include "chrome/browser/browsing_data_appcache_helper.h"
12 #include "chrome/browser/browsing_data_cookie_helper.h"
12 #include "chrome/browser/browsing_data_database_helper.h" 13 #include "chrome/browser/browsing_data_database_helper.h"
13 #include "chrome/browser/browsing_data_file_system_helper.h" 14 #include "chrome/browser/browsing_data_file_system_helper.h"
14 #include "chrome/browser/browsing_data_indexed_db_helper.h" 15 #include "chrome/browser/browsing_data_indexed_db_helper.h"
15 #include "chrome/browser/browsing_data_local_storage_helper.h" 16 #include "chrome/browser/browsing_data_local_storage_helper.h"
16 #include "chrome/browser/content_settings/content_settings_details.h" 17 #include "chrome/browser/content_settings/content_settings_details.h"
17 #include "chrome/browser/content_settings/host_content_settings_map.h" 18 #include "chrome/browser/content_settings/host_content_settings_map.h"
18 #include "chrome/browser/cookies_tree_model.h" 19 #include "chrome/browser/cookies_tree_model.h"
19 #include "chrome/browser/profiles/profile.h" 20 #include "chrome/browser/profiles/profile.h"
20 #include "chrome/common/chrome_notification_types.h" 21 #include "chrome/common/chrome_notification_types.h"
21 #include "chrome/common/render_messages.h" 22 #include "chrome/common/render_messages.h"
22 #include "content/browser/renderer_host/render_process_host.h" 23 #include "content/browser/renderer_host/render_process_host.h"
23 #include "content/browser/renderer_host/render_view_host.h" 24 #include "content/browser/renderer_host/render_view_host.h"
24 #include "content/browser/tab_contents/navigation_details.h" 25 #include "content/browser/tab_contents/navigation_details.h"
25 #include "content/browser/tab_contents/tab_contents.h" 26 #include "content/browser/tab_contents/tab_contents.h"
26 #include "content/browser/tab_contents/tab_contents_delegate.h" 27 #include "content/browser/tab_contents/tab_contents_delegate.h"
27 #include "content/common/notification_service.h" 28 #include "content/common/notification_service.h"
28 #include "content/common/view_messages.h" 29 #include "content/common/view_messages.h"
29 #include "net/base/cookie_monster.h"
30 #include "webkit/fileapi/file_system_types.h" 30 #include "webkit/fileapi/file_system_types.h"
31 31
32 namespace { 32 namespace {
33 typedef std::list<TabSpecificContentSettings*> TabSpecificList; 33 typedef std::list<TabSpecificContentSettings*> TabSpecificList;
34 static base::LazyInstance<TabSpecificList> g_tab_specific( 34 static base::LazyInstance<TabSpecificList> g_tab_specific(
35 base::LINKER_INITIALIZED); 35 base::LINKER_INITIALIZED);
36 } 36 }
37 37
38 bool TabSpecificContentSettings::LocalSharedObjectsContainer::empty() const { 38 bool TabSpecificContentSettings::LocalSharedObjectsContainer::empty() const {
39 return cookies_->GetAllCookies().empty() && 39 return appcaches_->empty() &&
40 appcaches_->empty() && 40 cookies_->empty() &&
41 databases_->empty() && 41 databases_->empty() &&
42 file_systems_->empty() && 42 file_systems_->empty() &&
43 indexed_dbs_->empty() && 43 indexed_dbs_->empty() &&
44 local_storages_->empty() && 44 local_storages_->empty() &&
45 session_storages_->empty(); 45 session_storages_->empty();
46 } 46 }
47 47
48 TabSpecificContentSettings::TabSpecificContentSettings(TabContents* tab) 48 TabSpecificContentSettings::TabSpecificContentSettings(TabContents* tab)
49 : TabContentsObserver(tab), 49 : TabContentsObserver(tab),
50 profile_(Profile::FromBrowserContext(tab->browser_context())), 50 profile_(Profile::FromBrowserContext(tab->browser_context())),
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
232 NotificationService::NoDetails()); 232 NotificationService::NoDetails());
233 } 233 }
234 } 234 }
235 235
236 void TabSpecificContentSettings::OnCookiesRead( 236 void TabSpecificContentSettings::OnCookiesRead(
237 const GURL& url, 237 const GURL& url,
238 const net::CookieList& cookie_list, 238 const net::CookieList& cookie_list,
239 bool blocked_by_policy) { 239 bool blocked_by_policy) {
240 if (cookie_list.empty()) 240 if (cookie_list.empty())
241 return; 241 return;
242 LocalSharedObjectsContainer& container = blocked_by_policy ? 242 if (blocked_by_policy) {
243 blocked_local_shared_objects_ : allowed_local_shared_objects_; 243 blocked_local_shared_objects_.cookies()->AddReadCookies(
244 typedef net::CookieList::const_iterator cookie_iterator; 244 url, cookie_list);
245 for (cookie_iterator cookie = cookie_list.begin(); 245 OnContentBlocked(CONTENT_SETTINGS_TYPE_COOKIES, std::string());
246 cookie != cookie_list.end(); ++cookie) { 246 } else {
247 container.cookies()->SetCookieWithDetails(url, 247 allowed_local_shared_objects_.cookies()->AddReadCookies(
248 cookie->Name(), 248 url, cookie_list);
249 cookie->Value(), 249 OnContentAccessed(CONTENT_SETTINGS_TYPE_COOKIES);
250 cookie->Domain(),
251 cookie->Path(),
252 cookie->ExpiryDate(),
253 cookie->IsSecure(),
254 cookie->IsHttpOnly());
255 } 250 }
256 if (blocked_by_policy)
257 OnContentBlocked(CONTENT_SETTINGS_TYPE_COOKIES, std::string());
258 else
259 OnContentAccessed(CONTENT_SETTINGS_TYPE_COOKIES);
260 } 251 }
261 252
262 void TabSpecificContentSettings::OnCookieChanged( 253 void TabSpecificContentSettings::OnCookieChanged(
263 const GURL& url, 254 const GURL& url,
264 const std::string& cookie_line, 255 const std::string& cookie_line,
265 const net::CookieOptions& options, 256 const net::CookieOptions& options,
266 bool blocked_by_policy) { 257 bool blocked_by_policy) {
267 if (blocked_by_policy) { 258 if (blocked_by_policy) {
268 blocked_local_shared_objects_.cookies()->SetCookieWithOptions( 259 blocked_local_shared_objects_.cookies()->AddChangedCookie(
269 url, cookie_line, options); 260 url, cookie_line, options);
270 OnContentBlocked(CONTENT_SETTINGS_TYPE_COOKIES, std::string()); 261 OnContentBlocked(CONTENT_SETTINGS_TYPE_COOKIES, std::string());
271 } else { 262 } else {
272 allowed_local_shared_objects_.cookies()->SetCookieWithOptions( 263 allowed_local_shared_objects_.cookies()->AddChangedCookie(
273 url, cookie_line, options); 264 url, cookie_line, options);
274 OnContentAccessed(CONTENT_SETTINGS_TYPE_COOKIES); 265 OnContentAccessed(CONTENT_SETTINGS_TYPE_COOKIES);
275 } 266 }
276 } 267 }
277 268
278 void TabSpecificContentSettings::OnIndexedDBAccessed( 269 void TabSpecificContentSettings::OnIndexedDBAccessed(
279 const GURL& url, 270 const GURL& url,
280 const string16& description, 271 const string16& description,
281 bool blocked_by_policy) { 272 bool blocked_by_policy) {
282 if (blocked_by_policy) { 273 if (blocked_by_policy) {
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
479 HostContentSettingsMap* map = profile->GetHostContentSettingsMap(); 470 HostContentSettingsMap* map = profile->GetHostContentSettingsMap();
480 Send(new ViewMsg_SetDefaultContentSettings( 471 Send(new ViewMsg_SetDefaultContentSettings(
481 map->GetDefaultContentSettings())); 472 map->GetDefaultContentSettings()));
482 Send(new ViewMsg_SetContentSettingsForCurrentURL( 473 Send(new ViewMsg_SetContentSettingsForCurrentURL(
483 entry_url, map->GetContentSettings(entry_url, entry_url))); 474 entry_url, map->GetContentSettings(entry_url, entry_url)));
484 } 475 }
485 } 476 }
486 477
487 TabSpecificContentSettings::LocalSharedObjectsContainer:: 478 TabSpecificContentSettings::LocalSharedObjectsContainer::
488 LocalSharedObjectsContainer(Profile* profile) 479 LocalSharedObjectsContainer(Profile* profile)
489 : cookies_(new net::CookieMonster(NULL, NULL)), 480 : appcaches_(new CannedBrowsingDataAppCacheHelper(profile)),
490 appcaches_(new CannedBrowsingDataAppCacheHelper(profile)), 481 cookies_(new CannedBrowsingDataCookieHelper(profile)),
491 databases_(new CannedBrowsingDataDatabaseHelper(profile)), 482 databases_(new CannedBrowsingDataDatabaseHelper(profile)),
492 file_systems_(new CannedBrowsingDataFileSystemHelper(profile)), 483 file_systems_(new CannedBrowsingDataFileSystemHelper(profile)),
493 indexed_dbs_(new CannedBrowsingDataIndexedDBHelper(profile)), 484 indexed_dbs_(new CannedBrowsingDataIndexedDBHelper(profile)),
494 local_storages_(new CannedBrowsingDataLocalStorageHelper(profile)), 485 local_storages_(new CannedBrowsingDataLocalStorageHelper(profile)),
495 session_storages_(new CannedBrowsingDataLocalStorageHelper(profile)) { 486 session_storages_(new CannedBrowsingDataLocalStorageHelper(profile)) {
496 cookies_->SetCookieableSchemes(
497 net::CookieMonster::kDefaultCookieableSchemes,
498 net::CookieMonster::kDefaultCookieableSchemesCount);
499 cookies_->SetKeepExpiredCookies();
500 } 487 }
501 488
502 TabSpecificContentSettings::LocalSharedObjectsContainer:: 489 TabSpecificContentSettings::LocalSharedObjectsContainer::
503 ~LocalSharedObjectsContainer() { 490 ~LocalSharedObjectsContainer() {
504 } 491 }
505 492
506 void TabSpecificContentSettings::LocalSharedObjectsContainer::Reset() { 493 void TabSpecificContentSettings::LocalSharedObjectsContainer::Reset() {
507 cookies_ = new net::CookieMonster(NULL, NULL);
508 cookies_->SetCookieableSchemes(
509 net::CookieMonster::kDefaultCookieableSchemes,
510 net::CookieMonster::kDefaultCookieableSchemesCount);
511 cookies_->SetKeepExpiredCookies();
512 appcaches_->Reset(); 494 appcaches_->Reset();
495 cookies_->Reset();
513 databases_->Reset(); 496 databases_->Reset();
514 file_systems_->Reset(); 497 file_systems_->Reset();
515 indexed_dbs_->Reset(); 498 indexed_dbs_->Reset();
516 local_storages_->Reset(); 499 local_storages_->Reset();
517 session_storages_->Reset(); 500 session_storages_->Reset();
518 } 501 }
519 502
520 CookiesTreeModel* 503 CookiesTreeModel*
521 TabSpecificContentSettings::LocalSharedObjectsContainer::GetCookiesTreeModel() { 504 TabSpecificContentSettings::LocalSharedObjectsContainer::GetCookiesTreeModel() {
522 return new CookiesTreeModel(cookies_, 505 return new CookiesTreeModel(cookies_->Clone(),
523 databases_->Clone(), 506 databases_->Clone(),
524 local_storages_->Clone(), 507 local_storages_->Clone(),
525 session_storages_->Clone(), 508 session_storages_->Clone(),
526 appcaches_->Clone(), 509 appcaches_->Clone(),
527 indexed_dbs_->Clone(), 510 indexed_dbs_->Clone(),
528 file_systems_->Clone(), 511 file_systems_->Clone(),
529 true); 512 true);
530 } 513 }
OLDNEW
« no previous file with comments | « chrome/browser/content_settings/tab_specific_content_settings.h ('k') | chrome/browser/cookies_tree_model.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698