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

Side by Side Diff: remoting/host/plugin/host_script_object.cc

Issue 232223003: Windows chromoting host installation via the NPAPI plugin (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix unittests Created 6 years, 8 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 unified diff | Download patch
« no previous file with comments | « remoting/host/plugin/host_script_object.h ('k') | remoting/host/setup/daemon_controller.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "remoting/host/plugin/host_script_object.h" 5 #include "remoting/host/plugin/host_script_object.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/json/json_reader.h" 8 #include "base/json/json_reader.h"
9 #include "base/json/json_writer.h" 9 #include "base/json/json_writer.h"
10 #include "base/strings/string_util.h" 10 #include "base/strings/string_util.h"
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 const char* kFuncNameClearPairedClients = "clearPairedClients"; 50 const char* kFuncNameClearPairedClients = "clearPairedClients";
51 const char* kFuncNameDeletePairedClient = "deletePairedClient"; 51 const char* kFuncNameDeletePairedClient = "deletePairedClient";
52 const char* kFuncNameGetHostName = "getHostName"; 52 const char* kFuncNameGetHostName = "getHostName";
53 const char* kFuncNameGetPinHash = "getPinHash"; 53 const char* kFuncNameGetPinHash = "getPinHash";
54 const char* kFuncNameGenerateKeyPair = "generateKeyPair"; 54 const char* kFuncNameGenerateKeyPair = "generateKeyPair";
55 const char* kFuncNameUpdateDaemonConfig = "updateDaemonConfig"; 55 const char* kFuncNameUpdateDaemonConfig = "updateDaemonConfig";
56 const char* kFuncNameGetDaemonConfig = "getDaemonConfig"; 56 const char* kFuncNameGetDaemonConfig = "getDaemonConfig";
57 const char* kFuncNameGetDaemonVersion = "getDaemonVersion"; 57 const char* kFuncNameGetDaemonVersion = "getDaemonVersion";
58 const char* kFuncNameGetPairedClients = "getPairedClients"; 58 const char* kFuncNameGetPairedClients = "getPairedClients";
59 const char* kFuncNameGetUsageStatsConsent = "getUsageStatsConsent"; 59 const char* kFuncNameGetUsageStatsConsent = "getUsageStatsConsent";
60 const char* kFuncNameInstallHost = "installHost";
60 const char* kFuncNameStartDaemon = "startDaemon"; 61 const char* kFuncNameStartDaemon = "startDaemon";
61 const char* kFuncNameStopDaemon = "stopDaemon"; 62 const char* kFuncNameStopDaemon = "stopDaemon";
62 63
63 // States. 64 // States.
64 const char* kAttrNameDisconnected = "DISCONNECTED"; 65 const char* kAttrNameDisconnected = "DISCONNECTED";
65 const char* kAttrNameStarting = "STARTING"; 66 const char* kAttrNameStarting = "STARTING";
66 const char* kAttrNameRequestedAccessCode = "REQUESTED_ACCESS_CODE"; 67 const char* kAttrNameRequestedAccessCode = "REQUESTED_ACCESS_CODE";
67 const char* kAttrNameReceivedAccessCode = "RECEIVED_ACCESS_CODE"; 68 const char* kAttrNameReceivedAccessCode = "RECEIVED_ACCESS_CODE";
68 const char* kAttrNameConnected = "CONNECTED"; 69 const char* kAttrNameConnected = "CONNECTED";
69 const char* kAttrNameDisconnecting = "DISCONNECTING"; 70 const char* kAttrNameDisconnecting = "DISCONNECTING";
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 method_name == kFuncNameClearPairedClients || 147 method_name == kFuncNameClearPairedClients ||
147 method_name == kFuncNameDeletePairedClient || 148 method_name == kFuncNameDeletePairedClient ||
148 method_name == kFuncNameGetHostName || 149 method_name == kFuncNameGetHostName ||
149 method_name == kFuncNameGetPinHash || 150 method_name == kFuncNameGetPinHash ||
150 method_name == kFuncNameGenerateKeyPair || 151 method_name == kFuncNameGenerateKeyPair ||
151 method_name == kFuncNameUpdateDaemonConfig || 152 method_name == kFuncNameUpdateDaemonConfig ||
152 method_name == kFuncNameGetDaemonConfig || 153 method_name == kFuncNameGetDaemonConfig ||
153 method_name == kFuncNameGetDaemonVersion || 154 method_name == kFuncNameGetDaemonVersion ||
154 method_name == kFuncNameGetPairedClients || 155 method_name == kFuncNameGetPairedClients ||
155 method_name == kFuncNameGetUsageStatsConsent || 156 method_name == kFuncNameGetUsageStatsConsent ||
157 method_name == kFuncNameInstallHost ||
156 method_name == kFuncNameStartDaemon || 158 method_name == kFuncNameStartDaemon ||
157 method_name == kFuncNameStopDaemon); 159 method_name == kFuncNameStopDaemon);
158 } 160 }
159 161
160 bool HostNPScriptObject::InvokeDefault(const NPVariant* args, 162 bool HostNPScriptObject::InvokeDefault(const NPVariant* args,
161 uint32_t arg_count, 163 uint32_t arg_count,
162 NPVariant* result) { 164 NPVariant* result) {
163 VLOG(2) << "InvokeDefault"; 165 VLOG(2) << "InvokeDefault";
164 DCHECK(plugin_task_runner_->BelongsToCurrentThread()); 166 DCHECK(plugin_task_runner_->BelongsToCurrentThread());
165 SetException("exception during default invocation"); 167 SetException("exception during default invocation");
(...skipping 25 matching lines...) Expand all
191 } else if (method_name == kFuncNameUpdateDaemonConfig) { 193 } else if (method_name == kFuncNameUpdateDaemonConfig) {
192 return UpdateDaemonConfig(args, arg_count, result); 194 return UpdateDaemonConfig(args, arg_count, result);
193 } else if (method_name == kFuncNameGetDaemonConfig) { 195 } else if (method_name == kFuncNameGetDaemonConfig) {
194 return GetDaemonConfig(args, arg_count, result); 196 return GetDaemonConfig(args, arg_count, result);
195 } else if (method_name == kFuncNameGetDaemonVersion) { 197 } else if (method_name == kFuncNameGetDaemonVersion) {
196 return GetDaemonVersion(args, arg_count, result); 198 return GetDaemonVersion(args, arg_count, result);
197 } else if (method_name == kFuncNameGetPairedClients) { 199 } else if (method_name == kFuncNameGetPairedClients) {
198 return GetPairedClients(args, arg_count, result); 200 return GetPairedClients(args, arg_count, result);
199 } else if (method_name == kFuncNameGetUsageStatsConsent) { 201 } else if (method_name == kFuncNameGetUsageStatsConsent) {
200 return GetUsageStatsConsent(args, arg_count, result); 202 return GetUsageStatsConsent(args, arg_count, result);
203 } else if (method_name == kFuncNameInstallHost) {
204 return InstallHost(args, arg_count, result);
201 } else if (method_name == kFuncNameStartDaemon) { 205 } else if (method_name == kFuncNameStartDaemon) {
202 return StartDaemon(args, arg_count, result); 206 return StartDaemon(args, arg_count, result);
203 } else if (method_name == kFuncNameStopDaemon) { 207 } else if (method_name == kFuncNameStopDaemon) {
204 return StopDaemon(args, arg_count, result); 208 return StopDaemon(args, arg_count, result);
205 } else { 209 } else {
206 SetException("Invoke: unknown method " + method_name); 210 SetException("Invoke: unknown method " + method_name);
207 return false; 211 return false;
208 } 212 }
209 } 213 }
210 214
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after
426 kFuncNameClearPairedClients, 430 kFuncNameClearPairedClients,
427 kFuncNameDeletePairedClient, 431 kFuncNameDeletePairedClient,
428 kFuncNameGetHostName, 432 kFuncNameGetHostName,
429 kFuncNameGetPinHash, 433 kFuncNameGetPinHash,
430 kFuncNameGenerateKeyPair, 434 kFuncNameGenerateKeyPair,
431 kFuncNameUpdateDaemonConfig, 435 kFuncNameUpdateDaemonConfig,
432 kFuncNameGetDaemonConfig, 436 kFuncNameGetDaemonConfig,
433 kFuncNameGetDaemonVersion, 437 kFuncNameGetDaemonVersion,
434 kFuncNameGetPairedClients, 438 kFuncNameGetPairedClients,
435 kFuncNameGetUsageStatsConsent, 439 kFuncNameGetUsageStatsConsent,
440 kFuncNameInstallHost,
436 kFuncNameStartDaemon, 441 kFuncNameStartDaemon,
437 kFuncNameStopDaemon 442 kFuncNameStopDaemon
438 }; 443 };
439 for (size_t i = 0; i < arraysize(entries); ++i) { 444 for (size_t i = 0; i < arraysize(entries); ++i) {
440 values->push_back(entries[i]); 445 values->push_back(entries[i]);
441 } 446 }
442 return true; 447 return true;
443 } 448 }
444 449
445 // string username, string auth_token 450 // string username, string auth_token
(...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after
795 SetException("getUsageStatsConsent: invalid callback parameter"); 800 SetException("getUsageStatsConsent: invalid callback parameter");
796 return false; 801 return false;
797 } 802 }
798 803
799 daemon_controller_->GetUsageStatsConsent( 804 daemon_controller_->GetUsageStatsConsent(
800 base::Bind(&HostNPScriptObject::InvokeGetUsageStatsConsentCallback, 805 base::Bind(&HostNPScriptObject::InvokeGetUsageStatsConsentCallback,
801 weak_ptr_, base::Passed(&callback_obj))); 806 weak_ptr_, base::Passed(&callback_obj)));
802 return true; 807 return true;
803 } 808 }
804 809
810 bool HostNPScriptObject::InstallHost(const NPVariant* args,
811 uint32_t arg_count,
812 NPVariant* result) {
813 DCHECK(plugin_task_runner_->BelongsToCurrentThread());
814
815 if (arg_count != 1) {
816 SetException("installHost: bad number of arguments");
817 return false;
818 }
819
820 scoped_ptr<ScopedRefNPObject> callback_obj(
821 new ScopedRefNPObject(ObjectFromNPVariant(args[0])));
822 if (!callback_obj->get()) {
823 SetException("installHost: invalid callback parameter");
824 return false;
825 }
826
827 daemon_controller_->InstallHost(
828 base::Bind(&HostNPScriptObject::InvokeAsyncResultCallback, weak_ptr_,
829 base::Passed(&callback_obj)));
830 return true;
831 }
832
805 bool HostNPScriptObject::StartDaemon(const NPVariant* args, 833 bool HostNPScriptObject::StartDaemon(const NPVariant* args,
806 uint32_t arg_count, 834 uint32_t arg_count,
807 NPVariant* result) { 835 NPVariant* result) {
808 DCHECK(plugin_task_runner_->BelongsToCurrentThread()); 836 DCHECK(plugin_task_runner_->BelongsToCurrentThread());
809 837
810 if (arg_count != 3) { 838 if (arg_count != 3) {
811 SetException("startDaemon: bad number of arguments"); 839 SetException("startDaemon: bad number of arguments");
812 return false; 840 return false;
813 } 841 }
814 842
(...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after
1106 } 1134 }
1107 1135
1108 void HostNPScriptObject::SetException(const std::string& exception_string) { 1136 void HostNPScriptObject::SetException(const std::string& exception_string) {
1109 DCHECK(plugin_task_runner_->BelongsToCurrentThread()); 1137 DCHECK(plugin_task_runner_->BelongsToCurrentThread());
1110 1138
1111 g_npnetscape_funcs->setexception(parent_, exception_string.c_str()); 1139 g_npnetscape_funcs->setexception(parent_, exception_string.c_str());
1112 HOST_LOG << exception_string; 1140 HOST_LOG << exception_string;
1113 } 1141 }
1114 1142
1115 } // namespace remoting 1143 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/host/plugin/host_script_object.h ('k') | remoting/host/setup/daemon_controller.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698