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/service/cloud_print/cloud_print_proxy_backend.h" | 5 #include "chrome/service/cloud_print/cloud_print_proxy_backend.h" |
6 | 6 |
7 #include <map> | 7 #include <map> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
270 void CloudPrintProxyBackend::Core::DoInitializeWithLsid( | 270 void CloudPrintProxyBackend::Core::DoInitializeWithLsid( |
271 const std::string& lsid, const std::string& proxy_id) { | 271 const std::string& lsid, const std::string& proxy_id) { |
272 DCHECK(MessageLoop::current() == backend_->core_thread_.message_loop()); | 272 DCHECK(MessageLoop::current() == backend_->core_thread_.message_loop()); |
273 // Since Talk does not accept a Cloud Print token, for now, we make 2 auth | 273 // Since Talk does not accept a Cloud Print token, for now, we make 2 auth |
274 // requests, one for the chromiumsync service and another for print. This is | 274 // requests, one for the chromiumsync service and another for print. This is |
275 // temporary and should be removed once Talk supports our token. | 275 // temporary and should be removed once Talk supports our token. |
276 // Note: The GAIA login is synchronous but that should be OK because we are in | 276 // Note: The GAIA login is synchronous but that should be OK because we are in |
277 // the CloudPrintProxyCoreThread and we cannot really do anything else until | 277 // the CloudPrintProxyCoreThread and we cannot really do anything else until |
278 // the GAIA signin is successful. | 278 // the GAIA signin is successful. |
279 std::string user_agent = "ChromiumBrowser"; | 279 std::string user_agent = "ChromiumBrowser"; |
280 scoped_refptr<ServiceGaiaAuthenticator> gaia_auth_for_talk = | 280 scoped_refptr<ServiceGaiaAuthenticator> gaia_auth_for_talk( |
281 new ServiceGaiaAuthenticator( | 281 new ServiceGaiaAuthenticator( |
282 user_agent, kSyncGaiaServiceId, kGaiaUrl, | 282 user_agent, kSyncGaiaServiceId, kGaiaUrl, |
283 g_service_process->io_thread()->message_loop_proxy()); | 283 g_service_process->io_thread()->message_loop_proxy())); |
284 gaia_auth_for_talk->set_message_loop(MessageLoop::current()); | 284 gaia_auth_for_talk->set_message_loop(MessageLoop::current()); |
285 bool auth_succeeded = false; | 285 bool auth_succeeded = false; |
286 if (gaia_auth_for_talk->AuthenticateWithLsid(lsid)) { | 286 if (gaia_auth_for_talk->AuthenticateWithLsid(lsid)) { |
287 scoped_refptr<ServiceGaiaAuthenticator> gaia_auth_for_print = | 287 scoped_refptr<ServiceGaiaAuthenticator> gaia_auth_for_print( |
288 new ServiceGaiaAuthenticator( | 288 new ServiceGaiaAuthenticator( |
289 user_agent, kCloudPrintGaiaServiceId, kGaiaUrl, | 289 user_agent, kCloudPrintGaiaServiceId, kGaiaUrl, |
290 g_service_process->io_thread()->message_loop_proxy()); | 290 g_service_process->io_thread()->message_loop_proxy())); |
291 gaia_auth_for_print->set_message_loop(MessageLoop::current()); | 291 gaia_auth_for_print->set_message_loop(MessageLoop::current()); |
292 if (gaia_auth_for_print->AuthenticateWithLsid(lsid)) { | 292 if (gaia_auth_for_print->AuthenticateWithLsid(lsid)) { |
293 auth_succeeded = true; | 293 auth_succeeded = true; |
294 // Let the frontend know that we have authenticated. | 294 // Let the frontend know that we have authenticated. |
295 backend_->frontend_loop_->PostTask(FROM_HERE, NewRunnableMethod(this, | 295 backend_->frontend_loop_->PostTask(FROM_HERE, NewRunnableMethod(this, |
296 &Core::NotifyAuthenticated, gaia_auth_for_print->auth_token(), | 296 &Core::NotifyAuthenticated, gaia_auth_for_print->auth_token(), |
297 gaia_auth_for_talk->auth_token(), gaia_auth_for_talk->email())); | 297 gaia_auth_for_talk->auth_token(), gaia_auth_for_talk->email())); |
298 backend_->frontend_loop_->PostTask(FROM_HERE, NewRunnableMethod(this, | 298 backend_->frontend_loop_->PostTask(FROM_HERE, NewRunnableMethod(this, |
299 &Core::NotifyAuthenticated, gaia_auth_for_print->auth_token(), | 299 &Core::NotifyAuthenticated, gaia_auth_for_print->auth_token(), |
300 gaia_auth_for_talk->auth_token(), gaia_auth_for_talk->email())); | 300 gaia_auth_for_talk->auth_token(), gaia_auth_for_talk->email())); |
(...skipping 459 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
760 VLOG(1) << "CP_PROXY: Printer job handle shutdown, id " << printer_id; | 760 VLOG(1) << "CP_PROXY: Printer job handle shutdown, id " << printer_id; |
761 job_handler_map_.erase(printer_id); | 761 job_handler_map_.erase(printer_id); |
762 } | 762 } |
763 | 763 |
764 void CloudPrintProxyBackend::Core::OnAuthError() { | 764 void CloudPrintProxyBackend::Core::OnAuthError() { |
765 DCHECK(MessageLoop::current() == backend_->core_thread_.message_loop()); | 765 DCHECK(MessageLoop::current() == backend_->core_thread_.message_loop()); |
766 VLOG(1) << "CP_PROXY: Auth Error"; | 766 VLOG(1) << "CP_PROXY: Auth Error"; |
767 backend_->frontend_loop_->PostTask(FROM_HERE, NewRunnableMethod(this, | 767 backend_->frontend_loop_->PostTask(FROM_HERE, NewRunnableMethod(this, |
768 &Core::NotifyAuthenticationFailed)); | 768 &Core::NotifyAuthenticationFailed)); |
769 } | 769 } |
OLD | NEW |