Index: chrome/browser/content_settings/tab_specific_content_settings.cc |
diff --git a/chrome/browser/content_settings/tab_specific_content_settings.cc b/chrome/browser/content_settings/tab_specific_content_settings.cc |
index 4f3cebd152271ba631c9af344d0fe380fa4ae459..7e2b04958eb41d320ffd4bb8e55f26baa57981c9 100644 |
--- a/chrome/browser/content_settings/tab_specific_content_settings.cc |
+++ b/chrome/browser/content_settings/tab_specific_content_settings.cc |
@@ -106,8 +106,8 @@ TabSpecificContentSettings::TabSpecificContentSettings(WebContents* tab) |
subresource_filter_enabled_(false), |
subresource_filter_blockage_indicated_(false), |
observer_(this) { |
- ClearBlockedContentSettingsExceptForCookies(); |
- ClearCookieSpecificContentSettings(); |
+ ClearBlockedContentSettingsExceptForNavigationRelatedSettings(); |
+ ClearNavigationRelatedContentSettings(); |
observer_.Add(HostContentSettingsMapFactory::GetForProfile( |
Profile::FromBrowserContext(tab->GetBrowserContext()))); |
@@ -217,15 +217,18 @@ void TabSpecificContentSettings::FileSystemAccessed(int render_process_id, |
} |
// static |
-void TabSpecificContentSettings::ServiceWorkerAccessed(int render_process_id, |
- int render_frame_id, |
- const GURL& scope, |
- bool blocked_by_policy) { |
+void TabSpecificContentSettings::ServiceWorkerAccessed( |
+ int render_process_id, |
+ int render_frame_id, |
+ const GURL& scope, |
+ bool blocked_by_policy_javascript, |
+ bool blocked_by_policy_cookie) { |
DCHECK_CURRENTLY_ON(BrowserThread::UI); |
TabSpecificContentSettings* settings = |
GetForFrame(render_process_id, render_frame_id); |
if (settings) |
- settings->OnServiceWorkerAccessed(scope, blocked_by_policy); |
+ settings->OnServiceWorkerAccessed(scope, blocked_by_policy_javascript, |
+ blocked_by_policy_cookie); |
} |
bool TabSpecificContentSettings::IsContentBlocked( |
@@ -470,15 +473,25 @@ void TabSpecificContentSettings::OnLocalStorageAccessed( |
void TabSpecificContentSettings::OnServiceWorkerAccessed( |
const GURL& scope, |
- bool blocked_by_policy) { |
+ bool blocked_by_policy_javascript, |
+ bool blocked_by_policy_cookie) { |
DCHECK(scope.is_valid()); |
- if (blocked_by_policy) { |
+ if (blocked_by_policy_javascript || blocked_by_policy_cookie) { |
blocked_local_shared_objects_.service_workers()->AddServiceWorker( |
scope.GetOrigin(), std::vector<GURL>(1, scope)); |
- OnContentBlocked(CONTENT_SETTINGS_TYPE_COOKIES); |
} else { |
allowed_local_shared_objects_.service_workers()->AddServiceWorker( |
scope.GetOrigin(), std::vector<GURL>(1, scope)); |
+ } |
+ |
+ if (blocked_by_policy_javascript) { |
+ OnContentBlocked(CONTENT_SETTINGS_TYPE_JAVASCRIPT); |
+ } else { |
+ OnContentAllowed(CONTENT_SETTINGS_TYPE_JAVASCRIPT); |
+ } |
+ if (blocked_by_policy_cookie) { |
+ OnContentBlocked(CONTENT_SETTINGS_TYPE_COOKIES); |
+ } else { |
OnContentAllowed(CONTENT_SETTINGS_TYPE_COOKIES); |
} |
} |
@@ -651,9 +664,11 @@ void TabSpecificContentSettings::OnMidiSysExAccessBlocked( |
OnContentBlocked(CONTENT_SETTINGS_TYPE_MIDI_SYSEX); |
} |
-void TabSpecificContentSettings::ClearBlockedContentSettingsExceptForCookies() { |
+void TabSpecificContentSettings:: |
+ClearBlockedContentSettingsExceptForNavigationRelatedSettings() { |
for (auto& status : content_settings_status_) { |
- if (status.first == CONTENT_SETTINGS_TYPE_COOKIES) |
+ if (status.first == CONTENT_SETTINGS_TYPE_COOKIES || |
+ status.first == CONTENT_SETTINGS_TYPE_JAVASCRIPT) |
falken
2016/10/05 01:16:50
Why was this change needed? Before this patch, if
shimazu
2016/10/05 02:10:57
Yes, the icon will be shown during navigation and
|
continue; |
status.second.blocked = false; |
status.second.blockage_indicated_to_user = false; |
@@ -667,14 +682,17 @@ void TabSpecificContentSettings::ClearBlockedContentSettingsExceptForCookies() { |
content::NotificationService::NoDetails()); |
} |
-void TabSpecificContentSettings::ClearCookieSpecificContentSettings() { |
+void TabSpecificContentSettings::ClearNavigationRelatedContentSettings() { |
blocked_local_shared_objects_.Reset(); |
allowed_local_shared_objects_.Reset(); |
- ContentSettingsStatus& status = |
- content_settings_status_[CONTENT_SETTINGS_TYPE_COOKIES]; |
- status.blocked = false; |
- status.blockage_indicated_to_user = false; |
- status.allowed = false; |
+ for (ContentSettingsType type : |
+ {CONTENT_SETTINGS_TYPE_COOKIES, CONTENT_SETTINGS_TYPE_JAVASCRIPT}) { |
+ ContentSettingsStatus& status = |
+ content_settings_status_[type]; |
+ status.blocked = false; |
+ status.blockage_indicated_to_user = false; |
+ status.allowed = false; |
+ } |
content::NotificationService::current()->Notify( |
chrome::NOTIFICATION_WEB_CONTENT_SETTINGS_CHANGED, |
content::Source<WebContents>(web_contents()), |
@@ -791,7 +809,7 @@ void TabSpecificContentSettings::DidStartNavigation( |
// settings delegate's cookies so the user has a chance to modify cookie |
// settings. |
if (!navigation_handle->IsErrorPage()) |
- ClearCookieSpecificContentSettings(); |
+ ClearNavigationRelatedContentSettings(); |
ClearGeolocationContentSettings(); |
ClearMidiContentSettings(); |
ClearPendingProtocolHandler(); |
@@ -806,7 +824,7 @@ void TabSpecificContentSettings::DidFinishNavigation( |
} |
// Clear "blocked" flags. |
- ClearBlockedContentSettingsExceptForCookies(); |
+ ClearBlockedContentSettingsExceptForNavigationRelatedSettings(); |
blocked_plugin_names_.clear(); |
GeolocationDidNavigate(navigation_handle); |
MidiDidNavigate(navigation_handle); |