Fix HasServiceWorker check

Revert cb2014f9e8ae0283e5f20d4e2167be1592228887.
This commit is contained in:
Tony Ganch 2017-06-21 12:34:14 +02:00 committed by Aleksei Kuzmin
parent e2fe95894f
commit 4d9f309888
2 changed files with 14 additions and 4 deletions

View file

@ -1238,14 +1238,25 @@ void WebContents::InspectServiceWorker() {
}
void WebContents::HasServiceWorker(
const base::Callback<void(content::ServiceWorkerCapability)>& callback) {
const base::Callback<void(bool)>& callback) {
auto context = GetServiceWorkerContext(web_contents());
if (!context)
return;
struct WrappedCallback {
base::Callback<void(bool)> callback_;
WrappedCallback(const base::Callback<void(bool)>& callback) : callback_(callback) {}
void Run(content::ServiceWorkerCapability capability) {
callback_.Run(capability != content::ServiceWorkerCapability::NO_SERVICE_WORKER);
delete this;
}
};
auto wrapped_callback = new WrappedCallback(callback);
context->CheckHasServiceWorker(web_contents()->GetLastCommittedURL(),
GURL::EmptyGURL(),
callback);
base::Bind(&WrappedCallback::Run, base::Unretained(wrapped_callback)));
}
void WebContents::UnregisterServiceWorker(