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

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

Issue 7008003: Wire in OAuth2 support into non-sandboxed connections in libjingle. (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
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
11 #include "base/at_exit.h" 11 #include "base/at_exit.h"
12 #include "base/base_paths.h" 12 #include "base/base_paths.h"
13 #include "base/basictypes.h" 13 #include "base/basictypes.h"
14 #include "base/bind.h" 14 #include "base/bind.h"
15 #include "base/file_path.h" 15 #include "base/file_path.h"
16 #include "base/logging.h" 16 #include "base/logging.h"
17 #include "base/message_loop.h" 17 #include "base/message_loop.h"
18 #include "base/path_service.h" 18 #include "base/path_service.h"
19 #include "base/rand_util.h" 19 #include "base/rand_util.h"
20 #include "base/stringize_macros.h" 20 #include "base/stringize_macros.h"
21 #include "base/task.h" 21 #include "base/task.h"
22 #include "base/threading/platform_thread.h" 22 #include "base/threading/platform_thread.h"
23 #include "base/threading/thread.h" 23 #include "base/threading/thread.h"
24 #if defined(OS_MACOSX) 24 #if defined(OS_MACOSX)
25 #include "base/mac/foundation_util.h" 25 #include "base/mac/foundation_util.h"
26 #endif 26 #endif
27 #include "media/base/media.h" 27 #include "media/base/media.h"
28 #include "remoting/base/auth_token_util.h"
28 #include "remoting/host/chromoting_host.h" 29 #include "remoting/host/chromoting_host.h"
29 #include "remoting/host/chromoting_host_context.h" 30 #include "remoting/host/chromoting_host_context.h"
30 #include "remoting/host/host_config.h" 31 #include "remoting/host/host_config.h"
31 #include "remoting/host/host_key_pair.h" 32 #include "remoting/host/host_key_pair.h"
32 #include "remoting/host/in_memory_host_config.h" 33 #include "remoting/host/in_memory_host_config.h"
33 #include "remoting/host/register_support_host_request.h" 34 #include "remoting/host/register_support_host_request.h"
34 #include "remoting/host/support_access_verifier.h" 35 #include "remoting/host/support_access_verifier.h"
35 #include "third_party/npapi/bindings/npapi.h" 36 #include "third_party/npapi/bindings/npapi.h"
36 #include "third_party/npapi/bindings/npfunctions.h" 37 #include "third_party/npapi/bindings/npfunctions.h"
37 #include "third_party/npapi/bindings/npruntime.h" 38 #include "third_party/npapi/bindings/npruntime.h"
(...skipping 13 matching lines...) Expand all
51 DISCONNECTED, 52 DISCONNECTED,
52 REQUESTED_ACCESS_CODE, 53 REQUESTED_ACCESS_CODE,
53 RECEIVED_ACCESS_CODE, 54 RECEIVED_ACCESS_CODE,
54 CONNECTED, 55 CONNECTED,
55 AFFIRMING_CONNECTION, 56 AFFIRMING_CONNECTION,
56 ERROR, 57 ERROR,
57 } 58 }
58 59
59 attribute Function void onStateChanged(); 60 attribute Function void onStateChanged();
60 61
61 void connect(string uid, string auth_token); 62 // Auth token should be in the format "service:token". And example
Wez 2011/05/25 03:57:46 Typo: And
awong 2011/05/25 16:56:56 Done.
Jamie 2011/05/25 17:04:52 Should we name the parameter explicitly in the com
awong 2011/05/25 18:00:02 Done.
63 // would be "oauth2:1/2a3912vd".
64 void connect(string uid, string auth_token_with_service);
Wez 2011/05/25 03:57:46 If these were called |auth_service_and_token| the
awong 2011/05/25 16:56:56 Done.
62 void disconnect(); 65 void disconnect();
63 */ 66 */
64 67
65 namespace { 68 namespace {
66 69
67 // Global netscape functions initialized in NP_Initialize. 70 // Global netscape functions initialized in NP_Initialize.
68 NPNetscapeFuncs* g_npnetscape_funcs = NULL; 71 NPNetscapeFuncs* g_npnetscape_funcs = NULL;
69 72
70 // The name and description are returned by GetValue, but are also 73 // The name and description are returned by GetValue, but are also
71 // combined with the MIME type to satisfy GetMIMEDescription, so we 74 // combined with the MIME type to satisfy GetMIMEDescription, so we
(...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after
381 SetException("connect: bad number of arguments"); 384 SetException("connect: bad number of arguments");
382 return false; 385 return false;
383 } 386 }
384 387
385 std::string uid = StringFromNPVariant(args[0]); 388 std::string uid = StringFromNPVariant(args[0]);
386 if (uid.empty()) { 389 if (uid.empty()) {
387 SetException("connect: bad uid argument"); 390 SetException("connect: bad uid argument");
388 return false; 391 return false;
389 } 392 }
390 393
391 std::string auth_token = StringFromNPVariant(args[1]); 394 std::string auth_token_with_service = StringFromNPVariant(args[1]);
395 if (auth_token_with_service.empty()) {
Wez 2011/05/25 03:57:46 Why do this test here; the empty token case post-p
awong 2011/05/25 16:56:56 cause I'm silly? :) Fixed.
396 SetException("connect: bad auth_token_with_service argument");
397 return false;
398 }
399 std::string auth_token;
400 std::string auth_service;
401 remoting::ParseAuthTokenWithService(auth_token_with_service, &auth_token,
402 &auth_service);
392 if (auth_token.empty()) { 403 if (auth_token.empty()) {
Jamie 2011/05/25 17:04:52 Do we need a check for an empty service? The strin
awong 2011/05/25 18:00:02 I'm intentionally not doing that for now so I don'
393 SetException("connect: bad auth_token argument"); 404 SetException("connect: auth_token_with_service argument has empty token");
394 return false; 405 return false;
395 } 406 }
396 407
397 // TODO(wez): Load the media libraries to get the VP8 encoder. 408 // TODO(wez): Load the media libraries to get the VP8 encoder.
398 // This won't be needed once we link libvpx in statically. 409 // This won't be needed once we link libvpx in statically.
399 FilePath media_path; 410 FilePath media_path;
400 #if defined(OS_MACOSX) 411 #if defined(OS_MACOSX)
401 // MainAppBundlePath returns the Chromium Helper bundle, which in dev builds 412 // MainAppBundlePath returns the Chromium Helper bundle, which in dev builds
402 // sits alongside the Framework bundle, which contains the Libraries we need. 413 // sits alongside the Framework bundle, which contains the Libraries we need.
403 media_path = base::mac::MainAppBundlePath(); 414 media_path = base::mac::MainAppBundlePath();
(...skipping 11 matching lines...) Expand all
415 if (!media::InitializeMediaLibrary(media_path)) { 426 if (!media::InitializeMediaLibrary(media_path)) {
416 SetException("Failed to load media library"); 427 SetException("Failed to load media library");
417 return false; 428 return false;
418 } 429 }
419 430
420 // Store the supplied user ID and token to the Host configuration. 431 // Store the supplied user ID and token to the Host configuration.
421 scoped_refptr<remoting::MutableHostConfig> host_config = 432 scoped_refptr<remoting::MutableHostConfig> host_config =
422 new remoting::InMemoryHostConfig; 433 new remoting::InMemoryHostConfig;
423 host_config->SetString(remoting::kXmppLoginConfigPath, uid); 434 host_config->SetString(remoting::kXmppLoginConfigPath, uid);
424 host_config->SetString(remoting::kXmppAuthTokenConfigPath, auth_token); 435 host_config->SetString(remoting::kXmppAuthTokenConfigPath, auth_token);
436 host_config->SetString(remoting::kXmppAuthServiceConfigPath, auth_service);
425 437
426 // Create an access verifier and fetch the host secret. 438 // Create an access verifier and fetch the host secret.
427 scoped_ptr<remoting::SupportAccessVerifier> access_verifier; 439 scoped_ptr<remoting::SupportAccessVerifier> access_verifier;
428 access_verifier.reset(new remoting::SupportAccessVerifier); 440 access_verifier.reset(new remoting::SupportAccessVerifier);
429 if (!access_verifier->Init()) { 441 if (!access_verifier->Init()) {
430 SetException("connect: SupportAccessVerifier::Init failed"); 442 SetException("connect: SupportAccessVerifier::Init failed");
431 return false; 443 return false;
432 } 444 }
433 445
434 // Generate a key pair for the Host to use. 446 // Generate a key pair for the Host to use.
(...skipping 466 matching lines...) Expand 10 before | Expand all | Expand 10 after
901 return STRINGIZE(HOST_PLUGIN_MIME_TYPE) ":" 913 return STRINGIZE(HOST_PLUGIN_MIME_TYPE) ":"
902 HOST_PLUGIN_NAME ":" 914 HOST_PLUGIN_NAME ":"
903 HOST_PLUGIN_DESCRIPTION; 915 HOST_PLUGIN_DESCRIPTION;
904 } 916 }
905 917
906 OSCALL NPError NP_GetValue(void* npp, NPPVariable variable, void* value) { 918 OSCALL NPError NP_GetValue(void* npp, NPPVariable variable, void* value) {
907 return GetValue((NPP)npp, variable, value); 919 return GetValue((NPP)npp, variable, value);
908 } 920 }
909 921
910 } // extern "C" 922 } // extern "C"
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698