OLD | NEW |
1 /* | 1 /* |
2 * This file is part of Adblock Plus <https://adblockplus.org/>, | 2 * This file is part of Adblock Plus <https://adblockplus.org/>, |
3 * Copyright (C) 2006-present eyeo GmbH | 3 * Copyright (C) 2006-present eyeo GmbH |
4 * | 4 * |
5 * Adblock Plus is free software: you can redistribute it and/or modify | 5 * Adblock Plus is free software: you can redistribute it and/or modify |
6 * it under the terms of the GNU General Public License version 3 as | 6 * it under the terms of the GNU General Public License version 3 as |
7 * published by the Free Software Foundation. | 7 * published by the Free Software Foundation. |
8 * | 8 * |
9 * Adblock Plus is distributed in the hope that it will be useful, | 9 * Adblock Plus is distributed in the hope that it will be useful, |
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
72 | 72 |
73 auto headersObject = jsEngine->NewObject(); | 73 auto headersObject = jsEngine->NewObject(); |
74 for (const auto& header : response.responseHeaders) | 74 for (const auto& header : response.responseHeaders) |
75 { | 75 { |
76 headersObject.SetProperty(header.first, header.second); | 76 headersObject.SetProperty(header.first, header.second); |
77 } | 77 } |
78 resultObject.SetProperty("responseHeaders", headersObject); | 78 resultObject.SetProperty("responseHeaders", headersObject); |
79 | 79 |
80 webRequestParams[2].Call(resultObject); | 80 webRequestParams[2].Call(resultObject); |
81 }; | 81 }; |
82 | 82 jsEngine->GetPlatform().WithWebRequest( |
83 jsEngine->GetPlatform().GetWebRequest().GET(url, headers, getCallback); | 83 [url, headers, getCallback](IWebRequest& webRequest) |
| 84 { |
| 85 webRequest.GET(url, headers, getCallback); |
| 86 }); |
84 } | 87 } |
85 | 88 |
86 namespace | 89 namespace |
87 { | 90 { |
88 void GETCallback(const v8::FunctionCallbackInfo<v8::Value>& arguments) | 91 void GETCallback(const v8::FunctionCallbackInfo<v8::Value>& arguments) |
89 { | 92 { |
90 try | 93 try |
91 { | 94 { |
92 AdblockPlus::JsEngine::ScheduleWebRequest(arguments); | 95 AdblockPlus::JsEngine::ScheduleWebRequest(arguments); |
93 } catch (const std::exception& e) | 96 } catch (const std::exception& e) |
94 { | 97 { |
95 return AdblockPlus::Utils::ThrowExceptionInJS(arguments.GetIsolate(), e.wh
at()); | 98 return AdblockPlus::Utils::ThrowExceptionInJS(arguments.GetIsolate(), e.wh
at()); |
96 } | 99 } |
97 } | 100 } |
98 } | 101 } |
99 | 102 |
100 AdblockPlus::JsValue& AdblockPlus::WebRequestJsObject::Setup( | 103 AdblockPlus::JsValue& AdblockPlus::WebRequestJsObject::Setup( |
101 AdblockPlus::JsEngine& jsEngine, AdblockPlus::JsValue& obj) | 104 AdblockPlus::JsEngine& jsEngine, AdblockPlus::JsValue& obj) |
102 { | 105 { |
103 obj.SetProperty("GET", jsEngine.NewCallback(::GETCallback)); | 106 obj.SetProperty("GET", jsEngine.NewCallback(::GETCallback)); |
104 return obj; | 107 return obj; |
105 } | 108 } |
OLD | NEW |