<!--
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
URLRequestContextGetter* url_request_context_getter,
    Method method,
    Event type,
    URLPatterns patterns,
    Listener listener) {
  
  url_request_context_getter->GetURLRequestContext();
  
  auto* network_delegate = url_request_context_getter->network_delegate();
  (network_delegate->*method)(type, std::move(patterns), std::move(listener));
}
}  
WebRequest::WebRequest(v8::Isolate* isolate,
                       AtomBrowserContext* browser_context)
    : browser_context_(browser_context) {
  Init(isolate);
}
WebRequest::~WebRequest() {}
template <AtomNetworkDelegate::SimpleEvent type>
void WebRequest::SetSimpleListener(mate::Arguments* args) {
  SetListener<AtomNetworkDelegate::SimpleListener>(
      &AtomNetworkDelegate::SetSimpleListenerInIO, type, args);
}
template <AtomNetworkDelegate::ResponseEvent type>
void WebRequest::SetResponseListener(mate::Arguments* args) {
  SetListener<AtomNetworkDelegate::ResponseListener>(
      &AtomNetworkDelegate::SetResponseListenerInIO, type, args);
}
template <typename Listener, typename Method, typename Event>
void WebRequest::SetListener(Method method, Event type, mate::Arguments* args) {