| 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/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 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 180 | 180 |
| 181 // We don't need the launcher anymore. | 181 // We don't need the launcher anymore. |
| 182 launcher_ = NULL; | 182 launcher_ = NULL; |
| 183 } | 183 } |
| 184 | 184 |
| 185 bool ServiceProcessControl::OnMessageReceived(const IPC::Message& message) { | 185 bool ServiceProcessControl::OnMessageReceived(const IPC::Message& message) { |
| 186 bool handled = true; | 186 bool handled = true; |
| 187 IPC_BEGIN_MESSAGE_MAP(ServiceProcessControl, message) | 187 IPC_BEGIN_MESSAGE_MAP(ServiceProcessControl, message) |
| 188 IPC_MESSAGE_HANDLER(ServiceHostMsg_CloudPrintProxy_IsEnabled, | 188 IPC_MESSAGE_HANDLER(ServiceHostMsg_CloudPrintProxy_IsEnabled, |
| 189 OnCloudPrintProxyIsEnabled) | 189 OnCloudPrintProxyIsEnabled) |
| 190 IPC_MESSAGE_HANDLER(ServiceHostMsg_RemotingHost_HostInfo, | |
| 191 OnRemotingHostInfo) | |
| 192 IPC_MESSAGE_UNHANDLED(handled = false) | 190 IPC_MESSAGE_UNHANDLED(handled = false) |
| 193 IPC_END_MESSAGE_MAP() | 191 IPC_END_MESSAGE_MAP() |
| 194 return handled; | 192 return handled; |
| 195 } | 193 } |
| 196 | 194 |
| 197 void ServiceProcessControl::OnChannelConnected(int32 peer_pid) { | 195 void ServiceProcessControl::OnChannelConnected(int32 peer_pid) { |
| 198 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 196 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 199 channel_->set_sync_messages_with_no_timeout_allowed(false); | 197 channel_->set_sync_messages_with_no_timeout_allowed(false); |
| 200 | 198 |
| 201 // We just established a channel with the service process. Notify it if an | 199 // We just established a channel with the service process. Notify it if an |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 234 | 232 |
| 235 void ServiceProcessControl::OnCloudPrintProxyIsEnabled(bool enabled, | 233 void ServiceProcessControl::OnCloudPrintProxyIsEnabled(bool enabled, |
| 236 std::string email) { | 234 std::string email) { |
| 237 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 235 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 238 if (cloud_print_status_callback_ != NULL) { | 236 if (cloud_print_status_callback_ != NULL) { |
| 239 cloud_print_status_callback_->Run(enabled, email); | 237 cloud_print_status_callback_->Run(enabled, email); |
| 240 cloud_print_status_callback_.reset(); | 238 cloud_print_status_callback_.reset(); |
| 241 } | 239 } |
| 242 } | 240 } |
| 243 | 241 |
| 244 void ServiceProcessControl::OnRemotingHostInfo( | |
| 245 const remoting::ChromotingHostInfo& host_info) { | |
| 246 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | |
| 247 for (std::set<MessageHandler*>::iterator it = message_handlers_.begin(); | |
| 248 it != message_handlers_.end(); ++it) { | |
| 249 (*it)->OnRemotingHostInfo(host_info); | |
| 250 } | |
| 251 } | |
| 252 | |
| 253 bool ServiceProcessControl::GetCloudPrintProxyStatus( | 242 bool ServiceProcessControl::GetCloudPrintProxyStatus( |
| 254 Callback2<bool, std::string>::Type* cloud_print_status_callback) { | 243 Callback2<bool, std::string>::Type* cloud_print_status_callback) { |
| 255 DCHECK(cloud_print_status_callback); | 244 DCHECK(cloud_print_status_callback); |
| 256 cloud_print_status_callback_.reset(cloud_print_status_callback); | 245 cloud_print_status_callback_.reset(cloud_print_status_callback); |
| 257 return Send(new ServiceMsg_IsCloudPrintProxyEnabled); | 246 return Send(new ServiceMsg_IsCloudPrintProxyEnabled); |
| 258 } | 247 } |
| 259 | 248 |
| 260 bool ServiceProcessControl::Shutdown() { | 249 bool ServiceProcessControl::Shutdown() { |
| 261 bool ret = Send(new ServiceMsg_Shutdown()); | 250 bool ret = Send(new ServiceMsg_Shutdown()); |
| 262 channel_.reset(); | 251 channel_.reset(); |
| 263 return ret; | 252 return ret; |
| 264 } | 253 } |
| 265 | 254 |
| 266 bool ServiceProcessControl::SetRemotingHostCredentials( | |
| 267 const std::string& user, | |
| 268 const std::string& talk_token) { | |
| 269 return Send( | |
| 270 new ServiceMsg_SetRemotingHostCredentials(user, talk_token)); | |
| 271 } | |
| 272 | |
| 273 bool ServiceProcessControl::EnableRemotingHost() { | |
| 274 return Send(new ServiceMsg_EnableRemotingHost()); | |
| 275 } | |
| 276 | |
| 277 bool ServiceProcessControl::DisableRemotingHost() { | |
| 278 return Send(new ServiceMsg_DisableRemotingHost()); | |
| 279 } | |
| 280 | |
| 281 bool ServiceProcessControl::RequestRemotingHostStatus() { | |
| 282 if (CheckServiceProcessReady()) { | |
| 283 remoting::ChromotingHostInfo failure_host_info; | |
| 284 failure_host_info.enabled = false; | |
| 285 | |
| 286 Launch(NewRunnableMethod(this, &ServiceProcessControl::Send, | |
| 287 new ServiceMsg_GetRemotingHostInfo), | |
| 288 NewRunnableMethod(this, | |
| 289 &ServiceProcessControl::OnRemotingHostInfo, | |
| 290 failure_host_info)); | |
| 291 return true; | |
| 292 } | |
| 293 return false; | |
| 294 } | |
| 295 | |
| 296 void ServiceProcessControl::AddMessageHandler( | |
| 297 MessageHandler* message_handler) { | |
| 298 message_handlers_.insert(message_handler); | |
| 299 } | |
| 300 | |
| 301 void ServiceProcessControl::RemoveMessageHandler( | |
| 302 MessageHandler* message_handler) { | |
| 303 message_handlers_.erase(message_handler); | |
| 304 } | |
| 305 | |
| 306 DISABLE_RUNNABLE_METHOD_REFCOUNT(ServiceProcessControl); | 255 DISABLE_RUNNABLE_METHOD_REFCOUNT(ServiceProcessControl); |
| 307 | 256 |
| 308 ServiceProcessControl::Launcher::Launcher(ServiceProcessControl* process, | 257 ServiceProcessControl::Launcher::Launcher(ServiceProcessControl* process, |
| 309 CommandLine* cmd_line) | 258 CommandLine* cmd_line) |
| 310 : process_(process), | 259 : process_(process), |
| 311 cmd_line_(cmd_line), | 260 cmd_line_(cmd_line), |
| 312 launched_(false), | 261 launched_(false), |
| 313 retry_count_(0) { | 262 retry_count_(0) { |
| 314 } | 263 } |
| 315 | 264 |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 356 if (base::LaunchApp(*cmd_line_, false, true, NULL)) { | 305 if (base::LaunchApp(*cmd_line_, false, true, NULL)) { |
| 357 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, | 306 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, |
| 358 NewRunnableMethod(this, | 307 NewRunnableMethod(this, |
| 359 &Launcher::DoDetectLaunched)); | 308 &Launcher::DoDetectLaunched)); |
| 360 } else { | 309 } else { |
| 361 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, | 310 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, |
| 362 NewRunnableMethod(this, &Launcher::Notify)); | 311 NewRunnableMethod(this, &Launcher::Notify)); |
| 363 } | 312 } |
| 364 } | 313 } |
| 365 #endif // !OS_MACOSX | 314 #endif // !OS_MACOSX |
| OLD | NEW |