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

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

Issue 12316083: Move HostKeyPair into protocol::KeyPair. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Add missing files, move TestKeyPair. Created 7 years, 10 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
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/message_loop.h" 10 #include "base/message_loop.h"
11 #include "base/message_loop_proxy.h" 11 #include "base/message_loop_proxy.h"
12 #include "base/string_util.h" 12 #include "base/string_util.h"
13 #include "base/stringprintf.h" 13 #include "base/stringprintf.h"
14 #include "base/sys_string_conversions.h" 14 #include "base/sys_string_conversions.h"
15 #include "base/threading/platform_thread.h" 15 #include "base/threading/platform_thread.h"
16 #include "base/utf_string_conversions.h" 16 #include "base/utf_string_conversions.h"
17 #include "base/values.h" 17 #include "base/values.h"
18 #include "net/base/net_util.h" 18 #include "net/base/net_util.h"
19 #include "remoting/base/auth_token_util.h" 19 #include "remoting/base/auth_token_util.h"
20 #include "remoting/base/auto_thread.h" 20 #include "remoting/base/auto_thread.h"
21 #include "remoting/host/basic_desktop_environment.h" 21 #include "remoting/host/basic_desktop_environment.h"
22 #include "remoting/host/chromoting_host.h" 22 #include "remoting/host/chromoting_host.h"
23 #include "remoting/host/chromoting_host_context.h" 23 #include "remoting/host/chromoting_host_context.h"
24 #include "remoting/host/host_config.h" 24 #include "remoting/host/host_config.h"
25 #include "remoting/host/host_event_logger.h" 25 #include "remoting/host/host_event_logger.h"
26 #include "remoting/host/host_key_pair.h"
27 #include "remoting/host/host_secret.h" 26 #include "remoting/host/host_secret.h"
28 #include "remoting/host/host_status_observer.h" 27 #include "remoting/host/host_status_observer.h"
29 #include "remoting/host/it2me_host_user_interface.h" 28 #include "remoting/host/it2me_host_user_interface.h"
30 #include "remoting/host/network_settings.h" 29 #include "remoting/host/network_settings.h"
31 #include "remoting/host/pin_hash.h" 30 #include "remoting/host/pin_hash.h"
32 #include "remoting/host/plugin/host_log_handler.h" 31 #include "remoting/host/plugin/host_log_handler.h"
33 #include "remoting/host/policy_hack/policy_watcher.h" 32 #include "remoting/host/policy_hack/policy_watcher.h"
34 #include "remoting/host/register_support_host_request.h" 33 #include "remoting/host/register_support_host_request.h"
35 #include "remoting/host/service_urls.h" 34 #include "remoting/host/service_urls.h"
36 #include "remoting/host/session_manager_factory.h" 35 #include "remoting/host/session_manager_factory.h"
37 #include "remoting/jingle_glue/xmpp_signal_strategy.h" 36 #include "remoting/jingle_glue/xmpp_signal_strategy.h"
38 #include "remoting/protocol/it2me_host_authenticator_factory.h" 37 #include "remoting/protocol/it2me_host_authenticator_factory.h"
38 #include "remoting/protocol/key_pair.h"
39 #include "third_party/npapi/bindings/npruntime.h" 39 #include "third_party/npapi/bindings/npruntime.h"
40 40
41 namespace remoting { 41 namespace remoting {
42 42
43 namespace { 43 namespace {
44 44
45 // This is used for tagging system event logs. 45 // This is used for tagging system event logs.
46 const char kApplicationName[] = "chromoting"; 46 const char kApplicationName[] = "chromoting";
47 47
48 const char* kAttrNameAccessCode = "accessCode"; 48 const char* kAttrNameAccessCode = "accessCode";
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 155
156 // Caller supplied fields. 156 // Caller supplied fields.
157 scoped_ptr<ChromotingHostContext> host_context_; 157 scoped_ptr<ChromotingHostContext> host_context_;
158 scoped_refptr<base::SingleThreadTaskRunner> plugin_task_runner_; 158 scoped_refptr<base::SingleThreadTaskRunner> plugin_task_runner_;
159 base::WeakPtr<HostNPScriptObject> script_object_; 159 base::WeakPtr<HostNPScriptObject> script_object_;
160 XmppSignalStrategy::XmppServerConfig xmpp_server_config_; 160 XmppSignalStrategy::XmppServerConfig xmpp_server_config_;
161 std::string directory_bot_jid_; 161 std::string directory_bot_jid_;
162 162
163 State state_; 163 State state_;
164 164
165 HostKeyPair host_key_pair_; 165 protocol::KeyPair host_key_pair_;
166 scoped_ptr<SignalStrategy> signal_strategy_; 166 scoped_ptr<SignalStrategy> signal_strategy_;
167 scoped_ptr<RegisterSupportHostRequest> register_request_; 167 scoped_ptr<RegisterSupportHostRequest> register_request_;
168 scoped_ptr<LogToServer> log_to_server_; 168 scoped_ptr<LogToServer> log_to_server_;
169 scoped_ptr<DesktopEnvironmentFactory> desktop_environment_factory_; 169 scoped_ptr<DesktopEnvironmentFactory> desktop_environment_factory_;
170 scoped_ptr<It2MeHostUserInterface> it2me_host_user_interface_; 170 scoped_ptr<It2MeHostUserInterface> it2me_host_user_interface_;
171 scoped_ptr<HostEventLogger> host_event_logger_; 171 scoped_ptr<HostEventLogger> host_event_logger_;
172 172
173 scoped_refptr<ChromotingHost> host_; 173 scoped_refptr<ChromotingHost> host_;
174 int failed_login_attempts_; 174 int failed_login_attempts_;
175 175
(...skipping 468 matching lines...) Expand 10 before | Expand all | Expand 10 after
644 std::string local_certificate = host_key_pair_.GenerateCertificate(); 644 std::string local_certificate = host_key_pair_.GenerateCertificate();
645 if (local_certificate.empty()) { 645 if (local_certificate.empty()) {
646 LOG(ERROR) << "Failed to generate host certificate."; 646 LOG(ERROR) << "Failed to generate host certificate.";
647 SetState(kError); 647 SetState(kError);
648 Disconnect(); 648 Disconnect();
649 return; 649 return;
650 } 650 }
651 651
652 scoped_ptr<protocol::AuthenticatorFactory> factory( 652 scoped_ptr<protocol::AuthenticatorFactory> factory(
653 new protocol::It2MeHostAuthenticatorFactory( 653 new protocol::It2MeHostAuthenticatorFactory(
654 local_certificate, *host_key_pair_.private_key(), access_code)); 654 local_certificate, host_key_pair_.Copy(), access_code));
655 host_->SetAuthenticatorFactory(factory.Pass()); 655 host_->SetAuthenticatorFactory(factory.Pass());
656 656
657 // Pass the Access Code to the script object before changing state. 657 // Pass the Access Code to the script object before changing state.
658 plugin_task_runner_->PostTask( 658 plugin_task_runner_->PostTask(
659 FROM_HERE, base::Bind(&HostNPScriptObject::StoreAccessCode, 659 FROM_HERE, base::Bind(&HostNPScriptObject::StoreAccessCode,
660 script_object_, access_code, lifetime)); 660 script_object_, access_code, lifetime));
661 661
662 SetState(kReceivedAccessCode); 662 SetState(kReceivedAccessCode);
663 } 663 }
664 664
(...skipping 774 matching lines...) Expand 10 before | Expand all | Expand 10 after
1439 std::string translation = StringFromNPVariant(np_result); 1439 std::string translation = StringFromNPVariant(np_result);
1440 g_npnetscape_funcs->releasevariantvalue(&np_result); 1440 g_npnetscape_funcs->releasevariantvalue(&np_result);
1441 if (translation.empty()) { 1441 if (translation.empty()) {
1442 LOG(ERROR) << "Missing translation for " << tag; 1442 LOG(ERROR) << "Missing translation for " << tag;
1443 return false; 1443 return false;
1444 } 1444 }
1445 *result = UTF8ToUTF16(translation); 1445 *result = UTF8ToUTF16(translation);
1446 return true; 1446 return true;
1447 } 1447 }
1448 1448
1449 void HostNPScriptObject::DoGenerateKeyPair(const ScopedRefNPObject& callback) { 1449 void HostNPScriptObject::DoGenerateKeyPair(const ScopedRefNPObject& callback) {
Wez 2013/02/23 03:43:20 Not strictly related to this CL, but... DoGenerate
rmsousa 2013/02/26 02:38:52 There's already a TODO comment for it. I'll do tha
1450 HostKeyPair key_pair; 1450 protocol::KeyPair key_pair;
1451 key_pair.Generate(); 1451 key_pair.Generate();
1452 InvokeGenerateKeyPairCallback(callback, key_pair.GetAsString(), 1452 InvokeGenerateKeyPairCallback(callback, key_pair.GetAsString(),
1453 key_pair.GetPublicKey()); 1453 key_pair.GetPublicKey());
1454 } 1454 }
1455 1455
1456 void HostNPScriptObject::InvokeGenerateKeyPairCallback( 1456 void HostNPScriptObject::InvokeGenerateKeyPairCallback(
1457 const ScopedRefNPObject& callback, 1457 const ScopedRefNPObject& callback,
1458 const std::string& private_key, 1458 const std::string& private_key,
1459 const std::string& public_key) { 1459 const std::string& public_key) {
1460 if (!plugin_task_runner_->BelongsToCurrentThread()) { 1460 if (!plugin_task_runner_->BelongsToCurrentThread()) {
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
1582 } 1582 }
1583 1583
1584 void HostNPScriptObject::SetException(const std::string& exception_string) { 1584 void HostNPScriptObject::SetException(const std::string& exception_string) {
1585 DCHECK(plugin_task_runner_->BelongsToCurrentThread()); 1585 DCHECK(plugin_task_runner_->BelongsToCurrentThread());
1586 1586
1587 g_npnetscape_funcs->setexception(parent_, exception_string.c_str()); 1587 g_npnetscape_funcs->setexception(parent_, exception_string.c_str());
1588 LOG(INFO) << exception_string; 1588 LOG(INFO) << exception_string;
1589 } 1589 }
1590 1590
1591 } // namespace remoting 1591 } // namespace remoting
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698