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

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: Missed a string. Created 9 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
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() &&
jochen (gone - plz use gerrit) 2011/05/25 15:54:09 add filesystem_->empty()
Mike West 2011/05/25 16:55:16 Good catch.
38 indexed_dbs_->empty() && 40 indexed_dbs_->empty() &&
39 local_storages_->empty() && 41 local_storages_->empty() &&
40 session_storages_->empty(); 42 session_storages_->empty();
41 } 43 }
42 44
43 TabSpecificContentSettings::TabSpecificContentSettings(TabContents* tab) 45 TabSpecificContentSettings::TabSpecificContentSettings(TabContents* tab)
44 : TabContentsObserver(tab), 46 : TabContentsObserver(tab),
45 allowed_local_shared_objects_(tab->profile()), 47 allowed_local_shared_objects_(tab->profile()),
46 blocked_local_shared_objects_(tab->profile()), 48 blocked_local_shared_objects_(tab->profile()),
47 geolocation_settings_state_(tab->profile()), 49 geolocation_settings_state_(tab->profile()),
(...skipping 16 matching lines...) Expand all
64 RenderViewHost* view = RenderViewHost::FromID( 66 RenderViewHost* view = RenderViewHost::FromID(
65 render_process_id, render_view_id); 67 render_process_id, render_view_id);
66 if (!view) 68 if (!view)
67 return NULL; 69 return NULL;
68 // We loop through the tab contents and compare them with |view|, instead of 70 // We loop through the tab contents and compare them with |view|, instead of
69 // getting the RVH from each tab contents and comparing its IDs because the 71 // getting the RVH from each tab contents and comparing its IDs because the
70 // latter will miss provisional RenderViewHosts. 72 // latter will miss provisional RenderViewHosts.
71 for (TabSpecificList::iterator i = g_tab_specific.Get().begin(); 73 for (TabSpecificList::iterator i = g_tab_specific.Get().begin();
72 i != g_tab_specific.Get().end(); ++i) { 74 i != g_tab_specific.Get().end(); ++i) {
73 if (view->delegate() == (*i)->tab_contents()) 75 if (view->delegate() == (*i)->tab_contents())
74 return (*i); 76 return (*i);
75 } 77 }
76 78
77 return NULL; 79 return NULL;
78 } 80 }
79 81
80 void TabSpecificContentSettings::CookiesRead(int render_process_id, 82 void TabSpecificContentSettings::CookiesRead(int render_process_id,
81 int render_view_id, 83 int render_view_id,
82 const GURL& url, 84 const GURL& url,
83 const net::CookieList& cookie_list, 85 const net::CookieList& cookie_list,
84 bool blocked_by_policy) { 86 bool blocked_by_policy) {
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
124 void TabSpecificContentSettings::IndexedDBAccessed(int render_process_id, 126 void TabSpecificContentSettings::IndexedDBAccessed(int render_process_id,
125 int render_view_id, 127 int render_view_id,
126 const GURL& url, 128 const GURL& url,
127 const string16& description, 129 const string16& description,
128 bool blocked_by_policy) { 130 bool blocked_by_policy) {
129 TabSpecificContentSettings* settings = Get(render_process_id, render_view_id); 131 TabSpecificContentSettings* settings = Get(render_process_id, render_view_id);
130 if (settings) 132 if (settings)
131 settings->OnIndexedDBAccessed(url, description, blocked_by_policy); 133 settings->OnIndexedDBAccessed(url, description, blocked_by_policy);
132 } 134 }
133 135
136 void TabSpecificContentSettings::FileSystemAccessed(int render_process_id,
137 int render_view_id,
138 const GURL& url,
139 bool blocked_by_policy) {
140 TabSpecificContentSettings* settings = Get(render_process_id, render_view_id);
141 if (settings)
142 settings->OnFileSystemAccessed(url, blocked_by_policy);
143 }
144
134 bool TabSpecificContentSettings::IsContentBlocked( 145 bool TabSpecificContentSettings::IsContentBlocked(
135 ContentSettingsType content_type) const { 146 ContentSettingsType content_type) const {
136 DCHECK(content_type != CONTENT_SETTINGS_TYPE_GEOLOCATION) 147 DCHECK(content_type != CONTENT_SETTINGS_TYPE_GEOLOCATION)
137 << "Geolocation settings handled by ContentSettingGeolocationImageModel"; 148 << "Geolocation settings handled by ContentSettingGeolocationImageModel";
138 DCHECK(content_type != CONTENT_SETTINGS_TYPE_NOTIFICATIONS) 149 DCHECK(content_type != CONTENT_SETTINGS_TYPE_NOTIFICATIONS)
139 << "Notifications settings handled by " 150 << "Notifications settings handled by "
140 << "ContentSettingsNotificationsImageModel"; 151 << "ContentSettingsNotificationsImageModel";
141 152
142 if (content_type == CONTENT_SETTINGS_TYPE_IMAGES || 153 if (content_type == CONTENT_SETTINGS_TYPE_IMAGES ||
143 content_type == CONTENT_SETTINGS_TYPE_JAVASCRIPT || 154 content_type == CONTENT_SETTINGS_TYPE_JAVASCRIPT ||
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
261 } 272 }
262 273
263 void TabSpecificContentSettings::OnIndexedDBAccessed( 274 void TabSpecificContentSettings::OnIndexedDBAccessed(
264 const GURL& url, 275 const GURL& url,
265 const string16& description, 276 const string16& description,
266 bool blocked_by_policy) { 277 bool blocked_by_policy) {
267 if (blocked_by_policy) { 278 if (blocked_by_policy) {
268 blocked_local_shared_objects_.indexed_dbs()->AddIndexedDB( 279 blocked_local_shared_objects_.indexed_dbs()->AddIndexedDB(
269 url, description); 280 url, description);
270 OnContentBlocked(CONTENT_SETTINGS_TYPE_COOKIES, std::string()); 281 OnContentBlocked(CONTENT_SETTINGS_TYPE_COOKIES, std::string());
271 }else { 282 } else {
272 allowed_local_shared_objects_.indexed_dbs()->AddIndexedDB( 283 allowed_local_shared_objects_.indexed_dbs()->AddIndexedDB(
273 url, description); 284 url, description);
274 OnContentAccessed(CONTENT_SETTINGS_TYPE_COOKIES); 285 OnContentAccessed(CONTENT_SETTINGS_TYPE_COOKIES);
275 } 286 }
276 } 287 }
277 288
278 void TabSpecificContentSettings::OnLocalStorageAccessed( 289 void TabSpecificContentSettings::OnLocalStorageAccessed(
279 const GURL& url, 290 const GURL& url,
280 DOMStorageType storage_type, 291 DOMStorageType storage_type,
281 bool blocked_by_policy) { 292 bool blocked_by_policy) {
(...skipping 30 matching lines...) Expand all
312 const GURL& manifest_url, bool blocked_by_policy) { 323 const GURL& manifest_url, bool blocked_by_policy) {
313 if (blocked_by_policy) { 324 if (blocked_by_policy) {
314 blocked_local_shared_objects_.appcaches()->AddAppCache(manifest_url); 325 blocked_local_shared_objects_.appcaches()->AddAppCache(manifest_url);
315 OnContentBlocked(CONTENT_SETTINGS_TYPE_COOKIES, std::string()); 326 OnContentBlocked(CONTENT_SETTINGS_TYPE_COOKIES, std::string());
316 } else { 327 } else {
317 allowed_local_shared_objects_.appcaches()->AddAppCache(manifest_url); 328 allowed_local_shared_objects_.appcaches()->AddAppCache(manifest_url);
318 OnContentAccessed(CONTENT_SETTINGS_TYPE_COOKIES); 329 OnContentAccessed(CONTENT_SETTINGS_TYPE_COOKIES);
319 } 330 }
320 } 331 }
321 332
333 void TabSpecificContentSettings::OnFileSystemAccessed(
334 const GURL& url,
335 bool blocked_by_policy) {
336 if (blocked_by_policy) {
337 blocked_local_shared_objects_.file_systems()->AddFileSystem(url,
338 fileapi::kFileSystemTypeTemporary);
339 OnContentBlocked(CONTENT_SETTINGS_TYPE_COOKIES, std::string());
340 } else {
341 allowed_local_shared_objects_.file_systems()->AddFileSystem(url,
342 fileapi::kFileSystemTypeTemporary);
343 OnContentAccessed(CONTENT_SETTINGS_TYPE_COOKIES);
344 }
345 }
322 void TabSpecificContentSettings::OnGeolocationPermissionSet( 346 void TabSpecificContentSettings::OnGeolocationPermissionSet(
323 const GURL& requesting_origin, 347 const GURL& requesting_origin,
324 bool allowed) { 348 bool allowed) {
325 geolocation_settings_state_.OnGeolocationPermissionSet(requesting_origin, 349 geolocation_settings_state_.OnGeolocationPermissionSet(requesting_origin,
326 allowed); 350 allowed);
327 NotificationService::current()->Notify( 351 NotificationService::current()->Notify(
328 NotificationType::TAB_CONTENT_SETTINGS_CHANGED, 352 NotificationType::TAB_CONTENT_SETTINGS_CHANGED,
329 Source<TabContents>(tab_contents()), 353 Source<TabContents>(tab_contents()),
330 NotificationService::NoDetails()); 354 NotificationService::NoDetails());
331 } 355 }
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
445 entry_url, tab_contents()->profile()->GetHostContentSettingsMap()-> 469 entry_url, tab_contents()->profile()->GetHostContentSettingsMap()->
446 GetContentSettings(entry_url))); 470 GetContentSettings(entry_url)));
447 } 471 }
448 } 472 }
449 473
450 TabSpecificContentSettings::LocalSharedObjectsContainer:: 474 TabSpecificContentSettings::LocalSharedObjectsContainer::
451 LocalSharedObjectsContainer(Profile* profile) 475 LocalSharedObjectsContainer(Profile* profile)
452 : cookies_(new net::CookieMonster(NULL, NULL)), 476 : cookies_(new net::CookieMonster(NULL, NULL)),
453 appcaches_(new CannedBrowsingDataAppCacheHelper(profile)), 477 appcaches_(new CannedBrowsingDataAppCacheHelper(profile)),
454 databases_(new CannedBrowsingDataDatabaseHelper(profile)), 478 databases_(new CannedBrowsingDataDatabaseHelper(profile)),
479 file_systems_(new CannedBrowsingDataFileSystemHelper(profile)),
455 indexed_dbs_(new CannedBrowsingDataIndexedDBHelper(profile)), 480 indexed_dbs_(new CannedBrowsingDataIndexedDBHelper(profile)),
456 local_storages_(new CannedBrowsingDataLocalStorageHelper(profile)), 481 local_storages_(new CannedBrowsingDataLocalStorageHelper(profile)),
457 session_storages_(new CannedBrowsingDataLocalStorageHelper(profile)) { 482 session_storages_(new CannedBrowsingDataLocalStorageHelper(profile)) {
458 cookies_->SetCookieableSchemes( 483 cookies_->SetCookieableSchemes(
459 net::CookieMonster::kDefaultCookieableSchemes, 484 net::CookieMonster::kDefaultCookieableSchemes,
460 net::CookieMonster::kDefaultCookieableSchemesCount); 485 net::CookieMonster::kDefaultCookieableSchemesCount);
461 cookies_->SetKeepExpiredCookies(); 486 cookies_->SetKeepExpiredCookies();
462 } 487 }
463 488
464 TabSpecificContentSettings::LocalSharedObjectsContainer:: 489 TabSpecificContentSettings::LocalSharedObjectsContainer::
465 ~LocalSharedObjectsContainer() { 490 ~LocalSharedObjectsContainer() {
466 } 491 }
467 492
468 void TabSpecificContentSettings::LocalSharedObjectsContainer::Reset() { 493 void TabSpecificContentSettings::LocalSharedObjectsContainer::Reset() {
469 cookies_ = new net::CookieMonster(NULL, NULL); 494 cookies_ = new net::CookieMonster(NULL, NULL);
470 cookies_->SetCookieableSchemes( 495 cookies_->SetCookieableSchemes(
471 net::CookieMonster::kDefaultCookieableSchemes, 496 net::CookieMonster::kDefaultCookieableSchemes,
472 net::CookieMonster::kDefaultCookieableSchemesCount); 497 net::CookieMonster::kDefaultCookieableSchemesCount);
473 cookies_->SetKeepExpiredCookies(); 498 cookies_->SetKeepExpiredCookies();
474 appcaches_->Reset(); 499 appcaches_->Reset();
475 databases_->Reset(); 500 databases_->Reset();
501 file_systems_->Reset();
476 indexed_dbs_->Reset(); 502 indexed_dbs_->Reset();
477 local_storages_->Reset(); 503 local_storages_->Reset();
478 session_storages_->Reset(); 504 session_storages_->Reset();
479 } 505 }
480 506
481 CookiesTreeModel* 507 CookiesTreeModel*
482 TabSpecificContentSettings::LocalSharedObjectsContainer::GetCookiesTreeModel() { 508 TabSpecificContentSettings::LocalSharedObjectsContainer::GetCookiesTreeModel() {
483 return new CookiesTreeModel(cookies_, 509 return new CookiesTreeModel(cookies_,
484 databases_->Clone(), 510 databases_->Clone(),
485 local_storages_->Clone(), 511 local_storages_->Clone(),
486 session_storages_->Clone(), 512 session_storages_->Clone(),
487 appcaches_->Clone(), 513 appcaches_->Clone(),
488 indexed_dbs_->Clone(), 514 indexed_dbs_->Clone(),
515 file_systems_->Clone(),
489 true); 516 true);
490 } 517 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698