Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2258)

Unified Diff: remoting/host/plugin/host_script_object.cc

Issue 7547001: Propagate connected user to web app. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 9 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « remoting/host/plugin/host_script_object.h ('k') | remoting/host/register_support_host_request.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: remoting/host/plugin/host_script_object.cc
diff --git a/remoting/host/plugin/host_script_object.cc b/remoting/host/plugin/host_script_object.cc
index 5eb82de8c794d79c452123edadc08e0607ec1823..035641fe8d7885ec0e8dd9ff25a32e6b4daa261e 100644
--- a/remoting/host/plugin/host_script_object.cc
+++ b/remoting/host/plugin/host_script_object.cc
@@ -23,6 +23,7 @@ namespace remoting {
// Supported Javascript interface:
// readonly attribute string accessCode;
// readonly attribute int accessCodeLifetime;
+// readonly attribute string client;
// readonly attribute int state;
//
// state: {
@@ -46,6 +47,7 @@ namespace {
const char* kAttrNameAccessCode = "accessCode";
const char* kAttrNameAccessCodeLifetime = "accessCodeLifetime";
+const char* kAttrNameClient = "client";
const char* kAttrNameState = "state";
const char* kAttrNameLogDebugInfo = "logDebugInfo";
const char* kAttrNameOnStateChanged = "onStateChanged";
@@ -150,6 +152,7 @@ bool HostNPScriptObject::HasProperty(const std::string& property_name) {
CHECK_EQ(base::PlatformThread::CurrentId(), np_thread_id_);
return (property_name == kAttrNameAccessCode ||
property_name == kAttrNameAccessCodeLifetime ||
+ property_name == kAttrNameClient ||
property_name == kAttrNameState ||
property_name == kAttrNameLogDebugInfo ||
property_name == kAttrNameOnStateChanged ||
@@ -185,6 +188,9 @@ bool HostNPScriptObject::GetProperty(const std::string& property_name,
} else if (property_name == kAttrNameAccessCodeLifetime) {
INT32_TO_NPVARIANT(access_code_lifetime_.InSeconds(), *result);
return true;
+ } else if (property_name == kAttrNameClient) {
+ *result = NPVariantFromString(client_username_);
+ return true;
} else if (property_name == kAttrNameDisconnected) {
INT32_TO_NPVARIANT(kDisconnected, *result);
return true;
@@ -295,9 +301,21 @@ void HostNPScriptObject::OnAccessDenied() {
DisconnectInternal();
}
-void HostNPScriptObject::OnAuthenticatedClientsChanged(int clients_connected) {
+void HostNPScriptObject::OnClientAuthenticated(
+ remoting::protocol::ConnectionToClient* client) {
DCHECK_NE(base::PlatformThread::CurrentId(), np_thread_id_);
- OnStateChanged(clients_connected ? kConnected : kDisconnected);
+ client_username_ = client->session()->jid();
+ size_t pos = client_username_.find('/');
+ if (pos != std::string::npos)
+ client_username_.replace(pos, std::string::npos, "");
+ LOG(INFO) << "Client " << client_username_ << " connected.";
Wez 2011/08/02 21:38:01 nit: The client has authenticated; they were alrea
+ OnStateChanged(kConnected);
+}
+
+void HostNPScriptObject::OnClientDisconnected(
+ remoting::protocol::ConnectionToClient* client) {
+ client_username_.clear();
+ OnStateChanged(kDisconnected);
}
void HostNPScriptObject::OnShutdown() {
« no previous file with comments | « remoting/host/plugin/host_script_object.h ('k') | remoting/host/register_support_host_request.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698