From 62f4b25cf92a3e1c275e4cfed0ce6bfa27780b07 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Fri, 11 Dec 2015 19:11:09 +0800 Subject: [PATCH] Allow passing null to webRequest --- atom/browser/api/atom_api_web_request.cc | 11 ++++++----- atom/browser/api/atom_api_web_request.h | 2 -- atom/browser/net/atom_network_delegate.h | 1 - 3 files changed, 6 insertions(+), 8 deletions(-) diff --git a/atom/browser/api/atom_api_web_request.cc b/atom/browser/api/atom_api_web_request.cc index 07c0576977dc..a1b4df70c130 100644 --- a/atom/browser/api/atom_api_web_request.cc +++ b/atom/browser/api/atom_api_web_request.cc @@ -28,13 +28,14 @@ WebRequest::~WebRequest() { template void WebRequest::SetListener(mate::Arguments* args) { - DCHECK_CURRENTLY_ON(BrowserThread::UI); - - scoped_ptr filter(new base::DictionaryValue()); + scoped_ptr filter(new base::DictionaryValue); args->GetNext(filter.get()); + + v8::Local value; AtomNetworkDelegate::Listener callback; - if (!args->GetNext(&callback)) { - args->ThrowError("Must pass null or a function"); + if (!args->GetNext(&callback) && + !(args->GetNext(&value) && value->IsNull())) { + args->ThrowError("Must pass null or a Function"); return; } diff --git a/atom/browser/api/atom_api_web_request.h b/atom/browser/api/atom_api_web_request.h index 597bb80f7c65..f156b5816195 100644 --- a/atom/browser/api/atom_api_web_request.h +++ b/atom/browser/api/atom_api_web_request.h @@ -5,8 +5,6 @@ #ifndef ATOM_BROWSER_API_ATOM_API_WEB_REQUEST_H_ #define ATOM_BROWSER_API_ATOM_API_WEB_REQUEST_H_ -#include - #include "atom/browser/api/trackable_object.h" #include "atom/browser/net/atom_network_delegate.h" #include "native_mate/arguments.h" diff --git a/atom/browser/net/atom_network_delegate.h b/atom/browser/net/atom_network_delegate.h index 9f78cc8d92da..adc6935f2086 100644 --- a/atom/browser/net/atom_network_delegate.h +++ b/atom/browser/net/atom_network_delegate.h @@ -7,7 +7,6 @@ #include #include -#include #include "brightray/browser/network_delegate.h" #include "base/callback.h"