diff --git a/atom/browser/api/atom_api_session.cc b/atom/browser/api/atom_api_session.cc index 9cec7378b8e0..8b73d61622ec 100644 --- a/atom/browser/api/atom_api_session.cc +++ b/atom/browser/api/atom_api_session.cc @@ -10,6 +10,7 @@ #include "atom/browser/api/atom_api_cookies.h" #include "atom/browser/api/atom_api_download_item.h" #include "atom/browser/api/atom_api_web_contents.h" +#include "atom/browser/api/atom_api_web_request.h" #include "atom/browser/api/save_page_handler.h" #include "atom/browser/atom_browser_context.h" #include "atom/browser/atom_browser_main_parts.h" @@ -368,6 +369,14 @@ v8::Local Session::Cookies(v8::Isolate* isolate) { return v8::Local::New(isolate, cookies_); } +v8::Local Session::WebRequest(v8::Isolate* isolate) { + if (web_request_.IsEmpty()) { + auto handle = atom::api::WebRequest::Create(isolate, browser_context()); + web_request_.Reset(isolate, handle.ToV8()); + } + return v8::Local::New(isolate, web_request_); +} + // static mate::Handle Session::CreateFrom( v8::Isolate* isolate, AtomBrowserContext* browser_context) { @@ -401,7 +410,8 @@ void Session::BuildPrototype(v8::Isolate* isolate, .SetMethod("enableNetworkEmulation", &Session::EnableNetworkEmulation) .SetMethod("disableNetworkEmulation", &Session::DisableNetworkEmulation) .SetMethod("setCertificateVerifyProc", &Session::SetCertVerifyProc) - .SetProperty("cookies", &Session::Cookies); + .SetProperty("cookies", &Session::Cookies) + .SetProperty("webRequest", &Session::WebRequest); } void ClearWrapSession() { diff --git a/atom/browser/api/atom_api_session.h b/atom/browser/api/atom_api_session.h index e800a992d4b7..0034b1480632 100644 --- a/atom/browser/api/atom_api_session.h +++ b/atom/browser/api/atom_api_session.h @@ -70,9 +70,11 @@ class Session: public mate::TrackableObject, void DisableNetworkEmulation(); void SetCertVerifyProc(v8::Local proc, mate::Arguments* args); v8::Local Cookies(v8::Isolate* isolate); + v8::Local WebRequest(v8::Isolate* isolate); - // Cached object for cookies API. + // Cached object. v8::Global cookies_; + v8::Global web_request_; scoped_refptr browser_context_; diff --git a/atom/browser/api/atom_api_web_request.cc b/atom/browser/api/atom_api_web_request.cc new file mode 100644 index 000000000000..ad772e4c2963 --- /dev/null +++ b/atom/browser/api/atom_api_web_request.cc @@ -0,0 +1,116 @@ +// Copyright (c) 2015 GitHub, Inc. +// Use of this source code is governed by the MIT license that can be +// found in the LICENSE file. + +#include "atom/browser/api/atom_api_web_request.h" + +#include "atom/browser/atom_browser_context.h" +#include "atom/browser/net/atom_network_delegate.h" +#include "atom/common/native_mate_converters/callback.h" +#include "atom/common/native_mate_converters/net_converter.h" +#include "atom/common/native_mate_converters/value_converter.h" +#include "content/public/browser/browser_thread.h" +#include "native_mate/dictionary.h" +#include "native_mate/object_template_builder.h" + +using content::BrowserThread; + +namespace atom { + +namespace api { + +WebRequest::WebRequest(AtomBrowserContext* browser_context) + : browser_context_(browser_context) { +} + +WebRequest::~WebRequest() { +} + +template +void WebRequest::SetListener(mate::Arguments* args) { + DCHECK_CURRENTLY_ON(BrowserThread::UI); + + base::DictionaryValue* filter = new base::DictionaryValue(); + args->GetNext(filter); + AtomNetworkDelegate::Listener callback; + if (!args->GetNext(&callback)) { + args->ThrowError("Must pass null or a function"); + return; + } + + auto delegate = browser_context_->network_delegate(); + BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, + base::Bind(&AtomNetworkDelegate::SetListenerInIO, + base::Unretained(delegate), + type, filter, callback)); +} + +mate::ObjectTemplateBuilder WebRequest::GetObjectTemplateBuilder( + v8::Isolate* isolate) { + return mate::ObjectTemplateBuilder(isolate) + .SetMethod("onBeforeRequest", + &WebRequest::SetListener< + AtomNetworkDelegate::kOnBeforeRequest>) + .SetMethod("onBeforeSendHeaders", + &WebRequest::SetListener< + AtomNetworkDelegate::kOnBeforeSendHeaders>) + .SetMethod("onSendHeaders", + &WebRequest::SetListener< + AtomNetworkDelegate::kOnSendHeaders>) + .SetMethod("onHeadersReceived", + &WebRequest::SetListener< + AtomNetworkDelegate::kOnHeadersReceived>) + .SetMethod("onBeforeRedirect", + &WebRequest::SetListener< + AtomNetworkDelegate::kOnBeforeRedirect>) + .SetMethod("onResponseStarted", + &WebRequest::SetListener< + AtomNetworkDelegate::kOnResponseStarted>) + .SetMethod("onCompleted", + &WebRequest::SetListener< + AtomNetworkDelegate::kOnCompleted>) + .SetMethod("onErrorOccurred", + &WebRequest::SetListener< + AtomNetworkDelegate::kOnErrorOccurred>); +} + +// static +mate::Handle WebRequest::Create( + v8::Isolate* isolate, + AtomBrowserContext* browser_context) { + return mate::CreateHandle(isolate, new WebRequest(browser_context)); +} + +// static +void WebRequest::BuildPrototype(v8::Isolate* isolate, + v8::Local prototype) { + mate::ObjectTemplateBuilder(isolate, prototype) + .SetMethod("onBeforeRequest", + &WebRequest::SetListener< + AtomNetworkDelegate::kOnBeforeRequest>) + .SetMethod("onBeforeSendHeaders", + &WebRequest::SetListener< + AtomNetworkDelegate::kOnBeforeSendHeaders>) + .SetMethod("onSendHeaders", + &WebRequest::SetListener< + AtomNetworkDelegate::kOnSendHeaders>) + .SetMethod("onHeadersReceived", + &WebRequest::SetListener< + AtomNetworkDelegate::kOnHeadersReceived>) + .SetMethod("onBeforeRedirect", + &WebRequest::SetListener< + AtomNetworkDelegate::kOnBeforeRedirect>) + .SetMethod("onResponseStarted", + &WebRequest::SetListener< + AtomNetworkDelegate::kOnResponseStarted>) + .SetMethod("onCompleted", + &WebRequest::SetListener< + AtomNetworkDelegate::kOnCompleted>) + .SetMethod("onErrorOccurred", + &WebRequest::SetListener< + AtomNetworkDelegate::kOnErrorOccurred>); +} + +} // namespace api + +} // namespace atom diff --git a/atom/browser/api/atom_api_web_request.h b/atom/browser/api/atom_api_web_request.h new file mode 100644 index 000000000000..04fb758a9a7c --- /dev/null +++ b/atom/browser/api/atom_api_web_request.h @@ -0,0 +1,51 @@ +// Copyright (c) 2015 GitHub, Inc. +// Use of this source code is governed by the MIT license that can be +// found in the LICENSE file. + +#ifndef ATOM_BROWSER_API_ATOM_API_WEB_REQUEST_H_ +#define ATOM_BROWSER_API_ATOM_API_WEB_REQUEST_H_ + +#include + +#include "atom/browser/net/atom_network_delegate.h" +#include "base/callback.h" +#include "native_mate/arguments.h" +#include "native_mate/wrappable.h" + +namespace atom { + +class AtomBrowserContext; + +namespace api { + +class WebRequest : public mate::TrackableObject { + public: + static mate::Handle Create(v8::Isolate* isolate, + AtomBrowserContext* browser_context); + + // mate::TrackableObject: + static void BuildPrototype(v8::Isolate* isolate, + v8::Local prototype); + + protected: + explicit WebRequest(AtomBrowserContext* browser_context); + ~WebRequest(); + + template + void SetListener(mate::Arguments* args); + + // mate::Wrappable: + mate::ObjectTemplateBuilder GetObjectTemplateBuilder( + v8::Isolate* isolate) override; + + private: + scoped_refptr browser_context_; + + DISALLOW_COPY_AND_ASSIGN(WebRequest); +}; + +} // namespace api + +} // namespace atom + +#endif // ATOM_BROWSER_API_ATOM_API_WEB_REQUEST_H_ diff --git a/atom/browser/atom_browser_context.cc b/atom/browser/atom_browser_context.cc index ec123825822e..12e0125752eb 100644 --- a/atom/browser/atom_browser_context.cc +++ b/atom/browser/atom_browser_context.cc @@ -8,6 +8,7 @@ #include "atom/browser/atom_download_manager_delegate.h" #include "atom/browser/browser.h" #include "atom/browser/net/atom_cert_verifier.h" +#include "atom/browser/net/atom_network_delegate.h" #include "atom/browser/net/atom_ssl_config_service.h" #include "atom/browser/net/atom_url_request_job_factory.h" #include "atom/browser/net/asar/asar_protocol_handler.h" @@ -63,12 +64,17 @@ AtomBrowserContext::AtomBrowserContext(const std::string& partition, : brightray::BrowserContext(partition, in_memory), cert_verifier_(nullptr), job_factory_(new AtomURLRequestJobFactory), + network_delegate_(new AtomNetworkDelegate), allow_ntlm_everywhere_(false) { } AtomBrowserContext::~AtomBrowserContext() { } +net::NetworkDelegate* AtomBrowserContext::CreateNetworkDelegate() { + return network_delegate_; +} + std::string AtomBrowserContext::GetUserAgent() { Browser* browser = Browser::Get(); std::string name = RemoveWhitespace(browser->GetName()); diff --git a/atom/browser/atom_browser_context.h b/atom/browser/atom_browser_context.h index 564c9955d917..9c94a60c305b 100644 --- a/atom/browser/atom_browser_context.h +++ b/atom/browser/atom_browser_context.h @@ -13,6 +13,7 @@ namespace atom { class AtomDownloadManagerDelegate; class AtomCertVerifier; +class AtomNetworkDelegate; class AtomURLRequestJobFactory; class WebViewManager; @@ -22,6 +23,7 @@ class AtomBrowserContext : public brightray::BrowserContext { ~AtomBrowserContext() override; // brightray::URLRequestContextGetter::Delegate: + net::NetworkDelegate* CreateNetworkDelegate() override; std::string GetUserAgent() override; scoped_ptr CreateURLRequestJobFactory( content::ProtocolHandlerMap* handlers, @@ -45,6 +47,8 @@ class AtomBrowserContext : public brightray::BrowserContext { AtomURLRequestJobFactory* job_factory() const { return job_factory_; } + AtomNetworkDelegate* network_delegate() const { return network_delegate_; } + private: scoped_ptr download_manager_delegate_; scoped_ptr guest_manager_; @@ -52,6 +56,7 @@ class AtomBrowserContext : public brightray::BrowserContext { // Managed by brightray::BrowserContext. AtomCertVerifier* cert_verifier_; AtomURLRequestJobFactory* job_factory_; + AtomNetworkDelegate* network_delegate_; bool allow_ntlm_everywhere_; diff --git a/atom/browser/net/atom_network_delegate.cc b/atom/browser/net/atom_network_delegate.cc new file mode 100644 index 000000000000..3b3c8f971987 --- /dev/null +++ b/atom/browser/net/atom_network_delegate.cc @@ -0,0 +1,220 @@ +// Copyright (c) 2015 GitHub, Inc. +// Use of this source code is governed by the MIT license that can be +// found in the LICENSE file. + +#include "atom/browser/net/atom_network_delegate.h" + +#include + +#include "atom/common/native_mate_converters/net_converter.h" +#include "content/public/browser/browser_thread.h" +#include "content/public/browser/resource_request_info.h" +#include "net/base/net_errors.h" +#include "net/url_request/url_request.h" + +using content::BrowserThread; + +namespace atom { + +namespace { + +base::DictionaryValue* ExtractRequestInfo(net::URLRequest* request) { + base::DictionaryValue* dict = new base::DictionaryValue(); + dict->SetInteger("id", request->identifier()); + dict->SetString("url", request->url().spec()); + dict->SetString("method", request->method()); + content::ResourceType resourceType = content::RESOURCE_TYPE_LAST_TYPE; + auto info = content::ResourceRequestInfo::ForRequest(request); + if (info) + resourceType = info->GetResourceType(); + dict->SetInteger("resourceType", resourceType); + dict->SetDouble("timestamp", base::Time::Now().ToDoubleT() * 1000); + + return dict; +} + +base::DictionaryValue* GetRequestHeadersDict( + const net::HttpRequestHeaders& headers) { + base::DictionaryValue* header_dict = new base::DictionaryValue(); + net::HttpRequestHeaders::Iterator it(headers); + while (it.GetNext()) + header_dict->SetString(it.name(), it.value()); + return header_dict; +} + +base::DictionaryValue* GetResponseHeadersDict( + const net::HttpResponseHeaders* headers) { + base::DictionaryValue* header_dict = new base::DictionaryValue(); + if (headers) { + void* iter = nullptr; + std::string key; + std::string value; + while (headers->EnumerateHeaderLines(&iter, &key, &value)) + header_dict->SetString(key, value); + } + return header_dict; +} + +void OnBeforeURLRequestResponse( + const net::CompletionCallback& callback, + GURL* new_url, + const AtomNetworkDelegate::BlockingResponse& result) { + if (!result.redirectURL.is_empty()) + *new_url = result.redirectURL; + callback.Run(result.cancel); +} + +void OnBeforeSendHeadersResponse( + const net::CompletionCallback& callback, + net::HttpRequestHeaders* headers, + const AtomNetworkDelegate::BlockingResponse& result) { + if (!result.requestHeaders.IsEmpty()) + *headers = result.requestHeaders; + callback.Run(result.cancel); +} + +void OnHeadersReceivedResponse( + const net::CompletionCallback& callback, + scoped_refptr* override_response_headers, + const AtomNetworkDelegate::BlockingResponse& result) { + if (result.responseHeaders.get()) + *override_response_headers = result.responseHeaders; + callback.Run(result.cancel); +} + +} // namespace + +// static +std::map +AtomNetworkDelegate::event_listener_map_; + +AtomNetworkDelegate::AtomNetworkDelegate() { +} + +AtomNetworkDelegate::~AtomNetworkDelegate() { +} + +void AtomNetworkDelegate::SetListenerInIO( + EventTypes type, + const base::DictionaryValue* filter, + const Listener& callback) { + ListenerInfo info; + info.callback = callback; + event_listener_map_[type] = info; +} + +int AtomNetworkDelegate::OnBeforeURLRequest( + net::URLRequest* request, + const net::CompletionCallback& callback, + GURL* new_url) { + brightray::NetworkDelegate::OnBeforeURLRequest(request, callback, new_url); + + auto listener_info = event_listener_map_[kOnBeforeRequest]; + if (!event_listener_map_.empty() && !listener_info.callback.is_null()) { + auto wrapped_callback = listener_info.callback; + auto details = ExtractRequestInfo(request); + + BrowserThread::PostTaskAndReplyWithResult(BrowserThread::UI, FROM_HERE, + base::Bind(wrapped_callback, details), + base::Bind(&OnBeforeURLRequestResponse, + callback, new_url)); + + return net::ERR_IO_PENDING; + } + + return net::OK; +} + +int AtomNetworkDelegate::OnBeforeSendHeaders( + net::URLRequest* request, + const net::CompletionCallback& callback, + net::HttpRequestHeaders* headers) { + auto listener_info = event_listener_map_[kOnBeforeSendHeaders]; + if (!event_listener_map_.empty() && !listener_info.callback.is_null()) { + auto wrapped_callback = listener_info.callback; + auto details = ExtractRequestInfo(request); + details->Set("requestHeaders", GetRequestHeadersDict(*headers)); + + BrowserThread::PostTaskAndReplyWithResult(BrowserThread::UI, FROM_HERE, + base::Bind(wrapped_callback, details), + base::Bind(&OnBeforeSendHeadersResponse, + callback, headers)); + + return net::ERR_IO_PENDING; + } + + return net::OK; +} + +void AtomNetworkDelegate::OnSendHeaders( + net::URLRequest* request, + const net::HttpRequestHeaders& headers) { + auto listener_info = event_listener_map_[kOnSendHeaders]; + if (!event_listener_map_.empty() && !listener_info.callback.is_null()) { + auto wrapped_callback = listener_info.callback; + auto details = ExtractRequestInfo(request); + details->Set("requestHeaders", GetRequestHeadersDict(headers)); + + BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, + base::Bind(base::IgnoreResult(wrapped_callback), + details)); + } +} + +int AtomNetworkDelegate::OnHeadersReceived( + net::URLRequest* request, + const net::CompletionCallback& callback, + const net::HttpResponseHeaders* original_response_headers, + scoped_refptr* override_response_headers, + GURL* allowed_unsafe_redirect_url) { + auto listener_info = event_listener_map_[kOnHeadersReceived]; + if (!event_listener_map_.empty() && !listener_info.callback.is_null()) { + auto wrapped_callback = listener_info.callback; + auto details = ExtractRequestInfo(request); + details->Set("responseHeaders", + GetResponseHeadersDict(original_response_headers)); + + BrowserThread::PostTaskAndReplyWithResult(BrowserThread::UI, FROM_HERE, + base::Bind(wrapped_callback, details), + base::Bind(&OnHeadersReceivedResponse, + callback, + override_response_headers)); + + return net::ERR_IO_PENDING; + } + + return net::OK; +} + +void AtomNetworkDelegate::OnBeforeRedirect(net::URLRequest* request, + const GURL& new_location) { + auto listener_info = event_listener_map_[kOnBeforeRedirect]; + if (!event_listener_map_.empty() && !listener_info.callback.is_null()) { + auto wrapped_callback = listener_info.callback; + auto details = ExtractRequestInfo(request); + details->SetString("redirectURL", new_location.spec()); + + BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, + base::Bind(base::IgnoreResult(wrapped_callback), + details)); + } +} + +void AtomNetworkDelegate::OnResponseStarted(net::URLRequest* request) { + auto listener_info = event_listener_map_[kOnResponseStarted]; + if (!event_listener_map_.empty() && !listener_info.callback.is_null()) { + auto wrapped_callback = listener_info.callback; + auto details = ExtractRequestInfo(request); + details->Set("responseHeaders", + GetResponseHeadersDict(request->response_headers())); + + BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, + base::Bind(base::IgnoreResult(wrapped_callback), + details)); + } +} + +void AtomNetworkDelegate::OnCompleted(net::URLRequest* request, bool started) { +} + +} // namespace atom diff --git a/atom/browser/net/atom_network_delegate.h b/atom/browser/net/atom_network_delegate.h new file mode 100644 index 000000000000..e1cfdb210035 --- /dev/null +++ b/atom/browser/net/atom_network_delegate.h @@ -0,0 +1,89 @@ +// Copyright (c) 2015 GitHub, Inc. +// Use of this source code is governed by the MIT license that can be +// found in the LICENSE file. + +#ifndef ATOM_BROWSER_NET_ATOM_NETWORK_DELEGATE_H_ +#define ATOM_BROWSER_NET_ATOM_NETWORK_DELEGATE_H_ + +#include +#include + +#include "brightray/browser/network_delegate.h" +#include "base/callback.h" +#include "base/values.h" +#include "net/http/http_request_headers.h" +#include "net/http/http_response_headers.h" + +namespace atom { + +class AtomNetworkDelegate : public brightray::NetworkDelegate { + public: + enum EventTypes { + kInvalidEvent = 0, + kOnBeforeRequest = 1 << 0, + kOnBeforeSendHeaders = 1 << 1, + kOnSendHeaders = 1 << 2, + kOnHeadersReceived = 1 << 3, + kOnBeforeRedirect = 1 << 4, + kOnResponseStarted = 1 << 5, + kOnErrorOccurred = 1 << 6, + kOnCompleted = 1 << 7, + }; + + struct BlockingResponse { + BlockingResponse() {} + ~BlockingResponse() {} + + bool cancel; + GURL redirectURL; + net::HttpRequestHeaders requestHeaders; + scoped_refptr responseHeaders; + }; + + using Listener = + base::Callback; + + AtomNetworkDelegate(); + ~AtomNetworkDelegate() override; + + void SetListenerInIO(EventTypes type, + const base::DictionaryValue* filter, + const Listener& callback); + + protected: + // net::NetworkDelegate: + int OnBeforeURLRequest(net::URLRequest* request, + const net::CompletionCallback& callback, + GURL* new_url) override; + int OnBeforeSendHeaders(net::URLRequest* request, + const net::CompletionCallback& callback, + net::HttpRequestHeaders* headers) override; + void OnSendHeaders(net::URLRequest* request, + const net::HttpRequestHeaders& headers) override; + int OnHeadersReceived( + net::URLRequest* request, + const net::CompletionCallback& callback, + const net::HttpResponseHeaders* original_response_headers, + scoped_refptr* override_response_headers, + GURL* allowed_unsafe_redirect_url) override; + void OnBeforeRedirect(net::URLRequest* request, + const GURL& new_location) override; + void OnResponseStarted(net::URLRequest* request) override; + void OnCompleted(net::URLRequest* request, bool started) override; + + private: + struct ListenerInfo { + ListenerInfo() {} + ~ListenerInfo() {} + + AtomNetworkDelegate::Listener callback; + }; + + static std::map event_listener_map_; + + DISALLOW_COPY_AND_ASSIGN(AtomNetworkDelegate); +}; + +} // namespace atom + +#endif // ATOM_BROWSER_NET_ATOM_NETWORK_DELEGATE_H_ diff --git a/atom/common/native_mate_converters/net_converter.cc b/atom/common/native_mate_converters/net_converter.cc index 4749a4fedfc2..2086e84d5891 100644 --- a/atom/common/native_mate_converters/net_converter.cc +++ b/atom/common/native_mate_converters/net_converter.cc @@ -7,8 +7,11 @@ #include #include "atom/common/node_includes.h" +#include "atom/common/native_mate_converters/gurl_converter.h" +#include "atom/common/native_mate_converters/value_converter.h" #include "native_mate/dictionary.h" #include "net/cert/x509_certificate.h" +#include "net/http/http_response_headers.h" #include "net/url_request/url_request.h" namespace mate { @@ -50,4 +53,38 @@ v8::Local Converter>::ToV8( return dict.GetHandle(); } +// static +bool Converter::FromV8( + v8::Isolate* isolate, v8::Local val, + atom::AtomNetworkDelegate::BlockingResponse* out) { + mate::Dictionary dict; + if (!ConvertFromV8(isolate, val, &dict)) + return false; + if (!dict.Get("cancel", &(out->cancel))) + return false; + dict.Get("redirectURL", &(out->redirectURL)); + base::DictionaryValue request_headers; + if (dict.Get("requestHeaders", &request_headers)) { + for (base::DictionaryValue::Iterator it(request_headers); + !it.IsAtEnd(); + it.Advance()) { + std::string value; + CHECK(it.value().GetAsString(&value)); + out->requestHeaders.SetHeader(it.key(), value); + } + } + base::DictionaryValue response_headers; + if (dict.Get("responseHeaders", &response_headers)) { + out->responseHeaders = new net::HttpResponseHeaders(""); + for (base::DictionaryValue::Iterator it(response_headers); + !it.IsAtEnd(); + it.Advance()) { + std::string value; + CHECK(it.value().GetAsString(&value)); + out->responseHeaders->AddHeader(it.key() + " : " + value); + } + } + return true; +} + } // namespace mate diff --git a/atom/common/native_mate_converters/net_converter.h b/atom/common/native_mate_converters/net_converter.h index b11c55929b98..f251da8c5c8a 100644 --- a/atom/common/native_mate_converters/net_converter.h +++ b/atom/common/native_mate_converters/net_converter.h @@ -5,6 +5,7 @@ #ifndef ATOM_COMMON_NATIVE_MATE_CONVERTERS_NET_CONVERTER_H_ #define ATOM_COMMON_NATIVE_MATE_CONVERTERS_NET_CONVERTER_H_ +#include "atom/browser/net/atom_network_delegate.h" #include "base/memory/ref_counted.h" #include "native_mate/converter.h" @@ -34,6 +35,13 @@ struct Converter> { const scoped_refptr& val); }; +template<> +struct Converter { + static bool FromV8(v8::Isolate* isolate, + v8::Local val, + atom::AtomNetworkDelegate::BlockingResponse* out); +}; + } // namespace mate #endif // ATOM_COMMON_NATIVE_MATE_CONVERTERS_NET_CONVERTER_H_ diff --git a/atom/common/native_mate_converters/value_converter.cc b/atom/common/native_mate_converters/value_converter.cc index c9c1a861ba26..431f11fbbdb3 100644 --- a/atom/common/native_mate_converters/value_converter.cc +++ b/atom/common/native_mate_converters/value_converter.cc @@ -30,6 +30,13 @@ v8::Local Converter::ToV8( return converter->ToV8Value(&val, isolate->GetCurrentContext()); } +v8::Local Converter::ToV8( + v8::Isolate* isolate, + const base::DictionaryValue* val) { + scoped_ptr converter(new atom::V8ValueConverter); + return converter->ToV8Value(val, isolate->GetCurrentContext()); +} + bool Converter::FromV8(v8::Isolate* isolate, v8::Local val, base::ListValue* out) { diff --git a/atom/common/native_mate_converters/value_converter.h b/atom/common/native_mate_converters/value_converter.h index 013dd99cc798..f660fd3f1897 100644 --- a/atom/common/native_mate_converters/value_converter.h +++ b/atom/common/native_mate_converters/value_converter.h @@ -23,6 +23,12 @@ struct Converter { const base::DictionaryValue& val); }; +template<> +struct Converter { + static v8::Local ToV8(v8::Isolate* isolate, + const base::DictionaryValue* val); +}; + template<> struct Converter { static bool FromV8(v8::Isolate* isolate, diff --git a/filenames.gypi b/filenames.gypi index aefe493335f1..640607d4017f 100644 --- a/filenames.gypi +++ b/filenames.gypi @@ -110,6 +110,8 @@ 'atom/browser/api/atom_api_tray.h', 'atom/browser/api/atom_api_web_contents.cc', 'atom/browser/api/atom_api_web_contents.h', + 'atom/browser/api/atom_api_web_request.cc', + 'atom/browser/api/atom_api_web_request.h', 'atom/browser/api/atom_api_web_view_manager.cc', 'atom/browser/api/atom_api_window.cc', 'atom/browser/api/atom_api_window.h', @@ -178,6 +180,8 @@ 'atom/browser/net/asar/url_request_asar_job.h', 'atom/browser/net/atom_cert_verifier.cc', 'atom/browser/net/atom_cert_verifier.h', + 'atom/browser/net/atom_network_delegate.cc', + 'atom/browser/net/atom_network_delegate.h', 'atom/browser/net/atom_ssl_config_service.cc', 'atom/browser/net/atom_ssl_config_service.h', 'atom/browser/net/atom_url_request_job_factory.cc',