summaryrefslogtreecommitdiffstats
path: root/chrome/service
diff options
context:
space:
mode:
authorvitalybuka@chromium.org <vitalybuka@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-03-27 17:52:05 +0000
committervitalybuka@chromium.org <vitalybuka@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-03-27 17:52:05 +0000
commitfd1f2e593f0ceae1ba269cc1a1a8cdf0d773d4fa (patch)
tree0f8ee772686ceb045a568812ba51befcc5c2a6c2 /chrome/service
parent97a806383bbc9e4386b2c4ea582a34ab86c014d6 (diff)
downloadchromium_src-fd1f2e593f0ceae1ba269cc1a1a8cdf0d773d4fa.zip
chromium_src-fd1f2e593f0ceae1ba269cc1a1a8cdf0d773d4fa.tar.gz
chromium_src-fd1f2e593f0ceae1ba269cc1a1a8cdf0d773d4fa.tar.bz2
Use service process to collect printers.
Connector could have list of print servers in "Service State" file, so it could operate on different printers list. CUPS connector uses different printer name format than printing PrintBackendCUPS. BUG=350235 NOTRY=true Review URL: https://codereview.chromium.org/208653010 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@259930 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/service')
-rw-r--r--chrome/service/cloud_print/cloud_print_proxy.cc36
-rw-r--r--chrome/service/cloud_print/cloud_print_proxy.h4
-rw-r--r--chrome/service/service_ipc_server.cc7
-rw-r--r--chrome/service/service_ipc_server.h1
4 files changed, 36 insertions, 12 deletions
diff --git a/chrome/service/cloud_print/cloud_print_proxy.cc b/chrome/service/cloud_print/cloud_print_proxy.cc
index 9e07db9..6834eb9 100644
--- a/chrome/service/cloud_print/cloud_print_proxy.cc
+++ b/chrome/service/cloud_print/cloud_print_proxy.cc
@@ -143,7 +143,8 @@ bool CloudPrintProxy::CreateBackend() {
if (backend_.get())
return false;
- settings_.InitFrom(service_prefs_);
+ ConnectorSettings settings;
+ settings.InitFrom(service_prefs_);
// By default we don't poll for jobs when we lose XMPP connection. But this
// behavior can be overridden by a preference.
@@ -156,8 +157,8 @@ bool CloudPrintProxy::CreateBackend() {
oauth_client_info.client_secret =
google_apis::GetOAuth2ClientSecret(google_apis::CLIENT_CLOUD_PRINT);
oauth_client_info.redirect_uri = "oob";
- backend_.reset(new CloudPrintProxyBackend(this, settings_, oauth_client_info,
- enable_job_poll));
+ backend_.reset(new CloudPrintProxyBackend(
+ this, settings, oauth_client_info, enable_job_poll));
return true;
}
@@ -188,12 +189,25 @@ void CloudPrintProxy::GetProxyInfo(CloudPrintProxyInfo* info) {
info->email.clear();
if (enabled_)
info->email = user_email();
- info->proxy_id = settings_.proxy_id();
- // If the Cloud Print service is not enabled, we may need to read the old
- // value of proxy_id from prefs.
- if (info->proxy_id.empty())
- info->proxy_id =
- service_prefs_->GetString(prefs::kCloudPrintProxyId, std::string());
+ ConnectorSettings settings;
+ settings.InitFrom(service_prefs_);
+ info->proxy_id = settings.proxy_id();
+}
+
+void CloudPrintProxy::GetPrinters(std::vector<std::string>* printers) {
+ ConnectorSettings settings;
+ settings.InitFrom(service_prefs_);
+ scoped_refptr<PrintSystem> print_system =
+ PrintSystem::CreateInstance(settings.print_system_settings());
+ if (!print_system)
+ return;
+ PrintSystem::PrintSystemResult result = print_system->Init();
+ if (!result.succeeded())
+ return;
+ printing::PrinterList printer_list;
+ print_system->EnumeratePrinters(&printer_list);
+ for (size_t i = 0; i < printer_list.size(); ++i)
+ printers->push_back(printer_list[i].printer_name);
}
void CloudPrintProxy::CheckCloudPrintProxyPolicy() {
@@ -253,7 +267,9 @@ void CloudPrintProxy::OnUnregisterPrinters(
UMA_HISTOGRAM_COUNTS_10000("CloudPrint.UnregisterPrinters",
printer_ids.size());
ShutdownBackend();
- wipeout_.reset(new CloudPrintWipeout(this, settings_.server_url()));
+ ConnectorSettings settings;
+ settings.InitFrom(service_prefs_);
+ wipeout_.reset(new CloudPrintWipeout(this, settings.server_url()));
wipeout_->UnregisterPrinters(auth_token, printer_ids);
}
diff --git a/chrome/service/cloud_print/cloud_print_proxy.h b/chrome/service/cloud_print/cloud_print_proxy.h
index 71c2d66..3c6ddbb 100644
--- a/chrome/service/cloud_print/cloud_print_proxy.h
+++ b/chrome/service/cloud_print/cloud_print_proxy.h
@@ -51,6 +51,8 @@ class CloudPrintProxy : public CloudPrintProxyFrontend,
void DisableForUser();
// Returns the proxy info.
void GetProxyInfo(CloudPrintProxyInfo* info);
+ // Return accessible printers.
+ void GetPrinters(std::vector<std::string>* printers);
// Launches a browser to see if the proxy policy has been set.
void CheckCloudPrintProxyPolicy();
@@ -92,8 +94,6 @@ class CloudPrintProxy : public CloudPrintProxyFrontend,
// This is set to true when the Cloud Print proxy is enabled and after
// successful authentication with the Cloud Print service.
bool enabled_;
- // Connector settings.
- ConnectorSettings settings_;
// This is a cleanup class for unregistering printers on proxy disable.
scoped_ptr<CloudPrintWipeout> wipeout_;
diff --git a/chrome/service/service_ipc_server.cc b/chrome/service/service_ipc_server.cc
index b700c57..987f806 100644
--- a/chrome/service/service_ipc_server.cc
+++ b/chrome/service/service_ipc_server.cc
@@ -100,6 +100,7 @@ bool ServiceIPCServer::OnMessageReceived(const IPC::Message& msg) {
IPC_MESSAGE_HANDLER(ServiceMsg_GetCloudPrintProxyInfo,
OnGetCloudPrintProxyInfo)
IPC_MESSAGE_HANDLER(ServiceMsg_GetHistograms, OnGetHistograms)
+ IPC_MESSAGE_HANDLER(ServiceMsg_GetPrinters, OnGetPrinters)
IPC_MESSAGE_HANDLER(ServiceMsg_Shutdown, OnShutdown);
IPC_MESSAGE_HANDLER(ServiceMsg_UpdateAvailable, OnUpdateAvailable);
IPC_MESSAGE_UNHANDLED(handled = false)
@@ -132,6 +133,12 @@ void ServiceIPCServer::OnGetHistograms() {
channel_->Send(new ServiceHostMsg_Histograms(deltas));
}
+void ServiceIPCServer::OnGetPrinters() {
+ std::vector<std::string> printers;
+ g_service_process->GetCloudPrintProxy()->GetPrinters(&printers);
+ channel_->Send(new ServiceHostMsg_Printers(printers));
+}
+
void ServiceIPCServer::OnDisableCloudPrintProxy() {
// User disabled CloudPrint proxy explicitly. Delete printers
// registered from this proxy and disable proxy.
diff --git a/chrome/service/service_ipc_server.h b/chrome/service/service_ipc_server.h
index c265a98..0708f35 100644
--- a/chrome/service/service_ipc_server.h
+++ b/chrome/service/service_ipc_server.h
@@ -60,6 +60,7 @@ class ServiceIPCServer : public IPC::Listener, public IPC::Sender {
const base::DictionaryValue& user_settings);
void OnGetCloudPrintProxyInfo();
void OnGetHistograms();
+ void OnGetPrinters();
void OnDisableCloudPrintProxy();
void OnShutdown();