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

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

Issue 7635012: Host process i18n and Linux implementation. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 4 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 | Annotate | Revision Log
OLDNEW
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 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 remoting::protocol::ConnectionToClient* client) OVERRIDE; 69 remoting::protocol::ConnectionToClient* client) OVERRIDE;
69 virtual void OnClientDisconnected( 70 virtual void OnClientDisconnected(
70 remoting::protocol::ConnectionToClient* client) OVERRIDE; 71 remoting::protocol::ConnectionToClient* client) OVERRIDE;
71 virtual void OnShutdown() OVERRIDE; 72 virtual void OnShutdown() OVERRIDE;
72 73
73 // A Log Message Handler that is called after each LOG message has been 74 // A Log Message Handler that is called after each LOG message has been
74 // processed. This must be of type LogMessageHandlerFunction defined in 75 // processed. This must be of type LogMessageHandlerFunction defined in
75 // base/logging.h. 76 // base/logging.h.
76 static bool LogToUI(int severity, const char* file, int line, 77 static bool LogToUI(int severity, const char* file, int line,
77 size_t message_start, const std::string& str); 78 size_t message_start, const std::string& str);
79
78 private: 80 private:
79 enum State { 81 enum State {
80 kDisconnected, 82 kDisconnected,
81 kRequestedAccessCode, 83 kRequestedAccessCode,
82 kReceivedAccessCode, 84 kReceivedAccessCode,
83 kConnected, 85 kConnected,
84 kAffirmingConnection, 86 kAffirmingConnection,
85 kError 87 kError
86 }; 88 };
87 89
(...skipping 20 matching lines...) Expand all
108 // Helper functions that run on main thread. Can be called on any 110 // Helper functions that run on main thread. Can be called on any
109 // other thread. 111 // other thread.
110 void ConnectInternal(const std::string& uid, 112 void ConnectInternal(const std::string& uid,
111 const std::string& auth_token, 113 const std::string& auth_token,
112 const std::string& auth_service); 114 const std::string& auth_service);
113 void DisconnectInternal(); 115 void DisconnectInternal();
114 116
115 // Callback for ChromotingHost::Shutdown(). 117 // Callback for ChromotingHost::Shutdown().
116 void OnShutdownFinished(); 118 void OnShutdownFinished();
117 119
120 // Helper function for executing InvokeDefault on an NPObject that performs
121 // a string->string mapping with one optional substitution parameter. Stores
122 // the translation in |result| and returns true on success, or leaves it
123 // unchanged and returns false on failure.
Wez 2011/08/13 01:35:32 Would it make more sense to do the substitution ev
Jamie 2011/08/13 02:20:15 The strings have their English translations hard-c
124 bool Localize(const char* tag, const char* parameter, std::string* result);
125
118 // Helper function for executing InvokeDefault on an NPObject, and ignoring 126 // Helper function for executing InvokeDefault on an NPObject, and ignoring
119 // the return value. 127 // the return value.
120 bool InvokeAndIgnoreResult(NPObject* func, 128 bool InvokeAndIgnoreResult(NPObject* func,
121 const NPVariant* args, 129 const NPVariant* args,
122 uint32_t argCount); 130 uint32_t argCount);
123 131
124 // Posts a task on the main NP thread. 132 // Posts a task on the main NP thread.
125 void PostTaskToNPThread( 133 void PostTaskToNPThread(
126 const tracked_objects::Location& from_here, const base::Closure& task); 134 const tracked_objects::Location& from_here, const base::Closure& task);
127 135
128 // Utility function for PostTaskToNPThread. 136 // Utility function for PostTaskToNPThread.
129 static void NPTaskSpringboard(void* task); 137 static void NPTaskSpringboard(void* task);
130 138
131 // Set an exception for the current call. 139 // Set an exception for the current call.
132 void SetException(const std::string& exception_string); 140 void SetException(const std::string& exception_string);
133 141
134 NPP plugin_; 142 NPP plugin_;
135 NPObject* parent_; 143 NPObject* parent_;
136 int state_; 144 int state_;
137 std::string access_code_; 145 std::string access_code_;
138 std::string client_username_; 146 std::string client_username_;
139 base::TimeDelta access_code_lifetime_; 147 base::TimeDelta access_code_lifetime_;
140 NPObject* log_debug_info_func_; 148 scoped_NPObject localize_func_;
141 NPObject* on_state_changed_func_; 149 scoped_NPObject log_debug_info_func_;
150 scoped_NPObject on_state_changed_func_;
142 base::PlatformThreadId np_thread_id_; 151 base::PlatformThreadId np_thread_id_;
143 152
144 scoped_ptr<RegisterSupportHostRequest> register_request_; 153 scoped_ptr<RegisterSupportHostRequest> register_request_;
145 scoped_refptr<MutableHostConfig> host_config_; 154 scoped_refptr<MutableHostConfig> host_config_;
146 ChromotingHostContext host_context_; 155 ChromotingHostContext host_context_;
147 scoped_ptr<DesktopEnvironment> desktop_environment_; 156 scoped_ptr<DesktopEnvironment> desktop_environment_;
148 157
149 scoped_refptr<ChromotingHost> host_; 158 scoped_refptr<ChromotingHost> host_;
150 int failed_login_attempts_; 159 int failed_login_attempts_;
151 160
152 base::WaitableEvent disconnected_event_; 161 base::WaitableEvent disconnected_event_;
153 base::CancellationFlag destructing_; 162 base::CancellationFlag destructing_;
154 }; 163 };
155 164
156 } // namespace remoting 165 } // namespace remoting
157 166
158 DISABLE_RUNNABLE_METHOD_REFCOUNT(remoting::HostNPScriptObject); 167 DISABLE_RUNNABLE_METHOD_REFCOUNT(remoting::HostNPScriptObject);
159 168
160 #endif // REMOTING_HOST_HOST_SCRIPT_OBJECT_H_ 169 #endif // REMOTING_HOST_HOST_SCRIPT_OBJECT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698