OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "chrome/service/service_process.h" | 5 #include "chrome/service/service_process.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
185 command_line.HasSwitch(switches::kEnableCloudPrintProxy); | 185 command_line.HasSwitch(switches::kEnableCloudPrintProxy); |
186 if (!cloud_print_proxy_enabled) { | 186 if (!cloud_print_proxy_enabled) { |
187 // Then check if the cloud print proxy was previously enabled. | 187 // Then check if the cloud print proxy was previously enabled. |
188 service_prefs_->GetBoolean(prefs::kCloudPrintProxyEnabled, | 188 service_prefs_->GetBoolean(prefs::kCloudPrintProxyEnabled, |
189 &cloud_print_proxy_enabled); | 189 &cloud_print_proxy_enabled); |
190 } | 190 } |
191 | 191 |
192 if (cloud_print_proxy_enabled) { | 192 if (cloud_print_proxy_enabled) { |
193 GetCloudPrintProxy()->EnableForUser(lsid); | 193 GetCloudPrintProxy()->EnableForUser(lsid); |
194 } | 194 } |
| 195 // Enable Virtual Printer Driver if needed. |
| 196 bool virtual_printer_driver_enabled = false; |
| 197 service_prefs_->GetBoolean(prefs::kVirtualPrinterDriverEnabled, |
| 198 &virtual_printer_driver_enabled); |
| 199 |
| 200 if (virtual_printer_driver_enabled) { |
| 201 EnableVirtualPrintDriver(); |
| 202 } |
195 | 203 |
196 VLOG(1) << "Starting Service Process IPC Server"; | 204 VLOG(1) << "Starting Service Process IPC Server"; |
197 ipc_server_.reset(new ServiceIPCServer( | 205 ipc_server_.reset(new ServiceIPCServer( |
198 service_process_state_->GetServiceProcessChannel())); | 206 service_process_state_->GetServiceProcessChannel())); |
199 ipc_server_->Init(); | 207 ipc_server_->Init(); |
200 | 208 |
201 // After the IPC server has started we signal that the service process is | 209 // After the IPC server has started we signal that the service process is |
202 // ready. | 210 // ready. |
203 if (!state->SignalReady(io_thread_->message_loop_proxy(), | 211 if (!state->SignalReady(io_thread_->message_loop_proxy(), |
204 NewRunnableMethod(this, &ServiceProcess::Shutdown))) { | 212 NewRunnableMethod(this, &ServiceProcess::Shutdown))) { |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
265 | 273 |
266 void ServiceProcess::OnCloudPrintProxyDisabled(bool persist_state) { | 274 void ServiceProcess::OnCloudPrintProxyDisabled(bool persist_state) { |
267 if (persist_state) { | 275 if (persist_state) { |
268 // Save the preference that we have disabled the cloud print proxy. | 276 // Save the preference that we have disabled the cloud print proxy. |
269 service_prefs_->SetBoolean(prefs::kCloudPrintProxyEnabled, false); | 277 service_prefs_->SetBoolean(prefs::kCloudPrintProxyEnabled, false); |
270 service_prefs_->WritePrefs(); | 278 service_prefs_->WritePrefs(); |
271 } | 279 } |
272 OnServiceDisabled(); | 280 OnServiceDisabled(); |
273 } | 281 } |
274 | 282 |
| 283 void ServiceProcess::EnableVirtualPrintDriver() { |
| 284 OnServiceEnabled(); |
| 285 // Save the preference that we have enabled the virtual driver. |
| 286 service_prefs_->SetBoolean(prefs::kVirtualPrinterDriverEnabled, true); |
| 287 service_prefs_->WritePrefs(); |
| 288 } |
| 289 |
| 290 void ServiceProcess::DisableVirtualPrintDriver() { |
| 291 OnServiceDisabled(); |
| 292 // Save the preference that we have disabled the virtual driver. |
| 293 service_prefs_->SetBoolean(prefs::kVirtualPrinterDriverEnabled, false); |
| 294 service_prefs_->WritePrefs(); |
| 295 } |
| 296 |
275 ServiceURLRequestContextGetter* | 297 ServiceURLRequestContextGetter* |
276 ServiceProcess::GetServiceURLRequestContextGetter() { | 298 ServiceProcess::GetServiceURLRequestContextGetter() { |
277 DCHECK(request_context_getter_.get()); | 299 DCHECK(request_context_getter_.get()); |
278 return request_context_getter_.get(); | 300 return request_context_getter_.get(); |
279 } | 301 } |
280 | 302 |
281 void ServiceProcess::OnServiceEnabled() { | 303 void ServiceProcess::OnServiceEnabled() { |
282 enabled_services_++; | 304 enabled_services_++; |
283 if ((1 == enabled_services_) && | 305 if ((1 == enabled_services_) && |
284 !CommandLine::ForCurrentProcess()->HasSwitch( | 306 !CommandLine::ForCurrentProcess()->HasSwitch( |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
321 } else { | 343 } else { |
322 Shutdown(); | 344 Shutdown(); |
323 } | 345 } |
324 } | 346 } |
325 } | 347 } |
326 | 348 |
327 ServiceProcess::~ServiceProcess() { | 349 ServiceProcess::~ServiceProcess() { |
328 Teardown(); | 350 Teardown(); |
329 g_service_process = NULL; | 351 g_service_process = NULL; |
330 } | 352 } |
OLD | NEW |