| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/extensions/api/cloud_print_private/cloud_print_private_
api.h" | 5 #include "chrome/browser/extensions/api/cloud_print_private/cloud_print_private_
api.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/threading/sequenced_worker_pool.h" | 9 #include "base/threading/sequenced_worker_pool.h" |
| 10 #include "chrome/browser/printing/cloud_print/cloud_print_proxy_service.h" | 10 #include "chrome/browser/printing/cloud_print/cloud_print_proxy_service.h" |
| (...skipping 19 matching lines...) Expand all Loading... |
| 30 } | 30 } |
| 31 | 31 |
| 32 CloudPrintPrivateSetupConnectorFunction:: | 32 CloudPrintPrivateSetupConnectorFunction:: |
| 33 CloudPrintPrivateSetupConnectorFunction() { | 33 CloudPrintPrivateSetupConnectorFunction() { |
| 34 } | 34 } |
| 35 | 35 |
| 36 CloudPrintPrivateSetupConnectorFunction:: | 36 CloudPrintPrivateSetupConnectorFunction:: |
| 37 ~CloudPrintPrivateSetupConnectorFunction() { | 37 ~CloudPrintPrivateSetupConnectorFunction() { |
| 38 } | 38 } |
| 39 | 39 |
| 40 | 40 bool CloudPrintPrivateSetupConnectorFunction::RunAsync() { |
| 41 bool CloudPrintPrivateSetupConnectorFunction::RunImpl() { | |
| 42 #if defined(ENABLE_FULL_PRINTING) | 41 #if defined(ENABLE_FULL_PRINTING) |
| 43 using api::cloud_print_private::SetupConnector::Params; | 42 using api::cloud_print_private::SetupConnector::Params; |
| 44 scoped_ptr<Params> params(Params::Create(*args_)); | 43 scoped_ptr<Params> params(Params::Create(*args_)); |
| 45 if (CloudPrintTestsDelegate::instance()) { | 44 if (CloudPrintTestsDelegate::instance()) { |
| 46 CloudPrintTestsDelegate::instance()->SetupConnector( | 45 CloudPrintTestsDelegate::instance()->SetupConnector( |
| 47 params->user_email, | 46 params->user_email, |
| 48 params->robot_email, | 47 params->robot_email, |
| 49 params->credentials, | 48 params->credentials, |
| 50 params->user_settings); | 49 params->user_settings); |
| 51 } else { | 50 } else { |
| (...skipping 14 matching lines...) Expand all Loading... |
| 66 return false; | 65 return false; |
| 67 #endif | 66 #endif |
| 68 } | 67 } |
| 69 | 68 |
| 70 CloudPrintPrivateGetHostNameFunction::CloudPrintPrivateGetHostNameFunction() { | 69 CloudPrintPrivateGetHostNameFunction::CloudPrintPrivateGetHostNameFunction() { |
| 71 } | 70 } |
| 72 | 71 |
| 73 CloudPrintPrivateGetHostNameFunction::~CloudPrintPrivateGetHostNameFunction() { | 72 CloudPrintPrivateGetHostNameFunction::~CloudPrintPrivateGetHostNameFunction() { |
| 74 } | 73 } |
| 75 | 74 |
| 76 bool CloudPrintPrivateGetHostNameFunction::RunImpl() { | 75 bool CloudPrintPrivateGetHostNameFunction::RunAsync() { |
| 77 SetResult(new base::StringValue( | 76 SetResult(new base::StringValue( |
| 78 CloudPrintTestsDelegate::instance() ? | 77 CloudPrintTestsDelegate::instance() ? |
| 79 CloudPrintTestsDelegate::instance()->GetHostName() : | 78 CloudPrintTestsDelegate::instance()->GetHostName() : |
| 80 net::GetHostName())); | 79 net::GetHostName())); |
| 81 SendResponse(true); | 80 SendResponse(true); |
| 82 return true; | 81 return true; |
| 83 } | 82 } |
| 84 | 83 |
| 85 CloudPrintPrivateGetPrintersFunction::CloudPrintPrivateGetPrintersFunction() { | 84 CloudPrintPrivateGetPrintersFunction::CloudPrintPrivateGetPrintersFunction() { |
| 86 } | 85 } |
| 87 | 86 |
| 88 CloudPrintPrivateGetPrintersFunction::~CloudPrintPrivateGetPrintersFunction() { | 87 CloudPrintPrivateGetPrintersFunction::~CloudPrintPrivateGetPrintersFunction() { |
| 89 } | 88 } |
| 90 | 89 |
| 91 void CloudPrintPrivateGetPrintersFunction::SendResults( | 90 void CloudPrintPrivateGetPrintersFunction::SendResults( |
| 92 const std::vector<std::string>& printers) { | 91 const std::vector<std::string>& printers) { |
| 93 results_ = api::cloud_print_private::GetPrinters::Results::Create(printers); | 92 results_ = api::cloud_print_private::GetPrinters::Results::Create(printers); |
| 94 SendResponse(true); | 93 SendResponse(true); |
| 95 } | 94 } |
| 96 | 95 |
| 97 bool CloudPrintPrivateGetPrintersFunction::RunImpl() { | 96 bool CloudPrintPrivateGetPrintersFunction::RunAsync() { |
| 98 #if defined(ENABLE_FULL_PRINTING) | 97 #if defined(ENABLE_FULL_PRINTING) |
| 99 std::vector<std::string> result; | 98 std::vector<std::string> result; |
| 100 if (CloudPrintTestsDelegate::instance()) { | 99 if (CloudPrintTestsDelegate::instance()) { |
| 101 SendResults(CloudPrintTestsDelegate::instance()->GetPrinters()); | 100 SendResults(CloudPrintTestsDelegate::instance()->GetPrinters()); |
| 102 } else { | 101 } else { |
| 103 CloudPrintProxyService* service = | 102 CloudPrintProxyService* service = |
| 104 CloudPrintProxyServiceFactory::GetForProfile(GetProfile()); | 103 CloudPrintProxyServiceFactory::GetForProfile(GetProfile()); |
| 105 if (!service) | 104 if (!service) |
| 106 return false; | 105 return false; |
| 107 service->GetPrinters( | 106 service->GetPrinters( |
| 108 base::Bind(&CloudPrintPrivateGetPrintersFunction::SendResults, this)); | 107 base::Bind(&CloudPrintPrivateGetPrintersFunction::SendResults, this)); |
| 109 } | 108 } |
| 110 return true; | 109 return true; |
| 111 #else | 110 #else |
| 112 return false; | 111 return false; |
| 113 #endif | 112 #endif |
| 114 } | 113 } |
| 115 | 114 |
| 116 | 115 |
| 117 CloudPrintPrivateGetClientIdFunction::CloudPrintPrivateGetClientIdFunction() { | 116 CloudPrintPrivateGetClientIdFunction::CloudPrintPrivateGetClientIdFunction() { |
| 118 } | 117 } |
| 119 | 118 |
| 120 CloudPrintPrivateGetClientIdFunction::~CloudPrintPrivateGetClientIdFunction() { | 119 CloudPrintPrivateGetClientIdFunction::~CloudPrintPrivateGetClientIdFunction() { |
| 121 } | 120 } |
| 122 | 121 |
| 123 bool CloudPrintPrivateGetClientIdFunction::RunImpl() { | 122 bool CloudPrintPrivateGetClientIdFunction::RunAsync() { |
| 124 SetResult(new base::StringValue( | 123 SetResult(new base::StringValue( |
| 125 CloudPrintTestsDelegate::instance() ? | 124 CloudPrintTestsDelegate::instance() ? |
| 126 CloudPrintTestsDelegate::instance()->GetClientId() : | 125 CloudPrintTestsDelegate::instance()->GetClientId() : |
| 127 google_apis::GetOAuth2ClientID(google_apis::CLIENT_CLOUD_PRINT))); | 126 google_apis::GetOAuth2ClientID(google_apis::CLIENT_CLOUD_PRINT))); |
| 128 SendResponse(true); | 127 SendResponse(true); |
| 129 return true; | 128 return true; |
| 130 } | 129 } |
| 131 | 130 |
| 132 } // namespace extensions | 131 } // namespace extensions |
| OLD | NEW |