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

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

Issue 6966036: Wrapping blocked filesystems into TabSpecificContentSettings (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebased onto trunk. Created 9 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
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_database_helper.h" 12 #include "chrome/browser/browsing_data_database_helper.h"
13 #include "chrome/browser/browsing_data_file_system_helper.h"
13 #include "chrome/browser/browsing_data_indexed_db_helper.h" 14 #include "chrome/browser/browsing_data_indexed_db_helper.h"
14 #include "chrome/browser/browsing_data_local_storage_helper.h" 15 #include "chrome/browser/browsing_data_local_storage_helper.h"
15 #include "chrome/browser/content_settings/content_settings_details.h" 16 #include "chrome/browser/content_settings/content_settings_details.h"
16 #include "chrome/browser/content_settings/host_content_settings_map.h" 17 #include "chrome/browser/content_settings/host_content_settings_map.h"
17 #include "chrome/browser/cookies_tree_model.h" 18 #include "chrome/browser/cookies_tree_model.h"
18 #include "chrome/browser/profiles/profile.h" 19 #include "chrome/browser/profiles/profile.h"
19 #include "chrome/common/render_messages.h" 20 #include "chrome/common/render_messages.h"
20 #include "content/browser/renderer_host/render_process_host.h" 21 #include "content/browser/renderer_host/render_process_host.h"
21 #include "content/browser/renderer_host/render_view_host.h" 22 #include "content/browser/renderer_host/render_view_host.h"
22 #include "content/browser/tab_contents/tab_contents.h" 23 #include "content/browser/tab_contents/tab_contents.h"
23 #include "content/browser/tab_contents/tab_contents_delegate.h" 24 #include "content/browser/tab_contents/tab_contents_delegate.h"
24 #include "content/common/notification_service.h" 25 #include "content/common/notification_service.h"
25 #include "content/common/view_messages.h" 26 #include "content/common/view_messages.h"
26 #include "net/base/cookie_monster.h" 27 #include "net/base/cookie_monster.h"
28 #include "webkit/fileapi/file_system_types.h"
27 29
28 namespace { 30 namespace {
29 typedef std::list<TabSpecificContentSettings*> TabSpecificList; 31 typedef std::list<TabSpecificContentSettings*> TabSpecificList;
30 static base::LazyInstance<TabSpecificList> g_tab_specific( 32 static base::LazyInstance<TabSpecificList> g_tab_specific(
31 base::LINKER_INITIALIZED); 33 base::LINKER_INITIALIZED);
32 } 34 }
33 35
34 bool TabSpecificContentSettings::LocalSharedObjectsContainer::empty() const { 36 bool TabSpecificContentSettings::LocalSharedObjectsContainer::empty() const {
35 return cookies_->GetAllCookies().empty() && 37 return cookies_->GetAllCookies().empty() &&
36 appcaches_->empty() && 38 appcaches_->empty() &&
37 databases_->empty() && 39 databases_->empty() &&
40 file_systems_->empty() &&
38 indexed_dbs_->empty() && 41 indexed_dbs_->empty() &&
39 local_storages_->empty() && 42 local_storages_->empty() &&
40 session_storages_->empty(); 43 session_storages_->empty();
41 } 44 }
42 45
43 TabSpecificContentSettings::TabSpecificContentSettings(TabContents* tab) 46 TabSpecificContentSettings::TabSpecificContentSettings(TabContents* tab)
44 : TabContentsObserver(tab), 47 : TabContentsObserver(tab),
45 allowed_local_shared_objects_(tab->profile()), 48 allowed_local_shared_objects_(tab->profile()),
46 blocked_local_shared_objects_(tab->profile()), 49 blocked_local_shared_objects_(tab->profile()),
47 geolocation_settings_state_(tab->profile()), 50 geolocation_settings_state_(tab->profile()),
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
124 void TabSpecificContentSettings::IndexedDBAccessed(int render_process_id, 127 void TabSpecificContentSettings::IndexedDBAccessed(int render_process_id,
125 int render_view_id, 128 int render_view_id,
126 const GURL& url, 129 const GURL& url,
127 const string16& description, 130 const string16& description,
128 bool blocked_by_policy) { 131 bool blocked_by_policy) {
129 TabSpecificContentSettings* settings = Get(render_process_id, render_view_id); 132 TabSpecificContentSettings* settings = Get(render_process_id, render_view_id);
130 if (settings) 133 if (settings)
131 settings->OnIndexedDBAccessed(url, description, blocked_by_policy); 134 settings->OnIndexedDBAccessed(url, description, blocked_by_policy);
132 } 135 }
133 136
137 void TabSpecificContentSettings::FileSystemAccessed(int render_process_id,
138 int render_view_id,
139 const GURL& url,
140 bool blocked_by_policy) {
141 TabSpecificContentSettings* settings = Get(render_process_id, render_view_id);
142 if (settings)
143 settings->OnFileSystemAccessed(url, blocked_by_policy);
144 }
145
134 bool TabSpecificContentSettings::IsContentBlocked( 146 bool TabSpecificContentSettings::IsContentBlocked(
135 ContentSettingsType content_type) const { 147 ContentSettingsType content_type) const {
136 DCHECK(content_type != CONTENT_SETTINGS_TYPE_GEOLOCATION) 148 DCHECK(content_type != CONTENT_SETTINGS_TYPE_GEOLOCATION)
137 << "Geolocation settings handled by ContentSettingGeolocationImageModel"; 149 << "Geolocation settings handled by ContentSettingGeolocationImageModel";
138 DCHECK(content_type != CONTENT_SETTINGS_TYPE_NOTIFICATIONS) 150 DCHECK(content_type != CONTENT_SETTINGS_TYPE_NOTIFICATIONS)
139 << "Notifications settings handled by " 151 << "Notifications settings handled by "
140 << "ContentSettingsNotificationsImageModel"; 152 << "ContentSettingsNotificationsImageModel";
141 DCHECK(content_type != CONTENT_SETTINGS_TYPE_PRERENDER) 153 DCHECK(content_type != CONTENT_SETTINGS_TYPE_PRERENDER)
142 << "Prerendering settings handled by " 154 << "Prerendering settings handled by "
143 << "ContentSettingPrerenderImageModel"; 155 << "ContentSettingPrerenderImageModel";
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
263 } 275 }
264 276
265 void TabSpecificContentSettings::OnIndexedDBAccessed( 277 void TabSpecificContentSettings::OnIndexedDBAccessed(
266 const GURL& url, 278 const GURL& url,
267 const string16& description, 279 const string16& description,
268 bool blocked_by_policy) { 280 bool blocked_by_policy) {
269 if (blocked_by_policy) { 281 if (blocked_by_policy) {
270 blocked_local_shared_objects_.indexed_dbs()->AddIndexedDB( 282 blocked_local_shared_objects_.indexed_dbs()->AddIndexedDB(
271 url, description); 283 url, description);
272 OnContentBlocked(CONTENT_SETTINGS_TYPE_COOKIES, std::string()); 284 OnContentBlocked(CONTENT_SETTINGS_TYPE_COOKIES, std::string());
273 }else { 285 } else {
274 allowed_local_shared_objects_.indexed_dbs()->AddIndexedDB( 286 allowed_local_shared_objects_.indexed_dbs()->AddIndexedDB(
275 url, description); 287 url, description);
276 OnContentAccessed(CONTENT_SETTINGS_TYPE_COOKIES); 288 OnContentAccessed(CONTENT_SETTINGS_TYPE_COOKIES);
277 } 289 }
278 } 290 }
279 291
280 void TabSpecificContentSettings::OnLocalStorageAccessed( 292 void TabSpecificContentSettings::OnLocalStorageAccessed(
281 const GURL& url, 293 const GURL& url,
282 DOMStorageType storage_type, 294 DOMStorageType storage_type,
283 bool blocked_by_policy) { 295 bool blocked_by_policy) {
(...skipping 30 matching lines...) Expand all
314 const GURL& manifest_url, bool blocked_by_policy) { 326 const GURL& manifest_url, bool blocked_by_policy) {
315 if (blocked_by_policy) { 327 if (blocked_by_policy) {
316 blocked_local_shared_objects_.appcaches()->AddAppCache(manifest_url); 328 blocked_local_shared_objects_.appcaches()->AddAppCache(manifest_url);
317 OnContentBlocked(CONTENT_SETTINGS_TYPE_COOKIES, std::string()); 329 OnContentBlocked(CONTENT_SETTINGS_TYPE_COOKIES, std::string());
318 } else { 330 } else {
319 allowed_local_shared_objects_.appcaches()->AddAppCache(manifest_url); 331 allowed_local_shared_objects_.appcaches()->AddAppCache(manifest_url);
320 OnContentAccessed(CONTENT_SETTINGS_TYPE_COOKIES); 332 OnContentAccessed(CONTENT_SETTINGS_TYPE_COOKIES);
321 } 333 }
322 } 334 }
323 335
336 void TabSpecificContentSettings::OnFileSystemAccessed(
337 const GURL& url,
338 bool blocked_by_policy) {
339 if (blocked_by_policy) {
340 blocked_local_shared_objects_.file_systems()->AddFileSystem(url,
341 fileapi::kFileSystemTypeTemporary, 0);
342 OnContentBlocked(CONTENT_SETTINGS_TYPE_COOKIES, std::string());
343 } else {
344 allowed_local_shared_objects_.file_systems()->AddFileSystem(url,
345 fileapi::kFileSystemTypeTemporary, 0);
346 OnContentAccessed(CONTENT_SETTINGS_TYPE_COOKIES);
347 }
348 }
324 void TabSpecificContentSettings::OnGeolocationPermissionSet( 349 void TabSpecificContentSettings::OnGeolocationPermissionSet(
325 const GURL& requesting_origin, 350 const GURL& requesting_origin,
326 bool allowed) { 351 bool allowed) {
327 geolocation_settings_state_.OnGeolocationPermissionSet(requesting_origin, 352 geolocation_settings_state_.OnGeolocationPermissionSet(requesting_origin,
328 allowed); 353 allowed);
329 NotificationService::current()->Notify( 354 NotificationService::current()->Notify(
330 NotificationType::TAB_CONTENT_SETTINGS_CHANGED, 355 NotificationType::TAB_CONTENT_SETTINGS_CHANGED,
331 Source<TabContents>(tab_contents()), 356 Source<TabContents>(tab_contents()),
332 NotificationService::NoDetails()); 357 NotificationService::NoDetails());
333 } 358 }
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
447 entry_url, tab_contents()->profile()->GetHostContentSettingsMap()-> 472 entry_url, tab_contents()->profile()->GetHostContentSettingsMap()->
448 GetContentSettings(entry_url))); 473 GetContentSettings(entry_url)));
449 } 474 }
450 } 475 }
451 476
452 TabSpecificContentSettings::LocalSharedObjectsContainer:: 477 TabSpecificContentSettings::LocalSharedObjectsContainer::
453 LocalSharedObjectsContainer(Profile* profile) 478 LocalSharedObjectsContainer(Profile* profile)
454 : cookies_(new net::CookieMonster(NULL, NULL)), 479 : cookies_(new net::CookieMonster(NULL, NULL)),
455 appcaches_(new CannedBrowsingDataAppCacheHelper(profile)), 480 appcaches_(new CannedBrowsingDataAppCacheHelper(profile)),
456 databases_(new CannedBrowsingDataDatabaseHelper(profile)), 481 databases_(new CannedBrowsingDataDatabaseHelper(profile)),
482 file_systems_(new CannedBrowsingDataFileSystemHelper(profile)),
457 indexed_dbs_(new CannedBrowsingDataIndexedDBHelper(profile)), 483 indexed_dbs_(new CannedBrowsingDataIndexedDBHelper(profile)),
458 local_storages_(new CannedBrowsingDataLocalStorageHelper(profile)), 484 local_storages_(new CannedBrowsingDataLocalStorageHelper(profile)),
459 session_storages_(new CannedBrowsingDataLocalStorageHelper(profile)) { 485 session_storages_(new CannedBrowsingDataLocalStorageHelper(profile)) {
460 cookies_->SetCookieableSchemes( 486 cookies_->SetCookieableSchemes(
461 net::CookieMonster::kDefaultCookieableSchemes, 487 net::CookieMonster::kDefaultCookieableSchemes,
462 net::CookieMonster::kDefaultCookieableSchemesCount); 488 net::CookieMonster::kDefaultCookieableSchemesCount);
463 cookies_->SetKeepExpiredCookies(); 489 cookies_->SetKeepExpiredCookies();
464 } 490 }
465 491
466 TabSpecificContentSettings::LocalSharedObjectsContainer:: 492 TabSpecificContentSettings::LocalSharedObjectsContainer::
467 ~LocalSharedObjectsContainer() { 493 ~LocalSharedObjectsContainer() {
468 } 494 }
469 495
470 void TabSpecificContentSettings::LocalSharedObjectsContainer::Reset() { 496 void TabSpecificContentSettings::LocalSharedObjectsContainer::Reset() {
471 cookies_ = new net::CookieMonster(NULL, NULL); 497 cookies_ = new net::CookieMonster(NULL, NULL);
472 cookies_->SetCookieableSchemes( 498 cookies_->SetCookieableSchemes(
473 net::CookieMonster::kDefaultCookieableSchemes, 499 net::CookieMonster::kDefaultCookieableSchemes,
474 net::CookieMonster::kDefaultCookieableSchemesCount); 500 net::CookieMonster::kDefaultCookieableSchemesCount);
475 cookies_->SetKeepExpiredCookies(); 501 cookies_->SetKeepExpiredCookies();
476 appcaches_->Reset(); 502 appcaches_->Reset();
477 databases_->Reset(); 503 databases_->Reset();
504 file_systems_->Reset();
478 indexed_dbs_->Reset(); 505 indexed_dbs_->Reset();
479 local_storages_->Reset(); 506 local_storages_->Reset();
480 session_storages_->Reset(); 507 session_storages_->Reset();
481 } 508 }
482 509
483 CookiesTreeModel* 510 CookiesTreeModel*
484 TabSpecificContentSettings::LocalSharedObjectsContainer::GetCookiesTreeModel() { 511 TabSpecificContentSettings::LocalSharedObjectsContainer::GetCookiesTreeModel() {
485 return new CookiesTreeModel(cookies_, 512 return new CookiesTreeModel(cookies_,
486 databases_->Clone(), 513 databases_->Clone(),
487 local_storages_->Clone(), 514 local_storages_->Clone(),
488 session_storages_->Clone(), 515 session_storages_->Clone(),
489 appcaches_->Clone(), 516 appcaches_->Clone(),
490 indexed_dbs_->Clone(), 517 indexed_dbs_->Clone(),
518 file_systems_->Clone(),
491 true); 519 true);
492 } 520 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698