<!--
Thanks for opening an issue! A few things to keep in mind:

- The issue tracker is only for bugs and feature requests.
- Before reporting a bug, please try reproducing your issue against
  the latest version of Electron.
- If you need general advice, join our Slack: http://atom-slack.herokuapp.com
-->

* Electron version: 1.7.9
* Operating system: macOS

### Expected behavior

The callback should be used only for URLs matching the filter.

```
const filter = { urls: ['*://www.googleapis.com'] };
session.defaultSession.webRequest.onBeforeRequest(filter, (details, callback) => {
  console.log('onBeforeRequest: ', details);
  callback({ cancel: true });
});
```

<!-- What do you think should happen? -->

### Actual behavior

The callback is called for random URLs.

```
onBeforeRequest:  { id: 1,
  method: 'GET',
  referrer: '',
  resourceType: 'mainFrame',
  timestamp: 1512654154551.9841,
  url: 'file:///Users/pronebird/apple/mail/build/index.html' }
onBeforeRequest:  { id: 4,
  method: 'GET',
  referrer: '',
  resourceType: 'mainFrame',
  timestamp: 1512654154564.2021,
  url: 'chrome-devtools://devtools/bundled/inspector.html?remoteBase=https://chrome-devtools-frontend.appspot.com/serve_file/@691bdb490962d4e6ae7f25c6ab1fdd0faaf19cd0/&can_dock=&toolbarColor=rgba(223,223,223,1)&textColor=rgba(0,0,0,1)&experiments=true' }
```

<!-- What actually happens? -->

shell/browser/api/atom_api_web_request.cc
URLPatterns patterns;
  mate::Dictionary dict;
  args->GetNext(&dict) && dict.Get("urls", &patterns);
  
  v8::Local<v8::Value> value;
  Listener listener;
  if (!args->GetNext(&listener) &&
      !(args->GetNext(&value) && value->IsNull())) {
    args->ThrowError("Must pass null or a Function");
    return;
  }
  auto* url_request_context_getter = static_cast<URLRequestContextGetter*>(
      browser_context_->GetRequestContext());
  if (!url_request_context_getter)
    return;
  base::PostTaskWithTraits(
      FROM_HERE, {BrowserThread::IO},
      base::BindOnce(&CallNetworkDelegateMethod<Method, Event, Listener>,
                     base::RetainedRef(url_request_context_getter), method,
                     type, std::move(patterns), std::move(listener)));
}
mate::Handle<WebRequest> WebRequest::Create(
    v8::Isolate* isolate,
    AtomBrowserContext* browser_context) {
  return mate::CreateHandle(isolate, new WebRequest(isolate, browser_context));
}
void WebRequest::BuildPrototype(v8::Isolate* isolate,