| OLD | NEW |
| 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/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/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/lazy_instance.h" | 10 #include "base/lazy_instance.h" |
| (...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 230 int render_frame_id, | 230 int render_frame_id, |
| 231 const GURL& url, | 231 const GURL& url, |
| 232 bool blocked_by_policy) { | 232 bool blocked_by_policy) { |
| 233 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 233 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 234 TabSpecificContentSettings* settings = GetForFrame( | 234 TabSpecificContentSettings* settings = GetForFrame( |
| 235 render_process_id, render_frame_id); | 235 render_process_id, render_frame_id); |
| 236 if (settings) | 236 if (settings) |
| 237 settings->OnFileSystemAccessed(url, blocked_by_policy); | 237 settings->OnFileSystemAccessed(url, blocked_by_policy); |
| 238 } | 238 } |
| 239 | 239 |
| 240 // static |
| 241 void TabSpecificContentSettings::ServiceWorkerAccessed(int render_process_id, |
| 242 int render_frame_id, |
| 243 const GURL& scope, |
| 244 bool blocked_by_policy) { |
| 245 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 246 DCHECK(scope.is_valid()); |
| 247 |
| 248 TabSpecificContentSettings* settings = |
| 249 GetForFrame(render_process_id, render_frame_id); |
| 250 if (settings) |
| 251 settings->OnServiceWorkerAccessed(scope, blocked_by_policy); |
| 252 } |
| 253 |
| 240 bool TabSpecificContentSettings::IsContentBlocked( | 254 bool TabSpecificContentSettings::IsContentBlocked( |
| 241 ContentSettingsType content_type) const { | 255 ContentSettingsType content_type) const { |
| 242 DCHECK(content_type != CONTENT_SETTINGS_TYPE_GEOLOCATION) | 256 DCHECK(content_type != CONTENT_SETTINGS_TYPE_GEOLOCATION) |
| 243 << "Geolocation settings handled by ContentSettingGeolocationImageModel"; | 257 << "Geolocation settings handled by ContentSettingGeolocationImageModel"; |
| 244 DCHECK(content_type != CONTENT_SETTINGS_TYPE_NOTIFICATIONS) | 258 DCHECK(content_type != CONTENT_SETTINGS_TYPE_NOTIFICATIONS) |
| 245 << "Notifications settings handled by " | 259 << "Notifications settings handled by " |
| 246 << "ContentSettingsNotificationsImageModel"; | 260 << "ContentSettingsNotificationsImageModel"; |
| 247 | 261 |
| 248 if (content_type == CONTENT_SETTINGS_TYPE_IMAGES || | 262 if (content_type == CONTENT_SETTINGS_TYPE_IMAGES || |
| 249 content_type == CONTENT_SETTINGS_TYPE_JAVASCRIPT || | 263 content_type == CONTENT_SETTINGS_TYPE_JAVASCRIPT || |
| (...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 455 helper->AddLocalStorage(url); | 469 helper->AddLocalStorage(url); |
| 456 | 470 |
| 457 if (blocked_by_policy) | 471 if (blocked_by_policy) |
| 458 OnContentBlocked(CONTENT_SETTINGS_TYPE_COOKIES); | 472 OnContentBlocked(CONTENT_SETTINGS_TYPE_COOKIES); |
| 459 else | 473 else |
| 460 OnContentAllowed(CONTENT_SETTINGS_TYPE_COOKIES); | 474 OnContentAllowed(CONTENT_SETTINGS_TYPE_COOKIES); |
| 461 | 475 |
| 462 NotifySiteDataObservers(); | 476 NotifySiteDataObservers(); |
| 463 } | 477 } |
| 464 | 478 |
| 479 void TabSpecificContentSettings::OnServiceWorkerAccessed( |
| 480 const GURL& scope, |
| 481 bool blocked_by_policy) { |
| 482 DCHECK(scope.is_valid()); |
| 483 if (blocked_by_policy) { |
| 484 blocked_local_shared_objects_.service_workers()->AddServiceWorker( |
| 485 scope.GetOrigin(), std::vector<GURL>(1, scope)); |
| 486 OnContentBlocked(CONTENT_SETTINGS_TYPE_COOKIES); |
| 487 } else { |
| 488 allowed_local_shared_objects_.service_workers()->AddServiceWorker( |
| 489 scope.GetOrigin(), std::vector<GURL>(1, scope)); |
| 490 OnContentAllowed(CONTENT_SETTINGS_TYPE_COOKIES); |
| 491 } |
| 492 } |
| 493 |
| 465 void TabSpecificContentSettings::OnWebDatabaseAccessed( | 494 void TabSpecificContentSettings::OnWebDatabaseAccessed( |
| 466 const GURL& url, | 495 const GURL& url, |
| 467 const base::string16& name, | 496 const base::string16& name, |
| 468 const base::string16& display_name, | 497 const base::string16& display_name, |
| 469 bool blocked_by_policy) { | 498 bool blocked_by_policy) { |
| 470 if (blocked_by_policy) { | 499 if (blocked_by_policy) { |
| 471 blocked_local_shared_objects_.databases()->AddDatabase( | 500 blocked_local_shared_objects_.databases()->AddDatabase( |
| 472 url, base::UTF16ToUTF8(name), base::UTF16ToUTF8(display_name)); | 501 url, base::UTF16ToUTF8(name), base::UTF16ToUTF8(display_name)); |
| 473 OnContentBlocked(CONTENT_SETTINGS_TYPE_COOKIES); | 502 OnContentBlocked(CONTENT_SETTINGS_TYPE_COOKIES); |
| 474 } else { | 503 } else { |
| (...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 793 | 822 |
| 794 void TabSpecificContentSettings::GeolocationDidNavigate( | 823 void TabSpecificContentSettings::GeolocationDidNavigate( |
| 795 const content::LoadCommittedDetails& details) { | 824 const content::LoadCommittedDetails& details) { |
| 796 geolocation_usages_state_.DidNavigate(GetCommittedDetails(details)); | 825 geolocation_usages_state_.DidNavigate(GetCommittedDetails(details)); |
| 797 } | 826 } |
| 798 | 827 |
| 799 void TabSpecificContentSettings::MidiDidNavigate( | 828 void TabSpecificContentSettings::MidiDidNavigate( |
| 800 const content::LoadCommittedDetails& details) { | 829 const content::LoadCommittedDetails& details) { |
| 801 midi_usages_state_.DidNavigate(GetCommittedDetails(details)); | 830 midi_usages_state_.DidNavigate(GetCommittedDetails(details)); |
| 802 } | 831 } |
| OLD | NEW |