Fix HasServiceWorker check
Revert cb2014f9e8ae0283e5f20d4e2167be1592228887.
This commit is contained in:
parent
e2fe95894f
commit
4d9f309888
2 changed files with 14 additions and 4 deletions
|
@ -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(
|
||||
|
|
|
@ -15,7 +15,6 @@
|
|||
#include "atom/browser/ui/autofill_popup.h"
|
||||
#include "content/common/cursors/webcursor.h"
|
||||
#include "content/public/browser/keyboard_event_processing_result.h"
|
||||
#include "content/public/browser/service_worker_context.h"
|
||||
#include "content/public/browser/web_contents_observer.h"
|
||||
#include "content/public/common/favicon_url.h"
|
||||
#include "native_mate/handle.h"
|
||||
|
@ -118,7 +117,7 @@ class WebContents : public mate::TrackableObject<WebContents>,
|
|||
void InspectElement(int x, int y);
|
||||
void InspectServiceWorker();
|
||||
void HasServiceWorker(
|
||||
const base::Callback<void(content::ServiceWorkerCapability)>&);
|
||||
const base::Callback<void(bool)>&);
|
||||
void UnregisterServiceWorker(const base::Callback<void(bool)>&);
|
||||
void SetIgnoreMenuShortcuts(bool ignore);
|
||||
void SetAudioMuted(bool muted);
|
||||
|
|
Loading…
Add table
Reference in a new issue