| 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_utils.h" |
| 20 #include "third_party/npapi/bindings/npapi.h" | 21 #include "third_party/npapi/bindings/npapi.h" |
| 21 #include "third_party/npapi/bindings/npfunctions.h" | 22 #include "third_party/npapi/bindings/npfunctions.h" |
| 22 #include "third_party/npapi/bindings/npruntime.h" | 23 #include "third_party/npapi/bindings/npruntime.h" |
| 23 | 24 |
| 24 namespace tracked_objects { | 25 namespace tracked_objects { |
| 25 class Location; | 26 class Location; |
| 26 } // namespace tracked_objects | 27 } // namespace tracked_objects |
| 27 | 28 |
| 28 namespace remoting { | 29 namespace remoting { |
| 29 | 30 |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 72 remoting::protocol::ConnectionToClient* client) OVERRIDE; | 73 remoting::protocol::ConnectionToClient* client) OVERRIDE; |
| 73 virtual void OnClientDisconnected( | 74 virtual void OnClientDisconnected( |
| 74 remoting::protocol::ConnectionToClient* client) OVERRIDE; | 75 remoting::protocol::ConnectionToClient* client) OVERRIDE; |
| 75 virtual void OnShutdown() OVERRIDE; | 76 virtual void OnShutdown() OVERRIDE; |
| 76 | 77 |
| 77 // A Log Message Handler that is called after each LOG message has been | 78 // A Log Message Handler that is called after each LOG message has been |
| 78 // processed. This must be of type LogMessageHandlerFunction defined in | 79 // processed. This must be of type LogMessageHandlerFunction defined in |
| 79 // base/logging.h. | 80 // base/logging.h. |
| 80 static bool LogToUI(int severity, const char* file, int line, | 81 static bool LogToUI(int severity, const char* file, int line, |
| 81 size_t message_start, const std::string& str); | 82 size_t message_start, const std::string& str); |
| 83 |
| 82 private: | 84 private: |
| 83 enum State { | 85 enum State { |
| 84 kDisconnected, | 86 kDisconnected, |
| 85 kRequestedAccessCode, | 87 kRequestedAccessCode, |
| 86 kReceivedAccessCode, | 88 kReceivedAccessCode, |
| 87 kConnected, | 89 kConnected, |
| 88 kAffirmingConnection, | 90 kAffirmingConnection, |
| 89 kError | 91 kError |
| 90 }; | 92 }; |
| 91 | 93 |
| (...skipping 26 matching lines...) Expand all Loading... |
| 118 const std::string& auth_token, | 120 const std::string& auth_token, |
| 119 const std::string& auth_service); | 121 const std::string& auth_service); |
| 120 void DisconnectInternal(); | 122 void DisconnectInternal(); |
| 121 | 123 |
| 122 // Callback for ChromotingHost::Shutdown(). | 124 // Callback for ChromotingHost::Shutdown(). |
| 123 void OnShutdownFinished(); | 125 void OnShutdownFinished(); |
| 124 | 126 |
| 125 // Called when the nat traversal policy is updated. | 127 // Called when the nat traversal policy is updated. |
| 126 void OnNatPolicyUpdate(bool nat_traversal_enabled); | 128 void OnNatPolicyUpdate(bool nat_traversal_enabled); |
| 127 | 129 |
| 130 void LocalizeStrings(); |
| 131 |
| 132 // Helper function for executing InvokeDefault on an NPObject that performs |
| 133 // a string->string mapping with one optional substitution parameter. Stores |
| 134 // the translation in |result| and returns true on success, or leaves it |
| 135 // unchanged and returns false on failure. |
| 136 bool LocalizeString(const char* tag, const char* substitution, |
| 137 std::string* result); |
| 138 |
| 128 // Helper function for executing InvokeDefault on an NPObject, and ignoring | 139 // Helper function for executing InvokeDefault on an NPObject, and ignoring |
| 129 // the return value. | 140 // the return value. |
| 130 bool InvokeAndIgnoreResult(NPObject* func, | 141 bool InvokeAndIgnoreResult(NPObject* func, |
| 131 const NPVariant* args, | 142 const NPVariant* args, |
| 132 uint32_t argCount); | 143 uint32_t argCount); |
| 133 | 144 |
| 134 // Posts a task on the main NP thread. | 145 // Posts a task on the main NP thread. |
| 135 void PostTaskToNPThread( | 146 void PostTaskToNPThread( |
| 136 const tracked_objects::Location& from_here, const base::Closure& task); | 147 const tracked_objects::Location& from_here, const base::Closure& task); |
| 137 | 148 |
| 138 // Utility function for PostTaskToNPThread. | 149 // Utility function for PostTaskToNPThread. |
| 139 static void NPTaskSpringboard(void* task); | 150 static void NPTaskSpringboard(void* task); |
| 140 | 151 |
| 141 // Set an exception for the current call. | 152 // Set an exception for the current call. |
| 142 void SetException(const std::string& exception_string); | 153 void SetException(const std::string& exception_string); |
| 143 | 154 |
| 144 NPP plugin_; | 155 NPP plugin_; |
| 145 NPObject* parent_; | 156 NPObject* parent_; |
| 146 int state_; | 157 int state_; |
| 147 std::string access_code_; | 158 std::string access_code_; |
| 148 std::string client_username_; | 159 std::string client_username_; |
| 149 base::TimeDelta access_code_lifetime_; | 160 base::TimeDelta access_code_lifetime_; |
| 150 NPObject* log_debug_info_func_; | 161 ScopedRefNPObject localize_func_; |
| 151 NPObject* on_state_changed_func_; | 162 ScopedRefNPObject log_debug_info_func_; |
| 163 ScopedRefNPObject on_state_changed_func_; |
| 152 base::PlatformThreadId np_thread_id_; | 164 base::PlatformThreadId np_thread_id_; |
| 153 | 165 |
| 154 scoped_ptr<RegisterSupportHostRequest> register_request_; | 166 scoped_ptr<RegisterSupportHostRequest> register_request_; |
| 155 scoped_refptr<MutableHostConfig> host_config_; | 167 scoped_refptr<MutableHostConfig> host_config_; |
| 156 ChromotingHostContext host_context_; | 168 ChromotingHostContext host_context_; |
| 157 scoped_ptr<DesktopEnvironment> desktop_environment_; | 169 scoped_ptr<DesktopEnvironment> desktop_environment_; |
| 158 | 170 |
| 159 scoped_refptr<ChromotingHost> host_; | 171 scoped_refptr<ChromotingHost> host_; |
| 160 int failed_login_attempts_; | 172 int failed_login_attempts_; |
| 161 | 173 |
| (...skipping 15 matching lines...) Expand all Loading... |
| 177 // it can be executed after at least one successful policy read. This | 189 // it can be executed after at least one successful policy read. This |
| 178 // variable contains the thunk if it is necessary. | 190 // variable contains the thunk if it is necessary. |
| 179 base::Closure pending_connect_; | 191 base::Closure pending_connect_; |
| 180 }; | 192 }; |
| 181 | 193 |
| 182 } // namespace remoting | 194 } // namespace remoting |
| 183 | 195 |
| 184 DISABLE_RUNNABLE_METHOD_REFCOUNT(remoting::HostNPScriptObject); | 196 DISABLE_RUNNABLE_METHOD_REFCOUNT(remoting::HostNPScriptObject); |
| 185 | 197 |
| 186 #endif // REMOTING_HOST_HOST_SCRIPT_OBJECT_H_ | 198 #endif // REMOTING_HOST_HOST_SCRIPT_OBJECT_H_ |
| OLD | NEW |