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

Side by Side Diff: remoting/host/host_plugin.cc

Issue 7004046: Fix use of SupportAccessVerifier in Host plugin. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 7 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 <stdio.h> 5 #include <stdio.h>
6 #include <string.h> 6 #include <string.h>
7 7
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after
304 int state_; 304 int state_;
305 std::string access_code_; 305 std::string access_code_;
306 NPObject* on_state_changed_func_; 306 NPObject* on_state_changed_func_;
307 base::AtExitManager exit_manager_; 307 base::AtExitManager exit_manager_;
308 base::PlatformThreadId np_thread_id_; 308 base::PlatformThreadId np_thread_id_;
309 309
310 scoped_refptr<remoting::RegisterSupportHostRequest> register_request_; 310 scoped_refptr<remoting::RegisterSupportHostRequest> register_request_;
311 scoped_refptr<remoting::ChromotingHost> host_; 311 scoped_refptr<remoting::ChromotingHost> host_;
312 scoped_refptr<remoting::MutableHostConfig> host_config_; 312 scoped_refptr<remoting::MutableHostConfig> host_config_;
313 remoting::ChromotingHostContext host_context_; 313 remoting::ChromotingHostContext host_context_;
314 std::string host_secret_; 314 std::string host_secret_;
Jamie 2011/05/20 20:18:02 Is this still needed now that the SupportAccessVer
Wez 2011/05/20 20:52:10 Done.
315 315
316 // Start connection. args are: 316 // Start connection. args are:
317 // string uid, string auth_token 317 // string uid, string auth_token
318 // No result. 318 // No result.
319 bool Connect(const NPVariant* args, uint32_t argCount, NPVariant* result); 319 bool Connect(const NPVariant* args, uint32_t argCount, NPVariant* result);
320 320
321 // Disconnect. No arguments or result. 321 // Disconnect. No arguments or result.
322 bool Disconnect(const NPVariant* args, uint32_t argCount, NPVariant* result); 322 bool Disconnect(const NPVariant* args, uint32_t argCount, NPVariant* result);
323 323
324 // Call OnStateChanged handler if there is one. 324 // Call OnStateChanged handler if there is one.
325 void OnStateChanged(State state); 325 void OnStateChanged(State state);
326 326
327 // Currently just mock methods to verify that everything is working 327 // Currently just mock methods to verify that everything is working
Jamie 2011/05/20 20:18:02 Presumably this comment is no longer accurate?
Wez 2011/05/20 20:52:10 Done.
328 void OnReceivedSupportID(bool success, const std::string& support_id); 328 void OnReceivedSupportID(remoting::SupportAccessVerifier* access_verifier,
329 bool success,
330 const std::string& support_id);
329 void OnConnected(); 331 void OnConnected();
330 void OnHostShutdown(); 332 void OnHostShutdown();
331 333
332 // Call a JavaScript function wrapped as an NPObject. 334 // Call a JavaScript function wrapped as an NPObject.
333 // If result is non-null, the result of the call will be stored in it. 335 // If result is non-null, the result of the call will be stored in it.
334 // Caller is responsible for releasing result if they ask for it. 336 // Caller is responsible for releasing result if they ask for it.
335 static bool CallJSFunction(NPObject* func, 337 static bool CallJSFunction(NPObject* func,
336 const NPVariant* args, 338 const NPVariant* args,
337 uint32_t argCount, 339 uint32_t argCount,
338 NPVariant* result); 340 NPVariant* result);
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
400 return false; 402 return false;
401 } 403 }
402 host_secret_ = access_verifier->host_secret(); 404 host_secret_ = access_verifier->host_secret();
403 405
404 // Generate a key pair for the Host to use. 406 // Generate a key pair for the Host to use.
405 // TODO(wez): Move this to the worker thread. 407 // TODO(wez): Move this to the worker thread.
406 remoting::HostKeyPair host_key_pair; 408 remoting::HostKeyPair host_key_pair;
407 host_key_pair.Generate(); 409 host_key_pair.Generate();
408 host_key_pair.Save(host_config); 410 host_key_pair.Save(host_config);
409 411
410 // Create the Host.
411 scoped_refptr<remoting::ChromotingHost> host =
412 remoting::ChromotingHost::Create(&host_context_, host_config,
413 access_verifier.release());
414
415 // Request registration of the host for support. 412 // Request registration of the host for support.
416 scoped_refptr<remoting::RegisterSupportHostRequest> register_request = 413 scoped_refptr<remoting::RegisterSupportHostRequest> register_request =
417 new remoting::RegisterSupportHostRequest(); 414 new remoting::RegisterSupportHostRequest();
418 if (!register_request->Init( 415 if (!register_request->Init(
419 host_config.get(), 416 host_config.get(),
420 base::Bind(&HostNPScriptObject::OnReceivedSupportID, 417 base::Bind(&HostNPScriptObject::OnReceivedSupportID,
421 base::Unretained(this)))) { 418 base::Unretained(this),
419 access_verifier.get()))) {
422 SetException("connect: RegisterSupportHostRequest::Init failed"); 420 SetException("connect: RegisterSupportHostRequest::Init failed");
423 return false; 421 return false;
424 } 422 }
423
424 // Create the Host.
425 scoped_refptr<remoting::ChromotingHost> host =
426 remoting::ChromotingHost::Create(&host_context_, host_config,
427 access_verifier.release());
425 host->AddStatusObserver(register_request); 428 host->AddStatusObserver(register_request);
426 429
430 // TODO(wez): Improve our authentication framework.
431 host->set_preauthenticated(true);
432
427 // Nothing went wrong, so lets save the host, config and request. 433 // Nothing went wrong, so lets save the host, config and request.
428 host_ = host; 434 host_ = host;
429 host_config_ = host_config; 435 host_config_ = host_config;
430 register_request_ = register_request; 436 register_request_ = register_request;
431 437
432 // Start the Host. 438 // Start the Host.
433 // TODO(wez): Attach to the Host for notifications of state changes. 439 // TODO(wez): Attach to the Host for notifications of state changes.
434 // It currently has no interface for that, though. 440 // It currently has no interface for that, though.
435 host_->Start(NewRunnableMethod(this, &HostNPScriptObject::OnHostShutdown)); 441 host_->Start(NewRunnableMethod(this, &HostNPScriptObject::OnHostShutdown));
436 442
(...skipping 15 matching lines...) Expand all
452 host_ = NULL; 458 host_ = NULL;
453 } 459 }
454 register_request_ = NULL; 460 register_request_ = NULL;
455 host_config_ = NULL; 461 host_config_ = NULL;
456 host_secret_.clear(); 462 host_secret_.clear();
457 463
458 OnStateChanged(kDisconnected); 464 OnStateChanged(kDisconnected);
459 return true; 465 return true;
460 } 466 }
461 467
462 void HostNPScriptObject::OnReceivedSupportID(bool success, 468 void HostNPScriptObject::OnReceivedSupportID(
463 const std::string& support_id) { 469 remoting::SupportAccessVerifier* access_verifier,
470 bool success,
471 const std::string& support_id) {
464 CHECK_NE(base::PlatformThread::CurrentId(), np_thread_id_); 472 CHECK_NE(base::PlatformThread::CurrentId(), np_thread_id_);
465 473
466 if (!success) { 474 if (!success) {
467 // TODO(wez): Replace the success/fail flag with full error reporting. 475 // TODO(wez): Replace the success/fail flag with full error reporting.
468 OnHostShutdown(); 476 OnHostShutdown();
469 return; 477 return;
470 } 478 }
471 479
472 // Combine the Support Id with the Host Id to make the Access Code 480 // Inform the AccessVerifier of our Support-Id, for authentication.
481 access_verifier->OnMe2MomHostRegistered(success, support_id);
482
483 // Combine the Support Id with the Host Id to make the Access Code.
473 // TODO(wez): Locking, anyone? 484 // TODO(wez): Locking, anyone?
474 access_code_ = support_id + "-" + host_secret_; 485 access_code_ = support_id + "-" + host_secret_;
475 host_secret_ = std::string(); 486 host_secret_.clear();
476 487
477 // Let the caller know that life is good. 488 // Let the caller know that life is good.
478 OnStateChanged(kReceivedAccessCode); 489 OnStateChanged(kReceivedAccessCode);
479 } 490 }
480 491
481 void HostNPScriptObject::OnConnected() { 492 void HostNPScriptObject::OnConnected() {
482 CHECK_NE(base::PlatformThread::CurrentId(), np_thread_id_); 493 CHECK_NE(base::PlatformThread::CurrentId(), np_thread_id_);
483 OnStateChanged(kConnected); 494 OnStateChanged(kConnected);
484 } 495 }
485 496
(...skipping 378 matching lines...) Expand 10 before | Expand all | Expand 10 after
864 return STRINGIZE(HOST_PLUGIN_MIME_TYPE) ":" 875 return STRINGIZE(HOST_PLUGIN_MIME_TYPE) ":"
865 HOST_PLUGIN_NAME ":" 876 HOST_PLUGIN_NAME ":"
866 HOST_PLUGIN_DESCRIPTION; 877 HOST_PLUGIN_DESCRIPTION;
867 } 878 }
868 879
869 OSCALL NPError NP_GetValue(void* npp, NPPVariable variable, void* value) { 880 OSCALL NPError NP_GetValue(void* npp, NPPVariable variable, void* value) {
870 return GetValue((NPP)npp, variable, value); 881 return GetValue((NPP)npp, variable, value);
871 } 882 }
872 883
873 } // extern "C" 884 } // extern "C"
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698