OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/browser/service/service_process_control.h" | 5 #include "chrome/browser/service/service_process_control.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/file_path.h" | 8 #include "base/file_path.h" |
9 #include "base/process_util.h" | 9 #include "base/process_util.h" |
10 #include "base/stl_util-inl.h" | 10 #include "base/stl_util-inl.h" |
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
236 | 236 |
237 // We don't need the launcher anymore. | 237 // We don't need the launcher anymore. |
238 launcher_ = NULL; | 238 launcher_ = NULL; |
239 } | 239 } |
240 | 240 |
241 void ServiceProcessControl::OnMessageReceived(const IPC::Message& message) { | 241 void ServiceProcessControl::OnMessageReceived(const IPC::Message& message) { |
242 IPC_BEGIN_MESSAGE_MAP(ServiceProcessControl, message) | 242 IPC_BEGIN_MESSAGE_MAP(ServiceProcessControl, message) |
243 IPC_MESSAGE_HANDLER(ServiceHostMsg_GoodDay, OnGoodDay) | 243 IPC_MESSAGE_HANDLER(ServiceHostMsg_GoodDay, OnGoodDay) |
244 IPC_MESSAGE_HANDLER(ServiceHostMsg_CloudPrintProxy_IsEnabled, | 244 IPC_MESSAGE_HANDLER(ServiceHostMsg_CloudPrintProxy_IsEnabled, |
245 OnCloudPrintProxyIsEnabled) | 245 OnCloudPrintProxyIsEnabled) |
| 246 IPC_MESSAGE_HANDLER(ServiceHostMsg_RemotingHost_HostInfo, |
| 247 OnRemotingHostInfo) |
246 IPC_END_MESSAGE_MAP() | 248 IPC_END_MESSAGE_MAP() |
247 } | 249 } |
248 | 250 |
249 void ServiceProcessControl::OnChannelConnected(int32 peer_pid) { | 251 void ServiceProcessControl::OnChannelConnected(int32 peer_pid) { |
250 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 252 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
251 RunConnectDoneTasks(); | 253 RunConnectDoneTasks(); |
252 } | 254 } |
253 | 255 |
254 void ServiceProcessControl::OnChannelError() { | 256 void ServiceProcessControl::OnChannelError() { |
255 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 257 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
(...skipping 10 matching lines...) Expand all Loading... |
266 | 268 |
267 // NotificationObserver implementation. | 269 // NotificationObserver implementation. |
268 void ServiceProcessControl::Observe(NotificationType type, | 270 void ServiceProcessControl::Observe(NotificationType type, |
269 const NotificationSource& source, | 271 const NotificationSource& source, |
270 const NotificationDetails& details) { | 272 const NotificationDetails& details) { |
271 if (type == NotificationType::UPGRADE_RECOMMENDED) { | 273 if (type == NotificationType::UPGRADE_RECOMMENDED) { |
272 Send(new ServiceMsg_UpdateAvailable); | 274 Send(new ServiceMsg_UpdateAvailable); |
273 } | 275 } |
274 } | 276 } |
275 | 277 |
276 | |
277 void ServiceProcessControl::OnGoodDay() { | 278 void ServiceProcessControl::OnGoodDay() { |
278 if (!message_handler_) | 279 if (!message_handler_) |
279 return; | 280 return; |
280 | 281 |
281 message_handler_->OnGoodDay(); | 282 message_handler_->OnGoodDay(); |
282 } | 283 } |
283 | 284 |
284 void ServiceProcessControl::OnCloudPrintProxyIsEnabled(bool enabled, | 285 void ServiceProcessControl::OnCloudPrintProxyIsEnabled(bool enabled, |
285 std::string email) { | 286 std::string email) { |
286 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 287 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
287 if (cloud_print_status_callback_ != NULL) { | 288 if (cloud_print_status_callback_ != NULL) { |
288 cloud_print_status_callback_->Run(enabled, email); | 289 cloud_print_status_callback_->Run(enabled, email); |
289 cloud_print_status_callback_.reset(); | 290 cloud_print_status_callback_.reset(); |
290 } | 291 } |
291 } | 292 } |
292 | 293 |
| 294 void ServiceProcessControl::OnRemotingHostInfo( |
| 295 remoting::ChromotingHostInfo host_info) { |
| 296 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 297 if (remoting_host_status_callback_ != NULL) { |
| 298 remoting_host_status_callback_->Run(host_info); |
| 299 remoting_host_status_callback_.reset(); |
| 300 } |
| 301 } |
| 302 |
| 303 bool ServiceProcessControl::GetCloudPrintProxyStatus( |
| 304 Callback2<bool, std::string>::Type* cloud_print_status_callback) { |
| 305 DCHECK(cloud_print_status_callback); |
| 306 cloud_print_status_callback_.reset(cloud_print_status_callback); |
| 307 return Send(new ServiceMsg_IsCloudPrintProxyEnabled); |
| 308 } |
| 309 |
293 bool ServiceProcessControl::SendHello() { | 310 bool ServiceProcessControl::SendHello() { |
294 return Send(new ServiceMsg_Hello()); | 311 return Send(new ServiceMsg_Hello()); |
295 } | 312 } |
296 | 313 |
297 bool ServiceProcessControl::Shutdown() { | 314 bool ServiceProcessControl::Shutdown() { |
298 bool ret = Send(new ServiceMsg_Shutdown()); | 315 bool ret = Send(new ServiceMsg_Shutdown()); |
299 channel_.reset(); | 316 channel_.reset(); |
300 return ret; | 317 return ret; |
301 } | 318 } |
302 | 319 |
303 bool ServiceProcessControl::EnableRemotingWithTokens( | 320 bool ServiceProcessControl::SetRemotingHostCredentials( |
304 const std::string& user, | 321 const std::string& user, |
305 const std::string& remoting_token, | |
306 const std::string& talk_token) { | 322 const std::string& talk_token) { |
307 return Send( | 323 return Send( |
308 new ServiceMsg_EnableRemotingWithTokens(user, remoting_token, | 324 new ServiceMsg_SetRemotingHostCredentials(user, talk_token)); |
309 talk_token)); | |
310 } | 325 } |
311 | 326 |
312 bool ServiceProcessControl::GetCloudPrintProxyStatus( | 327 bool ServiceProcessControl::EnableRemotingHost() { |
313 Callback2<bool, std::string>::Type* cloud_print_status_callback) { | 328 return Send(new ServiceMsg_EnableRemotingHost()); |
314 DCHECK(cloud_print_status_callback); | 329 } |
315 cloud_print_status_callback_.reset(cloud_print_status_callback); | 330 |
316 return Send(new ServiceMsg_IsCloudPrintProxyEnabled); | 331 bool ServiceProcessControl::DisableRemotingHost() { |
| 332 return Send(new ServiceMsg_DisableRemotingHost()); |
| 333 } |
| 334 |
| 335 bool ServiceProcessControl::GetRemotingHostStatus( |
| 336 GetRemotingHostStatusCallback* status_callback) { |
| 337 DCHECK(status_callback); |
| 338 remoting_host_status_callback_.reset(status_callback); |
| 339 return Send(new ServiceMsg_GetRemotingHostInfo); |
317 } | 340 } |
318 | 341 |
319 DISABLE_RUNNABLE_METHOD_REFCOUNT(ServiceProcessControl); | 342 DISABLE_RUNNABLE_METHOD_REFCOUNT(ServiceProcessControl); |
OLD | NEW |