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

Side by Side Diff: remoting/client/plugin/chromoting_instance.cc

Issue 311983003: Third Party Authentication for Android Part I - TokenFetcherProxy (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Addressing CR feedbacks Created 6 years, 6 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) 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/client/plugin/chromoting_instance.h" 5 #include "remoting/client/plugin/chromoting_instance.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 29 matching lines...) Expand all
40 #include "remoting/client/chromoting_client.h" 40 #include "remoting/client/chromoting_client.h"
41 #include "remoting/client/client_config.h" 41 #include "remoting/client/client_config.h"
42 #include "remoting/client/frame_consumer_proxy.h" 42 #include "remoting/client/frame_consumer_proxy.h"
43 #include "remoting/client/plugin/delegating_signal_strategy.h" 43 #include "remoting/client/plugin/delegating_signal_strategy.h"
44 #include "remoting/client/plugin/media_source_video_renderer.h" 44 #include "remoting/client/plugin/media_source_video_renderer.h"
45 #include "remoting/client/plugin/normalizing_input_filter_cros.h" 45 #include "remoting/client/plugin/normalizing_input_filter_cros.h"
46 #include "remoting/client/plugin/normalizing_input_filter_mac.h" 46 #include "remoting/client/plugin/normalizing_input_filter_mac.h"
47 #include "remoting/client/plugin/pepper_audio_player.h" 47 #include "remoting/client/plugin/pepper_audio_player.h"
48 #include "remoting/client/plugin/pepper_input_handler.h" 48 #include "remoting/client/plugin/pepper_input_handler.h"
49 #include "remoting/client/plugin/pepper_port_allocator.h" 49 #include "remoting/client/plugin/pepper_port_allocator.h"
50 #include "remoting/client/plugin/pepper_token_fetcher.h"
51 #include "remoting/client/plugin/pepper_view.h" 50 #include "remoting/client/plugin/pepper_view.h"
52 #include "remoting/client/software_video_renderer.h" 51 #include "remoting/client/software_video_renderer.h"
52 #include "remoting/client/token_fetcher_proxy.h"
53 #include "remoting/protocol/connection_to_host.h" 53 #include "remoting/protocol/connection_to_host.h"
54 #include "remoting/protocol/host_stub.h" 54 #include "remoting/protocol/host_stub.h"
55 #include "remoting/protocol/libjingle_transport_factory.h" 55 #include "remoting/protocol/libjingle_transport_factory.h"
56 #include "third_party/libjingle/source/talk/base/helpers.h" 56 #include "third_party/libjingle/source/talk/base/helpers.h"
57 #include "third_party/libjingle/source/talk/base/ssladapter.h" 57 #include "third_party/libjingle/source/talk/base/ssladapter.h"
58 #include "url/gurl.h" 58 #include "url/gurl.h"
59 59
60 // Windows defines 'PostMessage', so we have to undef it. 60 // Windows defines 'PostMessage', so we have to undef it.
61 #if defined(PostMessage) 61 #if defined(PostMessage)
62 #undef PostMessage 62 #undef PostMessage
(...skipping 382 matching lines...) Expand 10 before | Expand all | Expand 10 after
445 scoped_ptr<base::DictionaryValue> data(new base::DictionaryValue()); 445 scoped_ptr<base::DictionaryValue> data(new base::DictionaryValue());
446 data->SetString("state", ConnectionStateToString(state)); 446 data->SetString("state", ConnectionStateToString(state));
447 data->SetString("error", ConnectionErrorToString(error)); 447 data->SetString("error", ConnectionErrorToString(error));
448 PostLegacyJsonMessage("onConnectionStatus", data.Pass()); 448 PostLegacyJsonMessage("onConnectionStatus", data.Pass());
449 } 449 }
450 450
451 void ChromotingInstance::FetchThirdPartyToken( 451 void ChromotingInstance::FetchThirdPartyToken(
452 const GURL& token_url, 452 const GURL& token_url,
453 const std::string& host_public_key, 453 const std::string& host_public_key,
454 const std::string& scope, 454 const std::string& scope,
455 base::WeakPtr<PepperTokenFetcher> pepper_token_fetcher) { 455 base::WeakPtr<TokenFetcherProxy> token_fetcher_proxy) {
456 // Once the Session object calls this function, it won't continue the 456 // Once the Session object calls this function, it won't continue the
457 // authentication until the callback is called (or connection is canceled). 457 // authentication until the callback is called (or connection is canceled).
458 // So, it's impossible to reach this with a callback already registered. 458 // So, it's impossible to reach this with a callback already registered.
459 DCHECK(!pepper_token_fetcher_.get()); 459 DCHECK(!token_fetcher_proxy_.get());
460 pepper_token_fetcher_ = pepper_token_fetcher; 460 token_fetcher_proxy_ = token_fetcher_proxy;
461 scoped_ptr<base::DictionaryValue> data(new base::DictionaryValue()); 461 scoped_ptr<base::DictionaryValue> data(new base::DictionaryValue());
462 data->SetString("tokenUrl", token_url.spec()); 462 data->SetString("tokenUrl", token_url.spec());
463 data->SetString("hostPublicKey", host_public_key); 463 data->SetString("hostPublicKey", host_public_key);
464 data->SetString("scope", scope); 464 data->SetString("scope", scope);
465 PostLegacyJsonMessage("fetchThirdPartyToken", data.Pass()); 465 PostLegacyJsonMessage("fetchThirdPartyToken", data.Pass());
466 } 466 }
467 467
468 void ChromotingInstance::OnConnectionReady(bool ready) { 468 void ChromotingInstance::OnConnectionReady(bool ready) {
469 scoped_ptr<base::DictionaryValue> data(new base::DictionaryValue()); 469 scoped_ptr<base::DictionaryValue> data(new base::DictionaryValue());
470 data->SetBoolean("ready", ready); 470 data->SetBoolean("ready", ready);
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
530 530
531 protocol::CursorShapeStub* ChromotingInstance::GetCursorShapeStub() { 531 protocol::CursorShapeStub* ChromotingInstance::GetCursorShapeStub() {
532 // TODO(sergeyu): Move cursor shape code to a separate class. 532 // TODO(sergeyu): Move cursor shape code to a separate class.
533 // crbug.com/138108 533 // crbug.com/138108
534 return this; 534 return this;
535 } 535 }
536 536
537 scoped_ptr<protocol::ThirdPartyClientAuthenticator::TokenFetcher> 537 scoped_ptr<protocol::ThirdPartyClientAuthenticator::TokenFetcher>
538 ChromotingInstance::GetTokenFetcher(const std::string& host_public_key) { 538 ChromotingInstance::GetTokenFetcher(const std::string& host_public_key) {
539 return scoped_ptr<protocol::ThirdPartyClientAuthenticator::TokenFetcher>( 539 return scoped_ptr<protocol::ThirdPartyClientAuthenticator::TokenFetcher>(
540 new PepperTokenFetcher(weak_factory_.GetWeakPtr(), host_public_key)); 540 new TokenFetcherProxy(
541 base::Bind(&ChromotingInstance::FetchThirdPartyToken,
542 weak_factory_.GetWeakPtr()),
543 host_public_key));
541 } 544 }
542 545
543 void ChromotingInstance::InjectClipboardEvent( 546 void ChromotingInstance::InjectClipboardEvent(
544 const protocol::ClipboardEvent& event) { 547 const protocol::ClipboardEvent& event) {
545 scoped_ptr<base::DictionaryValue> data(new base::DictionaryValue()); 548 scoped_ptr<base::DictionaryValue> data(new base::DictionaryValue());
546 data->SetString("mimeType", event.mime_type()); 549 data->SetString("mimeType", event.mime_type());
547 data->SetString("item", event.data()); 550 data->SetString("item", event.data());
548 PostLegacyJsonMessage("injectClipboardItem", data.Pass()); 551 PostLegacyJsonMessage("injectClipboardItem", data.Pass());
549 } 552 }
550 553
(...skipping 382 matching lines...) Expand 10 before | Expand all | Expand 10 after
933 936
934 void ChromotingInstance::HandleOnThirdPartyTokenFetched( 937 void ChromotingInstance::HandleOnThirdPartyTokenFetched(
935 const base::DictionaryValue& data) { 938 const base::DictionaryValue& data) {
936 std::string token; 939 std::string token;
937 std::string shared_secret; 940 std::string shared_secret;
938 if (!data.GetString("token", &token) || 941 if (!data.GetString("token", &token) ||
939 !data.GetString("sharedSecret", &shared_secret)) { 942 !data.GetString("sharedSecret", &shared_secret)) {
940 LOG(ERROR) << "Invalid onThirdPartyTokenFetched data."; 943 LOG(ERROR) << "Invalid onThirdPartyTokenFetched data.";
941 return; 944 return;
942 } 945 }
943 if (pepper_token_fetcher_.get()) { 946 if (token_fetcher_proxy_.get()) {
944 pepper_token_fetcher_->OnTokenFetched(token, shared_secret); 947 token_fetcher_proxy_->OnTokenFetched(token, shared_secret);
945 pepper_token_fetcher_.reset(); 948 token_fetcher_proxy_.reset();
946 } else { 949 } else {
947 LOG(WARNING) << "Ignored OnThirdPartyTokenFetched without a pending fetch."; 950 LOG(WARNING) << "Ignored OnThirdPartyTokenFetched without a pending fetch.";
948 } 951 }
949 } 952 }
950 953
951 void ChromotingInstance::HandleRequestPairing( 954 void ChromotingInstance::HandleRequestPairing(
952 const base::DictionaryValue& data) { 955 const base::DictionaryValue& data) {
953 std::string client_name; 956 std::string client_name;
954 if (!data.GetString("clientName", &client_name)) { 957 if (!data.GetString("clientName", &client_name)) {
955 LOG(ERROR) << "Invalid requestPairing"; 958 LOG(ERROR) << "Invalid requestPairing";
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after
1198 pp::VarArrayBuffer array_buffer(buffer_size); 1201 pp::VarArrayBuffer array_buffer(buffer_size);
1199 void* data_ptr = array_buffer.Map(); 1202 void* data_ptr = array_buffer.Map();
1200 memcpy(data_ptr, buffer, buffer_size); 1203 memcpy(data_ptr, buffer, buffer_size);
1201 array_buffer.Unmap(); 1204 array_buffer.Unmap();
1202 pp::VarDictionary data_dictionary; 1205 pp::VarDictionary data_dictionary;
1203 data_dictionary.Set(pp::Var("buffer"), array_buffer); 1206 data_dictionary.Set(pp::Var("buffer"), array_buffer);
1204 PostChromotingMessage("mediaSourceData", data_dictionary); 1207 PostChromotingMessage("mediaSourceData", data_dictionary);
1205 } 1208 }
1206 1209
1207 } // namespace remoting 1210 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/client/plugin/chromoting_instance.h ('k') | remoting/client/plugin/pepper_token_fetcher.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698