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 OnAuthenticatedClientsChanged(int clients_connected) OVERRIDE; | 67 virtual void OnAuthenticatedClientsChanged(int clients_connected) OVERRIDE; |
72 virtual void OnShutdown() OVERRIDE; | 68 virtual void OnShutdown() OVERRIDE; |
73 | 69 |
| 70 // A Log Message Handler that is called after each LOG message has been |
| 71 // processed. This must be of type LogMessageHandlerFunction defined in |
| 72 // base/logging.h. |
| 73 static bool LogToUI(int severity, const char* file, int line, |
| 74 size_t message_start, const std::string& str); |
74 private: | 75 private: |
75 enum State { | 76 enum State { |
76 kDisconnected, | 77 kDisconnected, |
77 kRequestedAccessCode, | 78 kRequestedAccessCode, |
78 kReceivedAccessCode, | 79 kReceivedAccessCode, |
79 kConnected, | 80 kConnected, |
80 kAffirmingConnection, | 81 kAffirmingConnection, |
81 kError | 82 kError |
82 }; | 83 }; |
83 | 84 |
84 // Start connection. args are: | 85 // Start connection. args are: |
85 // string uid, string auth_token | 86 // string uid, string auth_token |
86 // No result. | 87 // No result. |
87 bool Connect(const NPVariant* args, uint32_t argCount, NPVariant* result); | 88 bool Connect(const NPVariant* args, uint32_t argCount, NPVariant* result); |
88 | 89 |
89 // Disconnect. No arguments or result. | 90 // Disconnect. No arguments or result. |
90 bool Disconnect(const NPVariant* args, uint32_t argCount, NPVariant* result); | 91 bool Disconnect(const NPVariant* args, uint32_t argCount, NPVariant* result); |
91 | 92 |
92 // Call OnStateChanged handler if there is one. | 93 // Call OnStateChanged handler if there is one. |
93 void OnStateChanged(State state); | 94 void OnStateChanged(State state); |
94 | 95 |
| 96 // Call LogDebugInfo handler if there is one. |
| 97 void LogDebugInfo(const std::string& message); |
| 98 |
95 // Callbacks invoked during session setup. | 99 // Callbacks invoked during session setup. |
96 void OnReceivedSupportID(remoting::SupportAccessVerifier* access_verifier, | 100 void OnReceivedSupportID(remoting::SupportAccessVerifier* access_verifier, |
97 bool success, | 101 bool success, |
98 const std::string& support_id, | 102 const std::string& support_id, |
99 const base::TimeDelta& lifetime); | 103 const base::TimeDelta& lifetime); |
100 | 104 |
101 // Helper functions that run on main thread. Can be called on any | 105 // Helper functions that run on main thread. Can be called on any |
102 // other thread. | 106 // other thread. |
103 void ConnectInternal(const std::string& uid, | 107 void ConnectInternal(const std::string& uid, |
104 const std::string& auth_token, | 108 const std::string& auth_token, |
(...skipping 21 matching lines...) Expand all Loading... |
126 | 130 |
127 NPP plugin_; | 131 NPP plugin_; |
128 NPObject* parent_; | 132 NPObject* parent_; |
129 int state_; | 133 int state_; |
130 std::string access_code_; | 134 std::string access_code_; |
131 base::TimeDelta access_code_lifetime_; | 135 base::TimeDelta access_code_lifetime_; |
132 NPObject* log_debug_info_func_; | 136 NPObject* log_debug_info_func_; |
133 NPObject* on_state_changed_func_; | 137 NPObject* on_state_changed_func_; |
134 base::PlatformThreadId np_thread_id_; | 138 base::PlatformThreadId np_thread_id_; |
135 | 139 |
136 scoped_ptr<HostPluginLogger> logger_; | |
137 | |
138 scoped_ptr<RegisterSupportHostRequest> register_request_; | 140 scoped_ptr<RegisterSupportHostRequest> register_request_; |
139 scoped_refptr<MutableHostConfig> host_config_; | 141 scoped_refptr<MutableHostConfig> host_config_; |
140 ChromotingHostContext host_context_; | 142 ChromotingHostContext host_context_; |
141 scoped_ptr<DesktopEnvironment> desktop_environment_; | 143 scoped_ptr<DesktopEnvironment> desktop_environment_; |
142 | 144 |
143 scoped_refptr<ChromotingHost> host_; | 145 scoped_refptr<ChromotingHost> host_; |
144 int failed_login_attempts_; | 146 int failed_login_attempts_; |
145 | 147 |
146 base::WaitableEvent disconnected_event_; | 148 base::WaitableEvent disconnected_event_; |
147 base::CancellationFlag destructing_; | 149 base::CancellationFlag destructing_; |
148 }; | 150 }; |
149 | 151 |
150 } // namespace remoting | 152 } // namespace remoting |
151 | 153 |
152 DISABLE_RUNNABLE_METHOD_REFCOUNT(remoting::HostNPScriptObject); | 154 DISABLE_RUNNABLE_METHOD_REFCOUNT(remoting::HostNPScriptObject); |
153 | 155 |
154 #endif // REMOTING_HOST_HOST_SCRIPT_OBJECT_H_ | 156 #endif // REMOTING_HOST_HOST_SCRIPT_OBJECT_H_ |
OLD | NEW |