summaryrefslogtreecommitdiffstats
path: root/chrome/browser/service
diff options
context:
space:
mode:
authorscottbyer@chromium.org <scottbyer@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-09-27 18:38:25 +0000
committerscottbyer@chromium.org <scottbyer@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-09-27 18:38:25 +0000
commit0233759c8f0a17a73899bfed59ae21a777a3d637 (patch)
tree80d589261b7970c8980eb741fb69430a82dce892 /chrome/browser/service
parentc5a272dbd00c74dffe922523811a4ecbcd7f882b (diff)
downloadchromium_src-0233759c8f0a17a73899bfed59ae21a777a3d637.zip
chromium_src-0233759c8f0a17a73899bfed59ae21a777a3d637.tar.gz
chromium_src-0233759c8f0a17a73899bfed59ae21a777a3d637.tar.bz2
Cloud print proxy management UI.
Based in the Under-the-Hood section of options, this UI allows mere mortals to turn on and off the cloud print proxy. Currently working on Windows only, behind a flag. BUG=none TEST=Open up the options, turn CPP on and off. Review URL: http://codereview.chromium.org/3450021 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@60684 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/service')
-rw-r--r--chrome/browser/service/service_process_control.cc33
-rw-r--r--chrome/browser/service/service_process_control.h19
2 files changed, 46 insertions, 6 deletions
diff --git a/chrome/browser/service/service_process_control.cc b/chrome/browser/service/service_process_control.cc
index 05dc446..c3c16d8 100644
--- a/chrome/browser/service/service_process_control.cc
+++ b/chrome/browser/service/service_process_control.cc
@@ -171,11 +171,11 @@ void ServiceProcessControl::OnProcessLaunched(Task* task) {
}
void ServiceProcessControl::OnMessageReceived(const IPC::Message& message) {
- if (!message_handler_)
- return;
-
- if (message.type() == ServiceHostMsg_GoodDay::ID)
- message_handler_->OnGoodDay();
+ IPC_BEGIN_MESSAGE_MAP(ServiceProcessControl, message)
+ IPC_MESSAGE_HANDLER(ServiceHostMsg_GoodDay, OnGoodDay)
+ IPC_MESSAGE_HANDLER(ServiceHostMsg_CloudPrintProxy_IsEnabled,
+ OnCloudPrintProxyIsEnabled)
+ IPC_END_MESSAGE_MAP()
}
void ServiceProcessControl::OnChannelConnected(int32 peer_pid) {
@@ -202,6 +202,22 @@ bool ServiceProcessControl::Send(IPC::Message* message) {
return channel_->Send(message);
}
+void ServiceProcessControl::OnGoodDay() {
+ if (!message_handler_)
+ return;
+
+ message_handler_->OnGoodDay();
+}
+
+void ServiceProcessControl::OnCloudPrintProxyIsEnabled(bool enabled,
+ std::string email) {
+ DCHECK(ChromeThread::CurrentlyOn(ChromeThread::UI));
+ if (cloud_print_status_callback_ != NULL) {
+ cloud_print_status_callback_->Run(enabled, email);
+ cloud_print_status_callback_.reset();
+ }
+}
+
bool ServiceProcessControl::SendHello() {
return Send(new ServiceMsg_Hello());
}
@@ -221,4 +237,11 @@ bool ServiceProcessControl::EnableRemotingWithTokens(
talk_token));
}
+bool ServiceProcessControl::GetCloudPrintProxyStatus(
+ Callback2<bool, std::string>::Type* cloud_print_status_callback) {
+ DCHECK(cloud_print_status_callback);
+ cloud_print_status_callback_.reset(cloud_print_status_callback);
+ return Send(new ServiceMsg_IsCloudPrintProxyEnabled);
+}
+
DISABLE_RUNNABLE_METHOD_REFCOUNT(ServiceProcessControl);
diff --git a/chrome/browser/service/service_process_control.h b/chrome/browser/service/service_process_control.h
index 53f40de..46c2a18 100644
--- a/chrome/browser/service/service_process_control.h
+++ b/chrome/browser/service/service_process_control.h
@@ -6,8 +6,10 @@
#define CHROME_BROWSER_SERVICE_SERVICE_PROCESS_CONTROL_H_
#include <queue>
+#include <string>
#include "base/id_map.h"
+#include "base/callback.h"
#include "base/process.h"
#include "base/scoped_ptr.h"
#include "base/task.h"
@@ -69,6 +71,10 @@ class ServiceProcessControl : public IPC::Channel::Sender,
// IPC::Channel::Sender implementation
virtual bool Send(IPC::Message* message);
+ // Message handlers
+ void OnGoodDay();
+ void OnCloudPrintProxyIsEnabled(bool enabled, std::string email);
+
// Send a hello message to the service process for testing purpose.
// Return true if the message was sent.
bool SendHello();
@@ -84,6 +90,13 @@ class ServiceProcessControl : public IPC::Channel::Sender,
const std::string& remoting_token,
const std::string& talk_token);
+ // Send a message to the service process to request a response
+ // containing the enablement status of the cloud print proxy and the
+ // registered email address. The callback gets the information when
+ // received.
+ bool GetCloudPrintProxyStatus(
+ Callback2<bool, std::string>::Type* cloud_print_status_callback);
+
// Set the message handler for receiving messages from the service process.
// TODO(hclam): Allow more than 1 handler.
void SetMessageHandler(MessageHandler* message_handler) {
@@ -113,8 +126,12 @@ class ServiceProcessControl : public IPC::Channel::Sender,
// connect.
scoped_ptr<Task> connect_done_task_;
+ // Callback that gets invoked when a status message is received from
+ // the cloud print proxy.
+ scoped_ptr<Callback2<bool, std::string>::Type> cloud_print_status_callback_;
+
// Handler for messages from service process.
MessageHandler* message_handler_;
};
-#endif // CHROME_BROWSER_SERVICE_SERVICE_PROCESS_H_
+#endif // CHROME_BROWSER_SERVICE_SERVICE_PROCESS_CONTROL_H_