diff options
author | weitaosu@chromium.org <weitaosu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-11-01 11:43:40 +0000 |
---|---|---|
committer | weitaosu@chromium.org <weitaosu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-11-01 11:43:40 +0000 |
commit | e6791fd4692027e86635adf84b918757eebade45 (patch) | |
tree | a2d257839cc86271b5a45d7cc97a55cfb1800d19 /remoting | |
parent | efc897f7d4133bc9e119d29a2878375abc07e4fd (diff) | |
download | chromium_src-e6791fd4692027e86635adf84b918757eebade45.zip chromium_src-e6791fd4692027e86635adf84b918757eebade45.tar.gz chromium_src-e6791fd4692027e86635adf84b918757eebade45.tar.bz2 |
It2Me native messaging: GYP and source refactoring
1. Add "me2me" to the names of all the me2me specific GYP targets and source files. This makes it easier for my next CL that will add the It2Me native messaging host component.
2. Create a remoting_native_messaging_base GYP target that contains the common native messaging plumbing code shared between remoting_core, remoting_me2me_native_messaging_host and the to-be-created remoting_it2me_native_messaging_host.
3. Clean up some dependencies in remoting.gyp: e.g. the native messaging manifest should be depended on by the archive targets, not the native messaging host binary targets.
4. Rename It2MeImpl to It2MeHost.
BUG=309844
Review URL: https://codereview.chromium.org/49113003
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@232331 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'remoting')
-rw-r--r-- | remoting/host/host_main.cc | 10 | ||||
-rw-r--r-- | remoting/host/it2me/it2me_host.cc (renamed from remoting/host/it2me/it2me_impl.cc) | 71 | ||||
-rw-r--r-- | remoting/host/it2me/it2me_host.h (renamed from remoting/host/it2me/it2me_impl.h) | 22 | ||||
-rw-r--r-- | remoting/host/native_messaging/native_messaging_channel.cc (renamed from remoting/host/setup/native_messaging_channel.cc) | 2 | ||||
-rw-r--r-- | remoting/host/native_messaging/native_messaging_channel.h (renamed from remoting/host/setup/native_messaging_channel.h) | 12 | ||||
-rw-r--r-- | remoting/host/native_messaging/native_messaging_reader.cc (renamed from remoting/host/setup/native_messaging_reader.cc) | 2 | ||||
-rw-r--r-- | remoting/host/native_messaging/native_messaging_reader.h (renamed from remoting/host/setup/native_messaging_reader.h) | 6 | ||||
-rw-r--r-- | remoting/host/native_messaging/native_messaging_reader_unittest.cc (renamed from remoting/host/setup/native_messaging_reader_unittest.cc) | 2 | ||||
-rw-r--r-- | remoting/host/native_messaging/native_messaging_writer.cc (renamed from remoting/host/setup/native_messaging_writer.cc) | 2 | ||||
-rw-r--r-- | remoting/host/native_messaging/native_messaging_writer.h (renamed from remoting/host/setup/native_messaging_writer.h) | 6 | ||||
-rw-r--r-- | remoting/host/native_messaging/native_messaging_writer_unittest.cc (renamed from remoting/host/setup/native_messaging_writer_unittest.cc) | 2 | ||||
-rw-r--r-- | remoting/host/plugin/host_script_object.cc | 26 | ||||
-rw-r--r-- | remoting/host/plugin/host_script_object.h | 16 | ||||
-rw-r--r-- | remoting/host/setup/me2me_native_messaging_host.cc (renamed from remoting/host/setup/native_messaging_host.cc) | 2 | ||||
-rw-r--r-- | remoting/host/setup/me2me_native_messaging_host.h (renamed from remoting/host/setup/native_messaging_host.h) | 8 | ||||
-rw-r--r-- | remoting/host/setup/me2me_native_messaging_host_main.cc (renamed from remoting/host/setup/native_messaging_host_main.cc) | 2 | ||||
-rw-r--r-- | remoting/host/setup/me2me_native_messaging_host_unittest.cc (renamed from remoting/host/setup/native_messaging_host_unittest.cc) | 4 | ||||
-rw-r--r-- | remoting/host/setup/me2me_native_messaging_manifest.json (renamed from remoting/host/setup/native_messaging_manifest.json) | 2 | ||||
-rw-r--r-- | remoting/remoting.gyp | 80 |
19 files changed, 144 insertions, 133 deletions
diff --git a/remoting/host/host_main.cc b/remoting/host/host_main.cc index bf3dc17..512bc64 100644 --- a/remoting/host/host_main.cc +++ b/remoting/host/host_main.cc @@ -21,7 +21,7 @@ #include "remoting/base/resources.h" #include "remoting/host/host_exit_codes.h" #include "remoting/host/logging.h" -#include "remoting/host/setup/native_messaging_host.h" +#include "remoting/host/setup/me2me_native_messaging_host.h" #include "remoting/host/usage_stats_consent.h" #if defined(OS_MACOSX) @@ -155,7 +155,10 @@ int RdpDesktopSessionMain() { MainRoutineFn SelectMainRoutine(const std::string& process_type) { MainRoutineFn main_routine = NULL; - if (process_type == kProcessTypeDaemon) { + if (process_type == kProcessTypeHost) { + main_routine = &HostProcessMain; +#if defined(OS_WIN) + } else if (process_type == kProcessTypeDaemon) { main_routine = &DaemonProcessMain; } else if (process_type == kProcessTypeDesktop) { main_routine = &DesktopProcessMain; @@ -163,10 +166,9 @@ MainRoutineFn SelectMainRoutine(const std::string& process_type) { main_routine = &ElevatedControllerMain; } else if (process_type == kProcessTypeRdpDesktopSession) { main_routine = &RdpDesktopSessionMain; - } else if (process_type == kProcessTypeHost) { - main_routine = &HostProcessMain; } else if (process_type == kProcessTypeNativeMessagingHost) { main_routine = &NativeMessagingHostMain; +#endif // defined(OS_WIN) } return main_routine; diff --git a/remoting/host/it2me/it2me_impl.cc b/remoting/host/it2me/it2me_host.cc index 7b1b4c4..465ca27 100644 --- a/remoting/host/it2me/it2me_impl.cc +++ b/remoting/host/it2me/it2me_host.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "remoting/host/it2me/it2me_impl.h" +#include "remoting/host/it2me/it2me_host.h" #include "base/bind.h" #include "base/strings/string_util.h" @@ -32,10 +32,10 @@ const int kMaxLoginAttempts = 5; } // namespace -It2MeImpl::It2MeImpl( +It2MeHost::It2MeHost( scoped_ptr<ChromotingHostContext> host_context, scoped_refptr<base::SingleThreadTaskRunner> plugin_task_runner, - base::WeakPtr<It2MeImpl::Observer> observer, + base::WeakPtr<It2MeHost::Observer> observer, const XmppSignalStrategy::XmppServerConfig& xmpp_server_config, const std::string& directory_bot_jid) : host_context_(host_context.Pass()), @@ -50,11 +50,11 @@ It2MeImpl::It2MeImpl( DCHECK(plugin_task_runner_->BelongsToCurrentThread()); } -void It2MeImpl::Connect() { +void It2MeHost::Connect() { if (!host_context_->ui_task_runner()->BelongsToCurrentThread()) { DCHECK(plugin_task_runner_->BelongsToCurrentThread()); host_context_->ui_task_runner()->PostTask( - FROM_HERE, base::Bind(&It2MeImpl::Connect, this)); + FROM_HERE, base::Bind(&It2MeHost::Connect, this)); return; } @@ -67,18 +67,18 @@ void It2MeImpl::Connect() { policy_watcher_.reset( policy_hack::PolicyWatcher::Create(host_context_->network_task_runner())); policy_watcher_->StartWatching( - base::Bind(&It2MeImpl::OnPolicyUpdate, this)); + base::Bind(&It2MeHost::OnPolicyUpdate, this)); // Switch to the network thread to start the actual connection. host_context_->network_task_runner()->PostTask( - FROM_HERE, base::Bind(&It2MeImpl::ReadPolicyAndConnect, this)); + FROM_HERE, base::Bind(&It2MeHost::ReadPolicyAndConnect, this)); } -void It2MeImpl::Disconnect() { +void It2MeHost::Disconnect() { if (!host_context_->network_task_runner()->BelongsToCurrentThread()) { DCHECK(plugin_task_runner_->BelongsToCurrentThread()); host_context_->network_task_runner()->PostTask( - FROM_HERE, base::Bind(&It2MeImpl::Disconnect, this)); + FROM_HERE, base::Bind(&It2MeHost::Disconnect, this)); return; } @@ -109,16 +109,16 @@ void It2MeImpl::Disconnect() { // SignalStrategy::Listener handlers are not allowed to destroy // SignalStrategy, so post task to destroy the host later. host_context_->network_task_runner()->PostTask( - FROM_HERE, base::Bind(&It2MeImpl::ShutdownOnNetworkThread, this)); + FROM_HERE, base::Bind(&It2MeHost::ShutdownOnNetworkThread, this)); return; } } -void It2MeImpl::RequestNatPolicy() { +void It2MeHost::RequestNatPolicy() { if (!host_context_->network_task_runner()->BelongsToCurrentThread()) { DCHECK(plugin_task_runner_->BelongsToCurrentThread()); host_context_->network_task_runner()->PostTask( - FROM_HERE, base::Bind(&It2MeImpl::RequestNatPolicy, this)); + FROM_HERE, base::Bind(&It2MeHost::RequestNatPolicy, this)); return; } @@ -126,7 +126,7 @@ void It2MeImpl::RequestNatPolicy() { UpdateNatPolicy(nat_traversal_enabled_); } -void It2MeImpl::ReadPolicyAndConnect() { +void It2MeHost::ReadPolicyAndConnect() { DCHECK(host_context_->network_task_runner()->BelongsToCurrentThread()); SetState(kStarting); @@ -138,11 +138,11 @@ void It2MeImpl::ReadPolicyAndConnect() { } else { // Otherwise, create the policy watcher, and thunk the connect. pending_connect_ = - base::Bind(&It2MeImpl::FinishConnect, this); + base::Bind(&It2MeHost::FinishConnect, this); } } -void It2MeImpl::FinishConnect() { +void It2MeHost::FinishConnect() { DCHECK(host_context_->network_task_runner()->BelongsToCurrentThread()); if (state_ != kStarting) { @@ -172,7 +172,7 @@ void It2MeImpl::FinishConnect() { scoped_ptr<RegisterSupportHostRequest> register_request( new RegisterSupportHostRequest( signal_strategy.get(), host_key_pair_, directory_bot_jid_, - base::Bind(&It2MeImpl::OnReceivedSupportID, + base::Bind(&It2MeHost::OnReceivedSupportID, base::Unretained(this)))); // Beyond this point nothing can fail, so save the config and request. @@ -231,7 +231,7 @@ void It2MeImpl::FinishConnect() { return; } -void It2MeImpl::ShutdownOnNetworkThread() { +void It2MeHost::ShutdownOnNetworkThread() { DCHECK(host_context_->network_task_runner()->BelongsToCurrentThread()); DCHECK(state_ == kDisconnecting || state_ == kDisconnected); @@ -247,10 +247,10 @@ void It2MeImpl::ShutdownOnNetworkThread() { } host_context_->ui_task_runner()->PostTask( - FROM_HERE, base::Bind(&It2MeImpl::ShutdownOnUiThread, this)); + FROM_HERE, base::Bind(&It2MeHost::ShutdownOnUiThread, this)); } -void It2MeImpl::ShutdownOnUiThread() { +void It2MeHost::ShutdownOnUiThread() { DCHECK(host_context_->ui_task_runner()->BelongsToCurrentThread()); // Destroy the DesktopEnvironmentFactory, to free thread references. @@ -265,7 +265,7 @@ void It2MeImpl::ShutdownOnUiThread() { } } -void It2MeImpl::OnAccessDenied(const std::string& jid) { +void It2MeHost::OnAccessDenied(const std::string& jid) { DCHECK(host_context_->network_task_runner()->BelongsToCurrentThread()); ++failed_login_attempts_; @@ -274,8 +274,7 @@ void It2MeImpl::OnAccessDenied(const std::string& jid) { } } -void It2MeImpl::OnClientAuthenticated( - const std::string& jid) { +void It2MeHost::OnClientAuthenticated(const std::string& jid) { DCHECK(host_context_->network_task_runner()->BelongsToCurrentThread()); if (state_ == kDisconnecting) { @@ -300,21 +299,19 @@ void It2MeImpl::OnClientAuthenticated( // Pass the client user name to the script object before changing state. plugin_task_runner_->PostTask( - FROM_HERE, base::Bind(&It2MeImpl::Observer::OnClientAuthenticated, + FROM_HERE, base::Bind(&It2MeHost::Observer::OnClientAuthenticated, observer_, client_username)); SetState(kConnected); } -void It2MeImpl::OnClientDisconnected( - const std::string& jid) { +void It2MeHost::OnClientDisconnected(const std::string& jid) { DCHECK(host_context_->network_task_runner()->BelongsToCurrentThread()); Disconnect(); } -void It2MeImpl::OnPolicyUpdate( - scoped_ptr<base::DictionaryValue> policies) { +void It2MeHost::OnPolicyUpdate(scoped_ptr<base::DictionaryValue> policies) { DCHECK(host_context_->network_task_runner()->BelongsToCurrentThread()); bool nat_policy; @@ -336,8 +333,7 @@ void It2MeImpl::OnPolicyUpdate( } } -void It2MeImpl::UpdateNatPolicy( - bool nat_traversal_enabled) { +void It2MeHost::UpdateNatPolicy(bool nat_traversal_enabled) { DCHECK(host_context_->network_task_runner()->BelongsToCurrentThread()); VLOG(2) << "UpdateNatPolicy: " << nat_traversal_enabled; @@ -352,12 +348,11 @@ void It2MeImpl::UpdateNatPolicy( // Notify the web-app of the policy setting. plugin_task_runner_->PostTask( - FROM_HERE, base::Bind(&It2MeImpl::Observer::OnNatPolicyChanged, + FROM_HERE, base::Bind(&It2MeHost::Observer::OnNatPolicyChanged, observer_, nat_traversal_enabled_)); } -void It2MeImpl::UpdateHostDomainPolicy( - const std::string& host_domain) { +void It2MeHost::UpdateHostDomainPolicy(const std::string& host_domain) { DCHECK(host_context_->network_task_runner()->BelongsToCurrentThread()); VLOG(2) << "UpdateHostDomainPolicy: " << host_domain; @@ -370,13 +365,13 @@ void It2MeImpl::UpdateHostDomainPolicy( required_host_domain_ = host_domain; } -It2MeImpl::~It2MeImpl() { +It2MeHost::~It2MeHost() { // Check that resources that need to be torn down on the UI thread are gone. DCHECK(!desktop_environment_factory_.get()); DCHECK(!policy_watcher_.get()); } -void It2MeImpl::SetState(It2MeHostState state) { +void It2MeHost::SetState(It2MeHostState state) { DCHECK(host_context_->network_task_runner()->BelongsToCurrentThread()); switch (state_) { @@ -420,16 +415,16 @@ void It2MeImpl::SetState(It2MeHostState state) { // Post a state-change notification to the web-app. plugin_task_runner_->PostTask( - FROM_HERE, base::Bind(&It2MeImpl::Observer::OnStateChanged, + FROM_HERE, base::Bind(&It2MeHost::Observer::OnStateChanged, observer_, state)); } -bool It2MeImpl::IsConnected() const { +bool It2MeHost::IsConnected() const { return state_ == kRequestedAccessCode || state_ == kReceivedAccessCode || state_ == kConnected; } -void It2MeImpl::OnReceivedSupportID( +void It2MeHost::OnReceivedSupportID( bool success, const std::string& support_id, const base::TimeDelta& lifetime) { @@ -459,7 +454,7 @@ void It2MeImpl::OnReceivedSupportID( // Pass the Access Code to the script object before changing state. plugin_task_runner_->PostTask( - FROM_HERE, base::Bind(&It2MeImpl::Observer::OnStoreAccessCode, + FROM_HERE, base::Bind(&It2MeHost::Observer::OnStoreAccessCode, observer_, access_code, lifetime)); SetState(kReceivedAccessCode); diff --git a/remoting/host/it2me/it2me_impl.h b/remoting/host/it2me/it2me_host.h index f31709b..6a40276 100644 --- a/remoting/host/it2me/it2me_impl.h +++ b/remoting/host/it2me/it2me_host.h @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef REMOTING_HOST_IT2ME__IT2ME_IMPL_H_ -#define REMOTING_HOST_IT2ME__IT2ME_IMPL_H_ +#ifndef REMOTING_HOST_IT2ME_IT2ME_HOST_H_ +#define REMOTING_HOST_IT2ME_IT2ME_HOST_H_ #include "base/memory/ref_counted.h" #include "base/memory/weak_ptr.h" @@ -40,8 +40,8 @@ enum It2MeHostState { }; // Internal implementation of the plugin's It2Me host function. -class It2MeImpl - : public base::RefCountedThreadSafe<It2MeImpl>, +class It2MeHost + : public base::RefCountedThreadSafe<It2MeHost>, public HostStatusObserver { public: @@ -54,10 +54,10 @@ class It2MeImpl virtual void OnStateChanged(It2MeHostState state) = 0; }; - It2MeImpl( + It2MeHost( scoped_ptr<ChromotingHostContext> context, scoped_refptr<base::SingleThreadTaskRunner> plugin_task_runner, - base::WeakPtr<It2MeImpl::Observer> observer, + base::WeakPtr<It2MeHost::Observer> observer, const XmppSignalStrategy::XmppServerConfig& xmpp_server_config, const std::string& directory_bot_jid); @@ -79,9 +79,9 @@ class It2MeImpl virtual void OnClientDisconnected(const std::string& jid) OVERRIDE; private: - friend class base::RefCountedThreadSafe<It2MeImpl>; + friend class base::RefCountedThreadSafe<It2MeHost>; - virtual ~It2MeImpl(); + virtual ~It2MeHost(); // Updates state of the host. Can be called only on the network thread. void SetState(It2MeHostState state); @@ -118,7 +118,7 @@ class It2MeImpl // Caller supplied fields. scoped_ptr<ChromotingHostContext> host_context_; scoped_refptr<base::SingleThreadTaskRunner> plugin_task_runner_; - base::WeakPtr<It2MeImpl::Observer> observer_; + base::WeakPtr<It2MeHost::Observer> observer_; XmppSignalStrategy::XmppServerConfig xmpp_server_config_; std::string directory_bot_jid_; @@ -153,9 +153,9 @@ class It2MeImpl // variable contains the thunk if it is necessary. base::Closure pending_connect_; - DISALLOW_COPY_AND_ASSIGN(It2MeImpl); + DISALLOW_COPY_AND_ASSIGN(It2MeHost); }; } // namespace remoting -#endif // REMOTING_HOST_IT2ME__IT2ME_IMPL_H_ +#endif // REMOTING_HOST_IT2ME_IT2ME_HOST_H_ diff --git a/remoting/host/setup/native_messaging_channel.cc b/remoting/host/native_messaging/native_messaging_channel.cc index b93fd94..3d4cf60 100644 --- a/remoting/host/setup/native_messaging_channel.cc +++ b/remoting/host/native_messaging/native_messaging_channel.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "remoting/host/setup/native_messaging_channel.h" +#include "remoting/host/native_messaging/native_messaging_channel.h" #include "base/basictypes.h" #include "base/bind.h" diff --git a/remoting/host/setup/native_messaging_channel.h b/remoting/host/native_messaging/native_messaging_channel.h index 9b0c229..f597847 100644 --- a/remoting/host/setup/native_messaging_channel.h +++ b/remoting/host/native_messaging/native_messaging_channel.h @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef REMOTING_HOST_SETUP_NATIVE_MESSAGING_CHANNEL_H_ -#define REMOTING_HOST_SETUP_NATIVE_MESSAGING_CHANNEL_H_ +#ifndef REMOTING_HOST_NATIVE_MESSAGING_NATIVE_MESSAGING_CHANNEL_H_ +#define REMOTING_HOST_NATIVE_MESSAGING_NATIVE_MESSAGING_CHANNEL_H_ #include "base/callback.h" #include "base/memory/ref_counted.h" @@ -11,8 +11,8 @@ #include "base/memory/weak_ptr.h" #include "base/platform_file.h" #include "base/threading/non_thread_safe.h" -#include "remoting/host/setup/native_messaging_reader.h" -#include "remoting/host/setup/native_messaging_writer.h" +#include "remoting/host/native_messaging/native_messaging_reader.h" +#include "remoting/host/native_messaging/native_messaging_writer.h" namespace base { class DictionaryValue; @@ -45,7 +45,7 @@ class NativeMessagingChannel : public base::NonThreadSafe { }; // Constructs an object taking the ownership of |input| and |output|. Closes - // |input| and |output| to prevent the caller frmo using them. + // |input| and |output| to prevent the caller from using them. NativeMessagingChannel( scoped_ptr<Delegate> delegate, base::PlatformFile input, @@ -91,4 +91,4 @@ class NativeMessagingChannel : public base::NonThreadSafe { } // namespace remoting -#endif // REMOTING_HOST_SETUP_NATIVE_MESSAGING_CHANNEL_H_ +#endif // REMOTING_HOST_NATIVE_MESSAGING_NATIVE_MESSAGING_CHANNEL_H_ diff --git a/remoting/host/setup/native_messaging_reader.cc b/remoting/host/native_messaging/native_messaging_reader.cc index 7151653..031daf7 100644 --- a/remoting/host/setup/native_messaging_reader.cc +++ b/remoting/host/native_messaging/native_messaging_reader.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "remoting/host/setup/native_messaging_reader.h" +#include "remoting/host/native_messaging/native_messaging_reader.h" #include <string> diff --git a/remoting/host/setup/native_messaging_reader.h b/remoting/host/native_messaging/native_messaging_reader.h index b9c81c3..06eb4cc 100644 --- a/remoting/host/setup/native_messaging_reader.h +++ b/remoting/host/native_messaging/native_messaging_reader.h @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef REMOTING_HOST_SETUP_NATIVE_MESSAGING_READER_H_ -#define REMOTING_HOST_SETUP_NATIVE_MESSAGING_READER_H_ +#ifndef REMOTING_HOST_NATIVE_MESSAGING_NATIVE_MESSAGING_READER_H_ +#define REMOTING_HOST_NATIVE_MESSAGING_NATIVE_MESSAGING_READER_H_ #include "base/basictypes.h" #include "base/callback.h" @@ -73,4 +73,4 @@ class NativeMessagingReader { } // namespace remoting -#endif // REMOTING_HOST_SETUP_NATIVE_MESSAGING_READER_H_ +#endif // REMOTING_HOST_NATIVE_MESSAGING_NATIVE_MESSAGING_READER_H_ diff --git a/remoting/host/setup/native_messaging_reader_unittest.cc b/remoting/host/native_messaging/native_messaging_reader_unittest.cc index c78b4c2..26ed78d 100644 --- a/remoting/host/setup/native_messaging_reader_unittest.cc +++ b/remoting/host/native_messaging/native_messaging_reader_unittest.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "remoting/host/setup/native_messaging_reader.h" +#include "remoting/host/native_messaging/native_messaging_reader.h" #include "base/basictypes.h" #include "base/bind.h" diff --git a/remoting/host/setup/native_messaging_writer.cc b/remoting/host/native_messaging/native_messaging_writer.cc index 15d6cd7..9788f21 100644 --- a/remoting/host/setup/native_messaging_writer.cc +++ b/remoting/host/native_messaging/native_messaging_writer.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "remoting/host/setup/native_messaging_writer.h" +#include "remoting/host/native_messaging/native_messaging_writer.h" #include <string> diff --git a/remoting/host/setup/native_messaging_writer.h b/remoting/host/native_messaging/native_messaging_writer.h index 72e5345..6208f91 100644 --- a/remoting/host/setup/native_messaging_writer.h +++ b/remoting/host/native_messaging/native_messaging_writer.h @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef REMOTING_HOST_SETUP_NATIVE_MESSAGING_WRITER_H_ -#define REMOTING_HOST_SETUP_NATIVE_MESSAGING_WRITER_H_ +#ifndef REMOTING_HOST_NATIVE_MESSAGING_NATIVE_MESSAGING_WRITER_H_ +#define REMOTING_HOST_NATIVE_MESSAGING_NATIVE_MESSAGING_WRITER_H_ #include "base/platform_file.h" #include "net/base/file_stream.h" @@ -34,4 +34,4 @@ class NativeMessagingWriter { } // namespace remoting -#endif // REMOTING_HOST_SETUP_NATIVE_MESSAGING_WRITER_H_ +#endif // REMOTING_HOST_NATIVE_MESSAGING_NATIVE_MESSAGING_WRITER_H_ diff --git a/remoting/host/setup/native_messaging_writer_unittest.cc b/remoting/host/native_messaging/native_messaging_writer_unittest.cc index c0cfbd1..52bdb1f 100644 --- a/remoting/host/setup/native_messaging_writer_unittest.cc +++ b/remoting/host/native_messaging/native_messaging_writer_unittest.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "remoting/host/setup/native_messaging_writer.h" +#include "remoting/host/native_messaging/native_messaging_writer.h" #include "base/basictypes.h" #include "base/json/json_reader.h" diff --git a/remoting/host/plugin/host_script_object.cc b/remoting/host/plugin/host_script_object.cc index 66d228c..542f725 100644 --- a/remoting/host/plugin/host_script_object.cc +++ b/remoting/host/plugin/host_script_object.cc @@ -130,9 +130,9 @@ HostNPScriptObject::~HostNPScriptObject() { HostLogHandler::UnregisterLoggingScriptObject(this); // Stop the It2Me host if the caller forgot to. - if (it2me_impl_.get()) { - it2me_impl_->Disconnect(); - it2me_impl_ = NULL; + if (it2me_host_.get()) { + it2me_host_->Disconnect(); + it2me_host_ = NULL; } } @@ -315,9 +315,9 @@ bool HostNPScriptObject::SetProperty(const std::string& property_name, if (property_name == kAttrNameOnNatTraversalPolicyChanged) { if (NPVARIANT_IS_OBJECT(*value)) { on_nat_traversal_policy_changed_func_ = NPVARIANT_TO_OBJECT(*value); - if (it2me_impl_.get()) { - // Ask the It2Me implementation to notify the web-app of the policy. - it2me_impl_->RequestNatPolicy(); + if (it2me_host_.get()) { + // Ask the It2Me host to notify the web-app of the policy. + it2me_host_->RequestNatPolicy(); } return true; } else { @@ -454,7 +454,7 @@ bool HostNPScriptObject::Connect(const NPVariant* args, return false; } - if (it2me_impl_.get()) { + if (it2me_host_.get()) { SetException("connect: can be called only when disconnected"); return false; } @@ -483,11 +483,11 @@ bool HostNPScriptObject::Connect(const NPVariant* args, return false; } - // Create the It2Me host implementation and start connecting. - it2me_impl_ = new It2MeImpl( + // Create the It2Me host and start connecting. + it2me_host_ = new It2MeHost( host_context.Pass(), plugin_task_runner_, weak_ptr_, xmpp_config, directory_bot_jid_); - it2me_impl_->Connect(); + it2me_host_->Connect(); return true; } @@ -501,9 +501,9 @@ bool HostNPScriptObject::Disconnect(const NPVariant* args, return false; } - if (it2me_impl_.get()) { - it2me_impl_->Disconnect(); - it2me_impl_ = NULL; + if (it2me_host_.get()) { + it2me_host_->Disconnect(); + it2me_host_ = NULL; } return true; diff --git a/remoting/host/plugin/host_script_object.h b/remoting/host/plugin/host_script_object.h index 74abcd9..2558903 100644 --- a/remoting/host/plugin/host_script_object.h +++ b/remoting/host/plugin/host_script_object.h @@ -13,7 +13,7 @@ #include "base/thread_task_runner_handle.h" #include "base/time/time.h" #include "remoting/base/auto_thread_task_runner.h" -#include "remoting/host/it2me/it2me_impl.h" +#include "remoting/host/it2me/it2me_host.h" #include "remoting/host/plugin/host_plugin_utils.h" #include "remoting/host/setup/daemon_controller.h" #include "remoting/jingle_glue/xmpp_signal_strategy.h" @@ -25,7 +25,7 @@ namespace remoting { // HostNPScriptObject creates threads that are required to run // ChromotingHost and starts/stops the host on those threads. When // destroyed it synchronously shuts down the host and all threads. -class HostNPScriptObject : public It2MeImpl::Observer { +class HostNPScriptObject : public It2MeHost::Observer { public: HostNPScriptObject(NPP plugin, NPObject* parent, @@ -157,7 +157,7 @@ class HostNPScriptObject : public It2MeImpl::Observer { bool StopDaemon(const NPVariant* args, uint32_t arg_count, NPVariant* result); ////////////////////////////////////////////////////////// - // Implementation of It2MeImpl::Observer methods. + // Implementation of It2MeHost::Observer methods. // Notifies OnStateChanged handler of a state change. virtual void OnStateChanged(It2MeHostState state) OVERRIDE; @@ -266,21 +266,21 @@ class HostNPScriptObject : public It2MeImpl::Observer { // It2Me host state. // Internal implementation of the It2Me host function. - scoped_refptr<It2MeImpl> it2me_impl_; + scoped_refptr<It2MeHost> it2me_host_; - // Cached, read-only copies of |it2me_impl_| session state. + // Cached, read-only copies of |it2me_host_| session state. It2MeHostState state_; std::string access_code_; base::TimeDelta access_code_lifetime_; std::string client_username_; - // IT2Me Talk server configuration used by |it2me_impl_| to connect. + // IT2Me Talk server configuration used by |it2me_host_| to connect. XmppSignalStrategy::XmppServerConfig xmpp_server_config_; - // Chromoting Bot JID used by |it2me_impl_| to register the host. + // Chromoting Bot JID used by |it2me_host_| to register the host. std::string directory_bot_jid_; - // Callbacks to notify in response to |it2me_impl_| events. + // Callbacks to notify in response to |it2me_host_| events. ScopedRefNPObject on_nat_traversal_policy_changed_func_; ScopedRefNPObject on_state_changed_func_; diff --git a/remoting/host/setup/native_messaging_host.cc b/remoting/host/setup/me2me_native_messaging_host.cc index 38ecdb1..63297a9 100644 --- a/remoting/host/setup/native_messaging_host.cc +++ b/remoting/host/setup/me2me_native_messaging_host.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "remoting/host/setup/native_messaging_host.h" +#include "remoting/host/setup/me2me_native_messaging_host.h" #include <string> diff --git a/remoting/host/setup/native_messaging_host.h b/remoting/host/setup/me2me_native_messaging_host.h index 4a359d7..179b0fe 100644 --- a/remoting/host/setup/native_messaging_host.h +++ b/remoting/host/setup/me2me_native_messaging_host.h @@ -2,15 +2,15 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef REMOTING_HOST_SETUP_NATIVE_MESSAGING_HOST_H_ -#define REMOTING_HOST_SETUP_NATIVE_MESSAGING_HOST_H_ +#ifndef REMOTING_HOST_SETUP_ME2ME_NATIVE_MESSAGING_HOST_H_ +#define REMOTING_HOST_SETUP_ME2ME_NATIVE_MESSAGING_HOST_H_ #include "base/memory/ref_counted.h" #include "base/memory/scoped_ptr.h" #include "base/memory/weak_ptr.h" #include "base/threading/thread_checker.h" +#include "remoting/host/native_messaging/native_messaging_channel.h" #include "remoting/host/setup/daemon_controller.h" -#include "remoting/host/setup/native_messaging_channel.h" #include "remoting/host/setup/oauth_client.h" namespace base { @@ -155,4 +155,4 @@ int NativeMessagingHostMain(); } // namespace remoting -#endif // REMOTING_HOST_SETUP_NATIVE_MESSAGING_HOST_H_ +#endif // REMOTING_HOST_SETUP_ME2ME_NATIVE_MESSAGING_HOST_H_ diff --git a/remoting/host/setup/native_messaging_host_main.cc b/remoting/host/setup/me2me_native_messaging_host_main.cc index d9db325..e69abfc 100644 --- a/remoting/host/setup/native_messaging_host_main.cc +++ b/remoting/host/setup/me2me_native_messaging_host_main.cc @@ -5,7 +5,7 @@ #include "base/at_exit.h" #include "base/command_line.h" #include "remoting/host/logging.h" -#include "remoting/host/setup/native_messaging_host.h" +#include "remoting/host/setup/me2me_native_messaging_host.h" int main(int argc, char** argv) { // This object instance is required by Chrome code (such as MessageLoop). diff --git a/remoting/host/setup/native_messaging_host_unittest.cc b/remoting/host/setup/me2me_native_messaging_host_unittest.cc index 164b77d..0d6e700 100644 --- a/remoting/host/setup/native_messaging_host_unittest.cc +++ b/remoting/host/setup/me2me_native_messaging_host_unittest.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "remoting/host/setup/native_messaging_host.h" +#include "remoting/host/setup/me2me_native_messaging_host.h" #include "base/basictypes.h" #include "base/compiler_specific.h" @@ -17,8 +17,8 @@ #include "net/base/file_stream.h" #include "net/base/net_util.h" #include "remoting/base/auto_thread_task_runner.h" +#include "remoting/host/native_messaging/native_messaging_channel.h" #include "remoting/host/pin_hash.h" -#include "remoting/host/setup/native_messaging_channel.h" #include "remoting/host/setup/test_util.h" #include "remoting/protocol/pairing_registry.h" #include "remoting/protocol/protocol_mock_objects.h" diff --git a/remoting/host/setup/native_messaging_manifest.json b/remoting/host/setup/me2me_native_messaging_manifest.json index 84884a2..d0b2fb1 100644 --- a/remoting/host/setup/native_messaging_manifest.json +++ b/remoting/host/setup/me2me_native_messaging_manifest.json @@ -2,7 +2,7 @@ "name": "com.google.chrome.remote_desktop", "description": "{% trans %}REMOTING_HOST_PLUGIN_NAME{% endtrans %}", "type": "stdio", - "path": "{{ NATIVE_MESSAGING_HOST_PATH }}", + "path": "{{ ME2ME_NATIVE_MESSAGING_HOST_PATH }}", "allowed_origins": [ "chrome-extension://ljacajndfccfgnfohlgkdphmbnpkjflk/", "chrome-extension://gbchcmhmhahfdphkhkmpfmihenigjmpp/", diff --git a/remoting/remoting.gyp b/remoting/remoting.gyp index 4835be6..0284b35 100644 --- a/remoting/remoting.gyp +++ b/remoting/remoting.gyp @@ -529,6 +529,23 @@ }, # end of target 'remoting_host' { + 'target_name': 'remoting_native_messaging_base', + 'type': 'static_library', + 'variables': { 'enable_wexit_time_destructors': 1, }, + 'dependencies': [ + '../base/base.gyp:base', + ], + 'sources': [ + 'host/native_messaging/native_messaging_channel.cc', + 'host/native_messaging/native_messaging_channel.h', + 'host/native_messaging/native_messaging_reader.cc', + 'host/native_messaging/native_messaging_reader.h', + 'host/native_messaging/native_messaging_writer.cc', + 'host/native_messaging/native_messaging_writer.h', + ], + }, # end of target 'remoting_native_messaging_base' + + { 'target_name': 'remoting_me2me_host_static', 'type': 'static_library', 'variables': { 'enable_wexit_time_destructors': 1, }, @@ -589,14 +606,8 @@ 'host/setup/daemon_installer_win.h', 'host/setup/host_starter.cc', 'host/setup/host_starter.h', - 'host/setup/native_messaging_channel.cc', - 'host/setup/native_messaging_channel.h', - 'host/setup/native_messaging_host.cc', - 'host/setup/native_messaging_host.h', - 'host/setup/native_messaging_reader.cc', - 'host/setup/native_messaging_reader.h', - 'host/setup/native_messaging_writer.cc', - 'host/setup/native_messaging_writer.h', + 'host/setup/me2me_native_messaging_host.cc', + 'host/setup/me2me_native_messaging_host.h', 'host/setup/oauth_client.cc', 'host/setup/oauth_client.h', 'host/setup/oauth_helper.cc', @@ -748,8 +759,8 @@ 'remoting_resources', ], 'sources': [ - 'host/it2me/it2me_impl.cc', - 'host/it2me/it2me_impl.h', + 'host/it2me/it2me_host.cc', + 'host/it2me/it2me_host.h', ], }, # end of target 'remoting_it2me_host_static' { @@ -899,7 +910,8 @@ 'dependencies': [ 'remoting_me2me_host', 'remoting_start_host', - 'remoting_native_messaging_host', + 'remoting_me2me_native_messaging_host', + 'remoting_me2me_native_messaging_manifest', ], 'actions': [ { @@ -1021,7 +1033,7 @@ ], # end of 'conditions' }, # end of target 'remoting_me2me_host' { - 'target_name': 'remoting_native_messaging_host', + 'target_name': 'remoting_me2me_native_messaging_host', 'type': 'executable', 'variables': { 'enable_wexit_time_destructors': 1, }, 'dependencies': [ @@ -1029,13 +1041,10 @@ 'remoting_host', 'remoting_host_logging', 'remoting_host_setup_base', - 'remoting_native_messaging_manifest', - ], - 'defines': [ - 'VERSION=<(version_full)', + 'remoting_native_messaging_base', ], 'sources': [ - 'host/setup/native_messaging_host_main.cc', + 'host/setup/me2me_native_messaging_host_main.cc', ], 'conditions': [ ['OS=="linux" and linux_use_tcmalloc==1', { @@ -1044,7 +1053,7 @@ ], }], ], - }, # end of target 'remoting_native_messaging_host' + }, # end of target 'remoting_me2me_native_messaging_host' ], # end of 'targets' }], # 'OS!="win" and enable_remoting_host==1' @@ -1158,7 +1167,8 @@ 'remoting_host_prefpane', 'remoting_host_uninstaller', 'remoting_me2me_host', - 'remoting_native_messaging_host', + 'remoting_me2me_native_messaging_host', + 'remoting_me2me_native_messaging_manifest', ], 'variables': { 'host_name': '<!(python <(version_py_path) -f <(branding_path) -t "@HOST_PLUGIN_FILE_NAME@")', @@ -1188,7 +1198,7 @@ 'PrivilegedHelperTools/org.chromium.chromoting.me2me_host.app', 'Applications/<(host_uninstaller_name).app', 'PrivilegedHelperTools/org.chromium.chromoting.me2me_host.app/Contents/MacOS/native_messaging_host', - 'Config/com.google.chrome.remote_desktop.json', + 'Config/com.google.chrome.remote_desktop.json', ], 'source_files': [ '<@(remoting_host_installer_mac_files)', @@ -1536,6 +1546,7 @@ 'remoting_lib_ps', 'remoting_lib_rc', 'remoting_me2me_host_static', + 'remoting_native_messaging_base', 'remoting_protocol', 'remoting_version_resources', ], @@ -1570,6 +1581,7 @@ 'host/remoting_me2me_host.cc', 'host/sas_injector.h', 'host/sas_injector_win.cc', + 'host/setup/me2me_native_messaging_host_main.cc', 'host/verify_config_window_win.cc', 'host/verify_config_window_win.h', 'host/win/chromoting_module.cc', @@ -1964,7 +1976,7 @@ 'remoting_core', 'remoting_desktop', 'remoting_host_exe', - 'remoting_native_messaging_manifest', + 'remoting_me2me_native_messaging_manifest', ], 'compiled_inputs': [ '<(PRODUCT_DIR)/remoting_core.dll', @@ -2321,16 +2333,16 @@ ], }, # end of target 'remoting_webapp' - # Generates 'native_messaging_manifest.json' to be included in the + # Generates 'me2me_native_messaging_manifest.json' to be included in the # installation. { - 'target_name': 'remoting_native_messaging_manifest', + 'target_name': 'remoting_me2me_native_messaging_manifest', 'type': 'none', 'dependencies': [ 'remoting_resources', ], 'variables': { - 'input': 'host/setup/native_messaging_manifest.json', + 'input': 'host/setup/me2me_native_messaging_manifest.json', 'output': '<(PRODUCT_DIR)/remoting/com.google.chrome.remote_desktop.json', }, 'target_conditions': [ @@ -2338,19 +2350,19 @@ 'conditions': [ [ 'OS == "win"', { 'variables': { - 'native_messaging_host_path': 'remoting_host.exe', + 'me2me_native_messaging_host_path': 'remoting_host.exe', }, }], [ 'OS == "mac"', { 'variables': { - 'native_messaging_host_path': '/Library/PrivilegedHelperTools/org.chromium.chromoting.me2me_host.app/Contents/MacOS/native_messaging_host', + 'me2me_native_messaging_host_path': '/Library/PrivilegedHelperTools/org.chromium.chromoting.me2me_host.app/Contents/MacOS/native_messaging_host', }, }], ['OS == "linux"', { 'variables': { - 'native_messaging_host_path': '/opt/google/chrome-remote-desktop/native-messaging-host', + 'me2me_native_messaging_host_path': '/opt/google/chrome-remote-desktop/native-messaging-host', }, }], ['OS != "linux" and OS != "mac" and OS != "win"', { 'variables': { - 'native_messaging_host_path': '/opt/google/chrome-remote-desktop/native-messaging-host', + 'me2me_native_messaging_host_path': '/opt/google/chrome-remote-desktop/native-messaging-host', }, }], ], # conditions @@ -2367,7 +2379,7 @@ 'action': [ 'python', '<(remoting_localize_path)', - '--define', 'NATIVE_MESSAGING_HOST_PATH=<(native_messaging_host_path)', + '--define', 'ME2ME_NATIVE_MESSAGING_HOST_PATH=<(me2me_native_messaging_host_path)', '--locale_dir', '<(webapp_locale_dir)', '--template', '<(input)', '--locale_output', @@ -2380,7 +2392,7 @@ }, ], ], # target_conditions - }, # end of target 'remoting_native_messaging_manifest' + }, # end of target 'remoting_me2me_native_messaging_manifest' { 'target_name': 'remoting_resources', 'type': 'none', @@ -2787,6 +2799,7 @@ 'remoting_host_event_logger', 'remoting_host_setup_base', 'remoting_jingle_glue', + 'remoting_native_messaging_base', 'remoting_protocol', 'remoting_resources', '../third_party/webrtc/modules/modules.gyp:desktop_capture', @@ -2851,6 +2864,8 @@ 'host/linux/x_server_clipboard_unittest.cc', 'host/local_input_monitor_unittest.cc', 'host/log_to_server_unittest.cc', + 'host/native_messaging/native_messaging_reader_unittest.cc', + 'host/native_messaging/native_messaging_writer_unittest.cc', 'host/pairing_registry_delegate_linux_unittest.cc', 'host/pairing_registry_delegate_win_unittest.cc', 'host/pin_hash_unittest.cc', @@ -2866,9 +2881,7 @@ 'host/screen_capturer_fake.h', 'host/screen_resolution_unittest.cc', 'host/server_log_entry_unittest.cc', - 'host/setup/native_messaging_host_unittest.cc', - 'host/setup/native_messaging_reader_unittest.cc', - 'host/setup/native_messaging_writer_unittest.cc', + 'host/setup/me2me_native_messaging_host_unittest.cc', 'host/setup/oauth_helper_unittest.cc', 'host/setup/pin_validator_unittest.cc', 'host/token_validator_factory_impl_unittest.cc', @@ -2971,6 +2984,7 @@ 'dependencies!': [ 'remoting_host', 'remoting_host_setup_base', + 'remoting_native_messaging_base', ], 'sources/': [ ['exclude', 'codec/*'], |