|
13 | 13 | #include "chrome/browser/devtools/devtools_window.h"
|
14 | 14 | #include "chrome/browser/extensions/devtools_util.h"
|
15 | 15 | #include "chrome/browser/extensions/extension_service.h"
|
| 16 | +#include "chrome/browser/net/profile_network_context_service.h" |
| 17 | +#include "chrome/browser/net/profile_network_context_service_factory.h" |
16 | 18 | #include "content/nw/src/api/nw_app.h"
|
17 | 19 | #include "content/nw/src/nw_base.h"
|
18 | 20 | #include "content/public/browser/render_frame_host.h"
|
|
34 | 36 |
|
35 | 37 | using namespace extensions::nwapi::nw__app;
|
36 | 38 |
|
37 |
| -namespace { |
38 |
| -void SetProxyConfigCallback( |
39 |
| - base::WaitableEvent* done, |
40 |
| - const scoped_refptr<net::URLRequestContextGetter>& url_request_context_getter, |
41 |
| - const net::ProxyConfigWithAnnotation& proxy_config) { |
42 |
| - net::ProxyResolutionService* proxy_service = |
43 |
| - url_request_context_getter->GetURLRequestContext()->proxy_resolution_service(); |
44 |
| - proxy_service->ResetConfigService(base::WrapUnique(new net::ProxyConfigServiceFixed(proxy_config))); |
45 |
| - done->Signal(); |
46 |
| -} |
47 |
| -} // namespace |
48 |
| - |
49 | 39 | namespace extensions {
|
50 | 40 | NwAppQuitFunction::NwAppQuitFunction() {
|
51 | 41 |
|
@@ -204,19 +194,10 @@ bool NwAppSetProxyConfigFunction::RunNWSync(base::ListValue* response, std::stri
|
204 | 194 | config = net::ProxyConfigWithAnnotation(pc, TRAFFIC_ANNOTATION_FOR_TESTS);
|
205 | 195 | }
|
206 | 196 |
|
207 |
| - base::ScopedAllowBaseSyncPrimitivesOutsideBlockingScope allow_wait; |
208 |
| - |
209 |
| - content::RenderProcessHost* render_process_host = GetSenderWebContents()->GetMainFrame()->GetProcess(); |
210 |
| - net::URLRequestContextGetter* context_getter = |
211 |
| - render_process_host->GetStoragePartition()->GetURLRequestContext(); |
212 |
| - |
213 |
| - base::WaitableEvent done(base::WaitableEvent::ResetPolicy::AUTOMATIC, |
214 |
| - base::WaitableEvent::InitialState::NOT_SIGNALED); |
215 |
| - base::PostTaskWithTraits( |
216 |
| - FROM_HERE, {content::BrowserThread::IO}, |
217 |
| - base::BindOnce(&SetProxyConfigCallback, &done, |
218 |
| - base::WrapRefCounted(context_getter), config)); |
219 |
| - done.Wait(); |
| 197 | + Profile* profile = Profile::FromBrowserContext(context_); |
| 198 | + auto* profile_network_context = |
| 199 | + ProfileNetworkContextServiceFactory::GetForContext(profile); |
| 200 | + profile_network_context->UpdateProxyConfig(config); |
220 | 201 | return true;
|
221 | 202 | }
|
222 | 203 |
|
|
0 commit comments