summaryrefslogtreecommitdiffstats
path: root/chrome/service
diff options
context:
space:
mode:
authorhclam@chromium.org <hclam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-08-17 00:33:46 +0000
committerhclam@chromium.org <hclam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-08-17 00:33:46 +0000
commitc41b2ecfcdc90b29ffc7b45e77a8fc68d269030c (patch)
treea9b8ea900db3a3181f403b4ad27ecfa3d9ce8b6a /chrome/service
parent9808e2f0f1e5b8b9c1798912ab1ae9a239426c92 (diff)
downloadchromium_src-c41b2ecfcdc90b29ffc7b45e77a8fc68d269030c.zip
chromium_src-c41b2ecfcdc90b29ffc7b45e77a8fc68d269030c.tar.gz
chromium_src-c41b2ecfcdc90b29ffc7b45e77a8fc68d269030c.tar.bz2
Gaia authentication for access remoting directory and talk
We are now able to access remoting directory token and talk token through the chromoting setup dialog. These information are sent to the service process for enabling the chromoting host and perform the host registration. All the plumbing for starting the service process, enabling the chromoting host through through IPC commands are in place but host registration is stubbed out and will be completed in next patch. Review URL: http://codereview.chromium.org/3176014 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@56278 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/service')
-rw-r--r--chrome/service/remoting/remoting_directory_service.cc31
-rw-r--r--chrome/service/remoting/remoting_directory_service.h58
-rw-r--r--chrome/service/service_ipc_server.cc12
-rw-r--r--chrome/service/service_ipc_server.h4
-rw-r--r--chrome/service/service_process.cc24
-rw-r--r--chrome/service/service_process.h16
6 files changed, 143 insertions, 2 deletions
diff --git a/chrome/service/remoting/remoting_directory_service.cc b/chrome/service/remoting/remoting_directory_service.cc
new file mode 100644
index 0000000..a213717
--- /dev/null
+++ b/chrome/service/remoting/remoting_directory_service.cc
@@ -0,0 +1,31 @@
+// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/service/remoting/remoting_directory_service.h"
+
+RemotingDirectoryService::RemotingDirectoryService(Client* client)
+ : client_(client) {
+}
+
+RemotingDirectoryService::~RemotingDirectoryService() {
+ // TODO(hclam): Implement.
+}
+
+void RemotingDirectoryService::AddHost(const std::string& token) {
+ // TODO(hclam): Implement.
+}
+
+void RemotingDirectoryService::CancelRequest() {
+ // TODO(hclam): Implement.
+}
+
+void RemotingDirectoryService::OnURLFetchComplete(
+ const URLFetcher* source,
+ const GURL& url,
+ const URLRequestStatus& status,
+ int response_code,
+ const ResponseCookies& cookies,
+ const std::string& data) {
+ // TODO(hclam): Implement.
+}
diff --git a/chrome/service/remoting/remoting_directory_service.h b/chrome/service/remoting/remoting_directory_service.h
new file mode 100644
index 0000000..3fcd865
--- /dev/null
+++ b/chrome/service/remoting/remoting_directory_service.h
@@ -0,0 +1,58 @@
+// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_SERVICE_REMOTING_REMOTING_DIRECTORY_SERVICE_H_
+#define CHROME_SERVICE_REMOTING_REMOTING_DIRECTORY_SERVICE_H_
+
+#include <string>
+
+#include "base/scoped_ptr.h"
+#include "chrome/common/net/url_fetcher.h"
+#include "googleurl/src/gurl.h"
+
+// A class to provide access to the remoting directory service.
+// TODO(hclam): Should implement this in Javascript.
+class RemotingDirectoryService : public URLFetcher::Delegate {
+ public:
+ // Client to receive events from the directory service.
+ class Client {
+ public:
+ virtual ~Client() {}
+
+ // Called when a remoting host was added.
+ virtual void OnRemotingHostAdded() {}
+
+ // Called when the last operation has failed.
+ virtual void OnRemotingDirectoryError() {}
+ };
+
+ RemotingDirectoryService(Client* client);
+ ~RemotingDirectoryService();
+
+ // Add this computer as host. Use the token for authentication.
+ // TODO(hclam): Need more information for this method call.
+ void AddHost(const std::string& token);
+
+ // Cancel the last requested operation.
+ void CancelRequest();
+
+ // URLFetcher::Delegate implementation.
+ virtual void OnURLFetchComplete(const URLFetcher* source,
+ const GURL& url,
+ const URLRequestStatus& status,
+ int response_code,
+ const ResponseCookies& cookies,
+ const std::string& data);
+
+ private:
+ Client* client_;
+ scoped_ptr<URLFetcher> fetcher_;
+
+ // True if a URL request has made and response is pending.
+ bool request_pending_;
+
+ DISALLOW_COPY_AND_ASSIGN(RemotingDirectoryService);
+};
+
+#endif // CHROME_SERVICE_REMOTING_REMOTING_DIRECTORY_SERVICE_H_
diff --git a/chrome/service/service_ipc_server.cc b/chrome/service/service_ipc_server.cc
index 116374f..1a698b4 100644
--- a/chrome/service/service_ipc_server.cc
+++ b/chrome/service/service_ipc_server.cc
@@ -64,6 +64,8 @@ void ServiceIPCServer::OnMessageReceived(const IPC::Message& msg) {
OnEnableCloudPrintProxy)
IPC_MESSAGE_HANDLER(ServiceMsg_EnableCloudPrintProxyWithTokens,
OnEnableCloudPrintProxyWithTokens)
+ IPC_MESSAGE_HANDLER(ServiceMsg_EnableRemotingWithTokens,
+ OnEnableRemotingWithTokens)
IPC_MESSAGE_HANDLER(ServiceMsg_DisableCloudPrintProxy,
OnDisableCloudPrintProxy)
IPC_MESSAGE_HANDLER(ServiceMsg_Hello, OnHello);
@@ -81,6 +83,16 @@ void ServiceIPCServer::OnEnableCloudPrintProxyWithTokens(
NOTIMPLEMENTED();
}
+void ServiceIPCServer::OnEnableRemotingWithTokens(
+ const std::string& login,
+ const std::string& remoting_token,
+ const std::string& talk_token) {
+#if defined(ENABLE_REMOTING)
+ g_service_process->EnableChromotingHostWithTokens(login, remoting_token,
+ talk_token);
+#endif
+}
+
void ServiceIPCServer::OnDisableCloudPrintProxy() {
g_service_process->GetCloudPrintProxy()->DisableForUser();
}
diff --git a/chrome/service/service_ipc_server.h b/chrome/service/service_ipc_server.h
index 521830e..2e8d437 100644
--- a/chrome/service/service_ipc_server.h
+++ b/chrome/service/service_ipc_server.h
@@ -40,6 +40,9 @@ 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 OnEnableRemotingWithTokens(const std::string& login,
+ const std::string& remoting_token,
+ const std::string& talk_token);
void OnDisableCloudPrintProxy();
void OnHello();
void OnShutdown();
@@ -55,4 +58,3 @@ class ServiceIPCServer : public IPC::Channel::Listener,
};
#endif // CHROME_SERVICE_SERVICE_IPC_SERVER_H_
-
diff --git a/chrome/service/service_process.cc b/chrome/service/service_process.cc
index 77e8cf0..9e5da1a 100644
--- a/chrome/service/service_process.cc
+++ b/chrome/service/service_process.cc
@@ -122,6 +122,17 @@ CloudPrintProxy* ServiceProcess::GetCloudPrintProxy() {
}
#if defined(ENABLE_REMOTING)
+bool ServiceProcess::EnableChromotingHostWithTokens(
+ const std::string& login,
+ const std::string& remoting_token,
+ const std::string& talk_token) {
+ remoting_directory_.reset(new RemotingDirectoryService(this));
+
+ // TODO(hclam): Complete the API calling to the remoting directory.
+ remoting_directory_->AddHost(remoting_token);
+ return true;
+}
+
bool ServiceProcess::StartChromotingHost() {
// We have already started.
if (chromoting_context_.get())
@@ -180,6 +191,19 @@ bool ServiceProcess::ShutdownChromotingHost() {
return true;
}
+void ServiceProcess::OnRemotingHostAdded() {
+ // TODO(hclam): Need to save the keys and configuration here.
+ // TODO(hclam): If we have a problem we need to send an IPC message back
+ // to the client that started this.
+ bool ret = StartChromotingHost();
+ DCHECK(ret);
+}
+
+void ServiceProcess::OnRemotingDirectoryError() {
+ // TODO(hclam): Implement.
+ NOTIMPLEMENTED() << "Remoting directory error";
+}
+
// A util function to update the login information to host config.
static void SaveChromotingConfigFunc(remoting::JsonHostConfig* config,
const std::string& login,
diff --git a/chrome/service/service_process.h b/chrome/service/service_process.h
index 55c7c19..2facdda 100644
--- a/chrome/service/service_process.h
+++ b/chrome/service/service_process.h
@@ -11,10 +11,12 @@
#include "base/scoped_ptr.h"
#include "base/thread.h"
#include "base/waitable_event.h"
+#include "chrome/service/remoting/remoting_directory_service.h"
class CloudPrintProxy;
class JsonPrefStore;
class ServiceIPCServer;
+
namespace net {
class NetworkChangeNotifier;
}
@@ -27,7 +29,7 @@ class JsonHostConfig;
// The ServiceProcess does not inherit from ChildProcess because this
// process can live independently of the browser process.
-class ServiceProcess {
+class ServiceProcess : public RemotingDirectoryService::Client {
public:
ServiceProcess();
~ServiceProcess();
@@ -74,6 +76,12 @@ class ServiceProcess {
// Return the reference to the chromoting host only if it has started.
remoting::ChromotingHost* GetChromotingHost() { return chromoting_host_; }
+ // Enable chromoting host with the tokens.
+ // Return true if successful.
+ bool EnableChromotingHostWithTokens(const std::string& login,
+ const std::string& remoting_token,
+ const std::string& talk_token);
+
// Start running the chromoting host asynchronously.
// Return true if chromoting host has started.
bool StartChromotingHost();
@@ -81,6 +89,10 @@ class ServiceProcess {
// Shutdown chromoting host. Return true if chromoting host was shutdown.
// The shutdown process will happen asynchronously.
bool ShutdownChromotingHost();
+
+ // RemotingDirectoryService::Client implementation.
+ virtual void OnRemotingHostAdded();
+ virtual void OnRemotingDirectoryError();
#endif
private:
@@ -115,7 +127,9 @@ class ServiceProcess {
scoped_refptr<remoting::JsonHostConfig> chromoting_config_;
scoped_ptr<remoting::ChromotingHostContext> chromoting_context_;
scoped_refptr<remoting::ChromotingHost> chromoting_host_;
+ scoped_ptr<RemotingDirectoryService> remoting_directory_;
#endif
+
// An event that will be signalled when we shutdown.
base::WaitableEvent shutdown_event_;