Chromium Code Reviews| Index: content/browser/service_worker/service_worker_dispatcher_host.cc |
| diff --git a/content/browser/service_worker/service_worker_dispatcher_host.cc b/content/browser/service_worker/service_worker_dispatcher_host.cc |
| index c0e32cee57284480dc9383c33efd166ab64c10c8..cd36e3ee85c0c5925ef07d8a2b2fd5d5865712a6 100644 |
| --- a/content/browser/service_worker/service_worker_dispatcher_host.cc |
| +++ b/content/browser/service_worker/service_worker_dispatcher_host.cc |
| @@ -81,6 +81,26 @@ WebContents* GetWebContents(int render_process_id, int render_frame_id) { |
| return WebContents::FromRenderFrameHost(rfh); |
| } |
| +std::string GetNavigationPreloadDisabledErrorMessage( |
| + ServiceWorkerVersion::NavigationPreloadSupportStatus support_status) { |
| + switch (support_status) { |
| + case ServiceWorkerVersion::NavigationPreloadSupportStatus::SUPPORTED: |
| + NOTREACHED(); |
| + break; |
| + case ServiceWorkerVersion::NavigationPreloadSupportStatus:: |
| + NOT_SUPPORTED_FILELD_TRIAL_STOPPED: |
| + return "Navigation Preload field trial is stopped."; |
|
falken
2017/01/13 09:13:20
nit: is "field trial" a term we use in public? May
horo
2017/01/13 09:27:57
Done.
|
| + case ServiceWorkerVersion::NavigationPreloadSupportStatus:: |
| + NOT_SUPPORTED_DISABLED_BY_COMMAND_LINE: |
| + return "Navigation Preload is disabled by command line flag."; |
| + case ServiceWorkerVersion::NavigationPreloadSupportStatus:: |
| + NOT_SUPPORTED_NO_VALID_ORIGIN_TRIAL_TOKEN: |
| + return "No valid Navigation Preload Orignin Trial token for the script."; |
|
falken
2017/01/13 09:13:20
nit: "Origin"
May be good to say "service worker
horo
2017/01/13 09:27:57
Done.
|
| + } |
| + NOTREACHED(); |
| + return ""; |
| +} |
| + |
| } // namespace |
| ServiceWorkerDispatcherHost::ServiceWorkerDispatcherHost( |
| @@ -717,6 +737,17 @@ void ServiceWorkerDispatcherHost::OnEnableNavigationPreload( |
| return; |
| } |
| + ServiceWorkerVersion::NavigationPreloadSupportStatus support_status = |
| + registration->active_version()->GetNavigationPreloadSupportStatus(); |
| + if (support_status != |
| + ServiceWorkerVersion::NavigationPreloadSupportStatus::SUPPORTED) { |
| + Send(new ServiceWorkerMsg_EnableNavigationPreloadError( |
| + thread_id, request_id, WebServiceWorkerError::ErrorTypeAbort, |
| + std::string(kEnableNavigationPreloadErrorPrefix) + |
| + GetNavigationPreloadDisabledErrorMessage(support_status))); |
| + return; |
| + } |
| + |
| std::vector<GURL> urls = {provider_host->document_url(), |
| registration->pattern()}; |
| if (!ServiceWorkerUtils::AllOriginsMatchAndCanAccessServiceWorkers(urls)) { |
| @@ -859,6 +890,16 @@ void ServiceWorkerDispatcherHost::OnSetNavigationPreloadHeader( |
| return; |
| } |
| + ServiceWorkerVersion::NavigationPreloadSupportStatus support_status = |
| + registration->active_version()->GetNavigationPreloadSupportStatus(); |
| + if (support_status != |
| + ServiceWorkerVersion::NavigationPreloadSupportStatus::SUPPORTED) { |
| + Send(new ServiceWorkerMsg_SetNavigationPreloadHeaderError( |
| + thread_id, request_id, WebServiceWorkerError::ErrorTypeAbort, |
| + std::string(kSetNavigationPreloadHeaderErrorPrefix) + |
| + GetNavigationPreloadDisabledErrorMessage(support_status))); |
| + return; |
| + } |
| std::vector<GURL> urls = {provider_host->document_url(), |
| registration->pattern()}; |
| if (!ServiceWorkerUtils::AllOriginsMatchAndCanAccessServiceWorkers(urls)) { |