Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(317)

Side by Side Diff: chromecast/browser/cast_browser_process.cc

Issue 2647323010: [Chromecast] Add proxy server support to chromecast (Closed)
Patch Set: Cleanup Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chromecast/browser/cast_browser_process.h" 5 #include "chromecast/browser/cast_browser_process.h"
6 6
7 #include <string>
7 #include <utility> 8 #include <utility>
8 9
10 #include "base/command_line.h"
9 #include "base/logging.h" 11 #include "base/logging.h"
10 #include "build/build_config.h" 12 #include "build/build_config.h"
11 #include "chromecast/base/metrics/cast_metrics_helper.h" 13 #include "chromecast/base/metrics/cast_metrics_helper.h"
12 #include "chromecast/browser/cast_browser_context.h" 14 #include "chromecast/browser/cast_browser_context.h"
13 #include "chromecast/browser/cast_resource_dispatcher_host_delegate.h" 15 #include "chromecast/browser/cast_resource_dispatcher_host_delegate.h"
14 #include "chromecast/browser/devtools/remote_debugging_server.h" 16 #include "chromecast/browser/devtools/remote_debugging_server.h"
15 #include "chromecast/browser/metrics/cast_metrics_service_client.h" 17 #include "chromecast/browser/metrics/cast_metrics_service_client.h"
16 #include "chromecast/net/connectivity_checker.h" 18 #include "chromecast/net/connectivity_checker.h"
17 #include "chromecast/service/cast_service.h" 19 #include "chromecast/service/cast_service.h"
18 #include "components/prefs/pref_service.h" 20 #include "components/prefs/pref_service.h"
21 #include "net/proxy/proxy_config.h"
19 22
20 #if defined(OS_ANDROID) 23 #if defined(OS_ANDROID)
21 #include "components/crash/content/browser/crash_dump_manager_android.h" 24 #include "components/crash/content/browser/crash_dump_manager_android.h"
22 #endif // defined(OS_ANDROID) 25 #endif // defined(OS_ANDROID)
23 26
24 #if defined(USE_AURA) 27 #if defined(USE_AURA)
25 #include "chromecast/graphics/cast_screen.h" 28 #include "chromecast/graphics/cast_screen.h"
26 #endif // defined(USE_AURA) 29 #endif // defined(USE_AURA)
27 30
28 namespace chromecast { 31 namespace chromecast {
29 namespace shell { 32 namespace shell {
30 33
31 namespace { 34 namespace {
32 CastBrowserProcess* g_instance = NULL; 35 CastBrowserProcess* g_instance = NULL;
33 } // namespace 36 } // namespace
34 37
35 // static 38 // static
36 CastBrowserProcess* CastBrowserProcess::GetInstance() { 39 CastBrowserProcess* CastBrowserProcess::GetInstance() {
37 DCHECK(g_instance); 40 DCHECK(g_instance);
38 return g_instance; 41 return g_instance;
39 } 42 }
40 43
41 CastBrowserProcess::CastBrowserProcess() 44 CastBrowserProcess::CastBrowserProcess()
42 : cast_content_browser_client_(nullptr), 45 : cast_content_browser_client_(nullptr),
43 net_log_(nullptr) { 46 net_log_(nullptr) {
44 DCHECK(!g_instance); 47 DCHECK(!g_instance);
48
45 g_instance = this; 49 g_instance = this;
46 } 50 }
47 51
48 CastBrowserProcess::~CastBrowserProcess() { 52 CastBrowserProcess::~CastBrowserProcess() {
49 DCHECK_EQ(g_instance, this); 53 DCHECK_EQ(g_instance, this);
50 if (pref_service_) 54 if (pref_service_)
51 pref_service_->CommitPendingWrite(); 55 pref_service_->CommitPendingWrite();
52 g_instance = NULL; 56 g_instance = NULL;
53 } 57 }
54 58
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 void CastBrowserProcess::SetMetricsServiceClient( 91 void CastBrowserProcess::SetMetricsServiceClient(
88 std::unique_ptr<metrics::CastMetricsServiceClient> metrics_service_client) { 92 std::unique_ptr<metrics::CastMetricsServiceClient> metrics_service_client) {
89 DCHECK(!metrics_service_client_); 93 DCHECK(!metrics_service_client_);
90 metrics_service_client_.swap(metrics_service_client); 94 metrics_service_client_.swap(metrics_service_client);
91 } 95 }
92 96
93 void CastBrowserProcess::SetPrefService( 97 void CastBrowserProcess::SetPrefService(
94 std::unique_ptr<PrefService> pref_service) { 98 std::unique_ptr<PrefService> pref_service) {
95 DCHECK(!pref_service_); 99 DCHECK(!pref_service_);
96 pref_service_.swap(pref_service); 100 pref_service_.swap(pref_service);
101 std::string proxy_server = pref_service_->GetString("proxy-server");
almasrymina 2017/01/25 02:52:56 the string constants are defined in chromecast/int
almasrymina 2017/01/25 02:52:56 I'm not too sure about this part. Essentially I us
wzhong 2017/01/25 03:03:45 In ChromecastSevice, you might load preference and
102
103 std::string proxy_bypass = pref_service_->GetString("proxy-bypass-list");
104
105 LOG(INFO) << "Setting proxy-server: " << proxy_server;
106 LOG(INFO) << "Setting proxy-bypass-list: " << proxy_bypass;
107
108 proxy_config_.reset(new net::ProxyConfig());
109
110 proxy_config_->proxy_rules().ParseFromString(proxy_server);
111 proxy_config_->proxy_rules().bypass_rules.ParseFromString(proxy_bypass);
97 } 112 }
98 113
99 void CastBrowserProcess::SetRemoteDebuggingServer( 114 void CastBrowserProcess::SetRemoteDebuggingServer(
100 std::unique_ptr<RemoteDebuggingServer> remote_debugging_server) { 115 std::unique_ptr<RemoteDebuggingServer> remote_debugging_server) {
101 DCHECK(!remote_debugging_server_); 116 DCHECK(!remote_debugging_server_);
102 remote_debugging_server_.swap(remote_debugging_server); 117 remote_debugging_server_.swap(remote_debugging_server);
103 } 118 }
104 119
105 void CastBrowserProcess::SetResourceDispatcherHostDelegate( 120 void CastBrowserProcess::SetResourceDispatcherHostDelegate(
106 std::unique_ptr<CastResourceDispatcherHostDelegate> delegate) { 121 std::unique_ptr<CastResourceDispatcherHostDelegate> delegate) {
107 DCHECK(!resource_dispatcher_host_delegate_); 122 DCHECK(!resource_dispatcher_host_delegate_);
108 resource_dispatcher_host_delegate_.swap(delegate); 123 resource_dispatcher_host_delegate_.swap(delegate);
109 } 124 }
110 125
111 #if defined(OS_ANDROID) 126 #if defined(OS_ANDROID)
112 void CastBrowserProcess::SetCrashDumpManager( 127 void CastBrowserProcess::SetCrashDumpManager(
113 std::unique_ptr<breakpad::CrashDumpManager> crash_dump_manager) { 128 std::unique_ptr<breakpad::CrashDumpManager> crash_dump_manager) {
114 DCHECK(!crash_dump_manager_); 129 DCHECK(!crash_dump_manager_);
115 crash_dump_manager_.swap(crash_dump_manager); 130 crash_dump_manager_.swap(crash_dump_manager);
116 } 131 }
117 #endif // defined(OS_ANDROID) 132 #endif // defined(OS_ANDROID)
118 133
119 void CastBrowserProcess::SetConnectivityChecker( 134 void CastBrowserProcess::SetConnectivityChecker(
120 scoped_refptr<ConnectivityChecker> connectivity_checker) { 135 scoped_refptr<ConnectivityChecker> connectivity_checker) {
121 DCHECK(!connectivity_checker_); 136 DCHECK(!connectivity_checker_);
122 connectivity_checker_.swap(connectivity_checker); 137 connectivity_checker_.swap(connectivity_checker);
123 } 138 }
124 139
140 net::ProxyConfig* CastBrowserProcess::proxy_config() {
141 DCHECK(proxy_config_->is_valid());
142 return proxy_config_.get();
143 }
144
125 void CastBrowserProcess::SetNetLog(net::NetLog* net_log) { 145 void CastBrowserProcess::SetNetLog(net::NetLog* net_log) {
126 DCHECK(!net_log_); 146 DCHECK(!net_log_);
127 net_log_ = net_log; 147 net_log_ = net_log;
128 } 148 }
129 149
130 } // namespace shell 150 } // namespace shell
131 } // namespace chromecast 151 } // namespace chromecast
OLDNEW
« no previous file with comments | « chromecast/browser/cast_browser_process.h ('k') | chromecast/browser/url_request_context_factory.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698