| OLD | NEW |
| 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 #ifndef REMOTING_HOST_PLUGIN_HOST_SCRIPT_OBJECT_H_ | 5 #ifndef REMOTING_HOST_PLUGIN_HOST_SCRIPT_OBJECT_H_ |
| 6 #define REMOTING_HOST_PLUGIN_HOST_SCRIPT_OBJECT_H_ | 6 #define REMOTING_HOST_PLUGIN_HOST_SCRIPT_OBJECT_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
| 12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
| 13 #include "base/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" |
| 14 #include "base/synchronization/cancellation_flag.h" | 14 #include "base/synchronization/cancellation_flag.h" |
| 15 #include "base/synchronization/waitable_event.h" | 15 #include "base/synchronization/waitable_event.h" |
| 16 #include "base/threading/platform_thread.h" | 16 #include "base/threading/platform_thread.h" |
| 17 #include "base/time.h" | 17 #include "base/time.h" |
| 18 #include "remoting/host/chromoting_host_context.h" | 18 #include "remoting/host/chromoting_host_context.h" |
| 19 #include "remoting/host/host_status_observer.h" | 19 #include "remoting/host/host_status_observer.h" |
| 20 #include "remoting/host/plugin/host_plugin_logger.h" | |
| 21 #include "third_party/npapi/bindings/npapi.h" | 20 #include "third_party/npapi/bindings/npapi.h" |
| 22 #include "third_party/npapi/bindings/npfunctions.h" | 21 #include "third_party/npapi/bindings/npfunctions.h" |
| 23 #include "third_party/npapi/bindings/npruntime.h" | 22 #include "third_party/npapi/bindings/npruntime.h" |
| 24 | 23 |
| 25 namespace tracked_objects { | 24 namespace tracked_objects { |
| 26 class Location; | 25 class Location; |
| 27 } // namespace tracked_objects | 26 } // namespace tracked_objects |
| 28 | 27 |
| 29 namespace remoting { | 28 namespace remoting { |
| 30 | 29 |
| (...skipping 22 matching lines...) Expand all Loading... |
| 53 bool Invoke(const std::string& method_name, | 52 bool Invoke(const std::string& method_name, |
| 54 const NPVariant* args, | 53 const NPVariant* args, |
| 55 uint32_t argCount, | 54 uint32_t argCount, |
| 56 NPVariant* result); | 55 NPVariant* result); |
| 57 bool HasProperty(const std::string& property_name); | 56 bool HasProperty(const std::string& property_name); |
| 58 bool GetProperty(const std::string& property_name, NPVariant* result); | 57 bool GetProperty(const std::string& property_name, NPVariant* result); |
| 59 bool SetProperty(const std::string& property_name, const NPVariant* value); | 58 bool SetProperty(const std::string& property_name, const NPVariant* value); |
| 60 bool RemoveProperty(const std::string& property_name); | 59 bool RemoveProperty(const std::string& property_name); |
| 61 bool Enumerate(std::vector<std::string>* values); | 60 bool Enumerate(std::vector<std::string>* values); |
| 62 | 61 |
| 63 // Call LogDebugInfo handler if there is one. | |
| 64 void LogDebugInfo(const std::string& message); | |
| 65 | |
| 66 // remoting::HostStatusObserver implementation. | 62 // remoting::HostStatusObserver implementation. |
| 67 virtual void OnSignallingConnected(remoting::SignalStrategy* signal_strategy, | 63 virtual void OnSignallingConnected(remoting::SignalStrategy* signal_strategy, |
| 68 const std::string& full_jid) OVERRIDE; | 64 const std::string& full_jid) OVERRIDE; |
| 69 virtual void OnSignallingDisconnected() OVERRIDE; | 65 virtual void OnSignallingDisconnected() OVERRIDE; |
| 70 virtual void OnAccessDenied() OVERRIDE; | 66 virtual void OnAccessDenied() OVERRIDE; |
| 71 virtual void OnClientAuthenticated( | 67 virtual void OnClientAuthenticated( |
| 72 remoting::protocol::ConnectionToClient* client) OVERRIDE; | 68 remoting::protocol::ConnectionToClient* client) OVERRIDE; |
| 73 virtual void OnClientDisconnected( | 69 virtual void OnClientDisconnected( |
| 74 remoting::protocol::ConnectionToClient* client) OVERRIDE; | 70 remoting::protocol::ConnectionToClient* client) OVERRIDE; |
| 75 virtual void OnShutdown() OVERRIDE; | 71 virtual void OnShutdown() OVERRIDE; |
| 76 | 72 |
| 73 // A Log Message Handler that is called after each LOG message has been |
| 74 // processed. This must be of type LogMessageHandlerFunction defined in |
| 75 // base/logging.h. |
| 76 static bool LogToUI(int severity, const char* file, int line, |
| 77 size_t message_start, const std::string& str); |
| 77 private: | 78 private: |
| 78 enum State { | 79 enum State { |
| 79 kDisconnected, | 80 kDisconnected, |
| 80 kRequestedAccessCode, | 81 kRequestedAccessCode, |
| 81 kReceivedAccessCode, | 82 kReceivedAccessCode, |
| 82 kConnected, | 83 kConnected, |
| 83 kAffirmingConnection, | 84 kAffirmingConnection, |
| 84 kError | 85 kError |
| 85 }; | 86 }; |
| 86 | 87 |
| 87 // Start connection. args are: | 88 // Start connection. args are: |
| 88 // string uid, string auth_token | 89 // string uid, string auth_token |
| 89 // No result. | 90 // No result. |
| 90 bool Connect(const NPVariant* args, uint32_t argCount, NPVariant* result); | 91 bool Connect(const NPVariant* args, uint32_t argCount, NPVariant* result); |
| 91 | 92 |
| 92 // Disconnect. No arguments or result. | 93 // Disconnect. No arguments or result. |
| 93 bool Disconnect(const NPVariant* args, uint32_t argCount, NPVariant* result); | 94 bool Disconnect(const NPVariant* args, uint32_t argCount, NPVariant* result); |
| 94 | 95 |
| 95 // Call OnStateChanged handler if there is one. | 96 // Call OnStateChanged handler if there is one. |
| 96 void OnStateChanged(State state); | 97 void OnStateChanged(State state); |
| 97 | 98 |
| 99 // Call LogDebugInfo handler if there is one. |
| 100 void LogDebugInfo(const std::string& message); |
| 101 |
| 98 // Callbacks invoked during session setup. | 102 // Callbacks invoked during session setup. |
| 99 void OnReceivedSupportID(remoting::SupportAccessVerifier* access_verifier, | 103 void OnReceivedSupportID(remoting::SupportAccessVerifier* access_verifier, |
| 100 bool success, | 104 bool success, |
| 101 const std::string& support_id, | 105 const std::string& support_id, |
| 102 const base::TimeDelta& lifetime); | 106 const base::TimeDelta& lifetime); |
| 103 | 107 |
| 104 // Helper functions that run on main thread. Can be called on any | 108 // Helper functions that run on main thread. Can be called on any |
| 105 // other thread. | 109 // other thread. |
| 106 void ConnectInternal(const std::string& uid, | 110 void ConnectInternal(const std::string& uid, |
| 107 const std::string& auth_token, | 111 const std::string& auth_token, |
| (...skipping 22 matching lines...) Expand all Loading... |
| 130 NPP plugin_; | 134 NPP plugin_; |
| 131 NPObject* parent_; | 135 NPObject* parent_; |
| 132 int state_; | 136 int state_; |
| 133 std::string access_code_; | 137 std::string access_code_; |
| 134 std::string client_username_; | 138 std::string client_username_; |
| 135 base::TimeDelta access_code_lifetime_; | 139 base::TimeDelta access_code_lifetime_; |
| 136 NPObject* log_debug_info_func_; | 140 NPObject* log_debug_info_func_; |
| 137 NPObject* on_state_changed_func_; | 141 NPObject* on_state_changed_func_; |
| 138 base::PlatformThreadId np_thread_id_; | 142 base::PlatformThreadId np_thread_id_; |
| 139 | 143 |
| 140 scoped_ptr<HostPluginLogger> logger_; | |
| 141 | |
| 142 scoped_ptr<RegisterSupportHostRequest> register_request_; | 144 scoped_ptr<RegisterSupportHostRequest> register_request_; |
| 143 scoped_refptr<MutableHostConfig> host_config_; | 145 scoped_refptr<MutableHostConfig> host_config_; |
| 144 ChromotingHostContext host_context_; | 146 ChromotingHostContext host_context_; |
| 145 scoped_ptr<DesktopEnvironment> desktop_environment_; | 147 scoped_ptr<DesktopEnvironment> desktop_environment_; |
| 146 | 148 |
| 147 scoped_refptr<ChromotingHost> host_; | 149 scoped_refptr<ChromotingHost> host_; |
| 148 int failed_login_attempts_; | 150 int failed_login_attempts_; |
| 149 | 151 |
| 150 base::WaitableEvent disconnected_event_; | 152 base::WaitableEvent disconnected_event_; |
| 151 base::CancellationFlag destructing_; | 153 base::CancellationFlag destructing_; |
| 152 }; | 154 }; |
| 153 | 155 |
| 154 } // namespace remoting | 156 } // namespace remoting |
| 155 | 157 |
| 156 DISABLE_RUNNABLE_METHOD_REFCOUNT(remoting::HostNPScriptObject); | 158 DISABLE_RUNNABLE_METHOD_REFCOUNT(remoting::HostNPScriptObject); |
| 157 | 159 |
| 158 #endif // REMOTING_HOST_HOST_SCRIPT_OBJECT_H_ | 160 #endif // REMOTING_HOST_HOST_SCRIPT_OBJECT_H_ |
| OLD | NEW |