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

Unified Diff: chrome/browser/chrome_content_browser_client.cc

Issue 2377603002: Disable ServiceWorker when JS is disabled (Closed)
Patch Set: Updated comments, removed the mock headers and renamed the function Created 4 years, 2 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | chrome/browser/chrome_service_worker_browsertest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/chrome_content_browser_client.cc
diff --git a/chrome/browser/chrome_content_browser_client.cc b/chrome/browser/chrome_content_browser_client.cc
index 7e0d304a0ace749f9382e3fa59cdf060e416894e..d53349a0ac796b6503047aec4921b0be22129883 100644
--- a/chrome/browser/chrome_content_browser_client.cc
+++ b/chrome/browser/chrome_content_browser_client.cc
@@ -1808,18 +1808,30 @@ bool ChromeContentBrowserClient::AllowServiceWorker(
#endif
ProfileIOData* io_data = ProfileIOData::FromResourceContext(context);
- bool allow = io_data->GetCookieSettings()->IsSettingCookieAllowed(
- scope, first_party_url);
+ // Check if JavaScript is allowed.
+ content_settings::SettingInfo info;
+ std::unique_ptr<base::Value> value =
+ io_data->GetHostContentSettingsMap()->GetWebsiteSetting(
+ first_party_url, first_party_url, CONTENT_SETTINGS_TYPE_JAVASCRIPT,
+ std::string(), &info);
+ ContentSetting setting = content_settings::ValueToContentSetting(value.get());
+ bool allow_javascript = (setting == CONTENT_SETTING_ALLOW);
+
+ // Check if cookies are allowed.
+ bool allow_serviceworker =
+ io_data->GetCookieSettings()->IsSettingCookieAllowed(scope,
+ first_party_url);
// Record access to database for potential display in UI.
// Only post the task if this is for a specific frame.
if (render_process_id != -1 && render_frame_id != -1) {
BrowserThread::PostTask(
BrowserThread::UI, FROM_HERE,
base::Bind(&TabSpecificContentSettings::ServiceWorkerAccessed,
- render_process_id, render_frame_id, scope, !allow));
+ render_process_id, render_frame_id, scope,
+ !allow_javascript, !allow_serviceworker));
}
- return allow;
+ return allow_javascript && allow_serviceworker;
}
bool ChromeContentBrowserClient::AllowGetCookie(
« no previous file with comments | « no previous file | chrome/browser/chrome_service_worker_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698