summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authorsanjeevr@chromium.org <sanjeevr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-09-16 23:08:29 +0000
committersanjeevr@chromium.org <sanjeevr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-09-16 23:08:29 +0000
commit448deffd5734b932904b3691d92ebd2a03204f5f (patch)
tree8809988a0ec214b9e5afb35273399387002bcb75 /chrome
parent7fe972ec750ed840f3cbbe45c21045b0d96ca7d2 (diff)
downloadchromium_src-448deffd5734b932904b3691d92ebd2a03204f5f.zip
chromium_src-448deffd5734b932904b3691d92ebd2a03204f5f.tar.gz
chromium_src-448deffd5734b932904b3691d92ebd2a03204f5f.tar.bz2
Added a sync IPC method to check the enabled state of the cloud print proxy.
BUG=None TEST=None Review URL: http://codereview.chromium.org/3457003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@59749 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r--chrome/common/service_messages_internal.h6
-rw-r--r--chrome/service/cloud_print/cloud_print_proxy.cc17
-rw-r--r--chrome/service/cloud_print/cloud_print_proxy.h14
-rw-r--r--chrome/service/service_ipc_server.cc7
-rw-r--r--chrome/service/service_ipc_server.h2
5 files changed, 40 insertions, 6 deletions
diff --git a/chrome/common/service_messages_internal.h b/chrome/common/service_messages_internal.h
index 538cf73..26225e4 100644
--- a/chrome/common/service_messages_internal.h
+++ b/chrome/common/service_messages_internal.h
@@ -29,6 +29,12 @@ IPC_BEGIN_MESSAGES(Service)
// Tell the service process to disable the cloud proxy.
IPC_MESSAGE_CONTROL0(ServiceMsg_DisableCloudPrintProxy)
+ // Queries whether the cloud print proxy is enabled.
+ IPC_SYNC_MESSAGE_ROUTED0_2(ServiceMsg_IsCloudPrintProxyEnabled,
+ bool, /* out: is_enabled*/
+ std::string /* out: Email address of account */
+ /* used for Cloud Print, if enabled*/)
+
// This message is for testing purpose.
IPC_MESSAGE_CONTROL0(ServiceMsg_Hello)
diff --git a/chrome/service/cloud_print/cloud_print_proxy.cc b/chrome/service/cloud_print/cloud_print_proxy.cc
index daa1fb3..75e6e0a 100644
--- a/chrome/service/cloud_print/cloud_print_proxy.cc
+++ b/chrome/service/cloud_print/cloud_print_proxy.cc
@@ -66,12 +66,11 @@ void CloudPrintProxy::EnableForUser(const std::string& lsid) {
service_prefs_->prefs()->GetString(prefs::kCloudPrintXMPPAuthToken,
&cloud_print_xmpp_token);
DCHECK(!cloud_print_xmpp_token.empty());
- std::string cloud_print_email;
service_prefs_->prefs()->GetString(prefs::kCloudPrintEmail,
- &cloud_print_email);
- DCHECK(!cloud_print_email.empty());
+ &cloud_print_email_);
+ DCHECK(!cloud_print_email_.empty());
backend_->InitializeWithToken(cloud_print_token, cloud_print_xmpp_token,
- cloud_print_email, proxy_id);
+ cloud_print_email_, proxy_id);
}
if (client_) {
client_->OnCloudPrintProxyEnabled();
@@ -80,12 +79,21 @@ void CloudPrintProxy::EnableForUser(const std::string& lsid) {
void CloudPrintProxy::DisableForUser() {
DCHECK(CalledOnValidThread());
+ cloud_print_email_.clear();
Shutdown();
if (client_) {
client_->OnCloudPrintProxyDisabled();
}
}
+bool CloudPrintProxy::IsEnabled(std::string* email) const {
+ bool enabled = !cloud_print_email().empty();
+ if (enabled && email) {
+ *email = cloud_print_email();
+ }
+ return enabled;
+}
+
void CloudPrintProxy::Shutdown() {
DCHECK(CalledOnValidThread());
if (backend_.get())
@@ -107,6 +115,7 @@ void CloudPrintProxy::OnAuthenticated(
const std::string& cloud_print_xmpp_token,
const std::string& email) {
DCHECK(CalledOnValidThread());
+ cloud_print_email_ = email;
service_prefs_->prefs()->SetString(prefs::kCloudPrintAuthToken,
cloud_print_token);
service_prefs_->prefs()->SetString(prefs::kCloudPrintXMPPAuthToken,
diff --git a/chrome/service/cloud_print/cloud_print_proxy.h b/chrome/service/cloud_print/cloud_print_proxy.h
index 755337f..cccf2b4 100644
--- a/chrome/service/cloud_print/cloud_print_proxy.h
+++ b/chrome/service/cloud_print/cloud_print_proxy.h
@@ -34,8 +34,15 @@ class CloudPrintProxy : public CloudPrintProxyFrontend,
void Initialize(JsonPrefStore* service_prefs, Client* client);
// Enables/disables cloud printing for the user
- virtual void EnableForUser(const std::string& lsid);
- virtual void DisableForUser();
+ void EnableForUser(const std::string& lsid);
+ void DisableForUser();
+ // Returns the enabled stata of the proxy. If enabled, the email address used
+ // for authentication is also returned in the optional |email| argument.
+ bool IsEnabled(std::string* email) const;
+
+ const std::string& cloud_print_email() const {
+ return cloud_print_email_;
+ }
// Notification methods from the backend. Called on UI thread.
virtual void OnPrinterListAvailable(
@@ -57,6 +64,9 @@ class CloudPrintProxy : public CloudPrintProxyFrontend,
// This class does not own this. If non-NULL, It is guaranteed to remain
// valid for the lifetime of this class.
Client* client_;
+ // The email address of the account used to authenticate to the Cloud Print
+ // service.
+ std::string cloud_print_email_;
DISALLOW_COPY_AND_ASSIGN(CloudPrintProxy);
};
diff --git a/chrome/service/service_ipc_server.cc b/chrome/service/service_ipc_server.cc
index 1a698b4..c532414 100644
--- a/chrome/service/service_ipc_server.cc
+++ b/chrome/service/service_ipc_server.cc
@@ -68,6 +68,8 @@ void ServiceIPCServer::OnMessageReceived(const IPC::Message& msg) {
OnEnableRemotingWithTokens)
IPC_MESSAGE_HANDLER(ServiceMsg_DisableCloudPrintProxy,
OnDisableCloudPrintProxy)
+ IPC_MESSAGE_HANDLER(ServiceMsg_IsCloudPrintProxyEnabled,
+ OnIsCloudPrintProxyEnabled)
IPC_MESSAGE_HANDLER(ServiceMsg_Hello, OnHello);
IPC_MESSAGE_HANDLER(ServiceMsg_Shutdown, OnShutdown);
IPC_END_MESSAGE_MAP()
@@ -83,6 +85,11 @@ void ServiceIPCServer::OnEnableCloudPrintProxyWithTokens(
NOTIMPLEMENTED();
}
+void ServiceIPCServer::OnIsCloudPrintProxyEnabled(bool* is_enabled,
+ std::string* email) {
+ *is_enabled = g_service_process->GetCloudPrintProxy()->IsEnabled(email);
+}
+
void ServiceIPCServer::OnEnableRemotingWithTokens(
const std::string& login,
const std::string& remoting_token,
diff --git a/chrome/service/service_ipc_server.h b/chrome/service/service_ipc_server.h
index 2e8d437..6ead58e 100644
--- a/chrome/service/service_ipc_server.h
+++ b/chrome/service/service_ipc_server.h
@@ -40,6 +40,8 @@ class ServiceIPCServer : public IPC::Channel::Listener,
void OnEnableCloudPrintProxy(const std::string& lsid);
void OnEnableCloudPrintProxyWithTokens(const std::string& cloud_print_token,
const std::string& talk_token);
+ void OnIsCloudPrintProxyEnabled(bool* is_enabled, std::string* email);
+
void OnEnableRemotingWithTokens(const std::string& login,
const std::string& remoting_token,
const std::string& talk_token);