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 #include "remoting/host/plugin/host_script_object.h" | 5 #include "remoting/host/plugin/host_script_object.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/message_loop.h" | 8 #include "base/message_loop.h" |
9 #include "base/message_loop_proxy.h" | 9 #include "base/message_loop_proxy.h" |
10 #include "base/sys_string_conversions.h" | 10 #include "base/sys_string_conversions.h" |
11 #include "base/threading/platform_thread.h" | 11 #include "base/threading/platform_thread.h" |
12 #include "base/utf_string_conversions.h" | 12 #include "base/utf_string_conversions.h" |
13 #include "remoting/base/auth_token_util.h" | 13 #include "remoting/base/auth_token_util.h" |
14 #include "remoting/base/util.h" | 14 #include "remoting/base/util.h" |
15 #include "remoting/host/chromoting_host.h" | 15 #include "remoting/host/chromoting_host.h" |
16 #include "remoting/host/chromoting_host_context.h" | 16 #include "remoting/host/chromoting_host_context.h" |
17 #include "remoting/host/desktop_environment.h" | 17 #include "remoting/host/desktop_environment.h" |
18 #include "remoting/host/host_config.h" | 18 #include "remoting/host/host_config.h" |
19 #include "remoting/host/host_key_pair.h" | 19 #include "remoting/host/host_key_pair.h" |
20 #include "remoting/host/in_memory_host_config.h" | 20 #include "remoting/host/in_memory_host_config.h" |
21 #include "remoting/host/plugin/policy_hack/nat_policy.h" | 21 #include "remoting/host/plugin/policy_hack/nat_policy.h" |
22 #include "remoting/host/register_support_host_request.h" | 22 #include "remoting/host/register_support_host_request.h" |
23 #include "remoting/host/support_access_verifier.h" | 23 #include "remoting/host/support_access_verifier.h" |
24 #include "remoting/host/ui_strings.h" | |
25 | 24 |
26 namespace remoting { | 25 namespace remoting { |
27 | 26 |
28 // Supported Javascript interface: | 27 // Supported Javascript interface: |
29 // readonly attribute string accessCode; | 28 // readonly attribute string accessCode; |
30 // readonly attribute int accessCodeLifetime; | 29 // readonly attribute int accessCodeLifetime; |
31 // readonly attribute string client; | 30 // readonly attribute string client; |
32 // readonly attribute int state; | 31 // readonly attribute int state; |
33 // | 32 // |
34 // state: { | 33 // state: { |
35 // DISCONNECTED, | 34 // DISCONNECTED, |
36 // REQUESTED_ACCESS_CODE, | 35 // REQUESTED_ACCESS_CODE, |
37 // RECEIVED_ACCESS_CODE, | 36 // RECEIVED_ACCESS_CODE, |
38 // CONNECTED, | 37 // CONNECTED, |
39 // AFFIRMING_CONNECTION, | 38 // AFFIRMING_CONNECTION, |
40 // ERROR, | 39 // ERROR, |
41 // } | 40 // } |
42 // | 41 // |
43 // attribute Function void logDebugInfo(string); | 42 // attribute Function void logDebugInfo(string); |
44 // attribute Function void onStateChanged(); | 43 // attribute Function void onStateChanged(); |
45 // attribute Function string localizeString(string,...); | 44 // attribute Function string localizeString(string,...); |
Sergey Ulanov
2011/08/29 23:43:32
Please update this comment
Lambros
2011/08/30 00:39:20
Done.
| |
46 // | 45 // |
47 // // The |auth_service_with_token| parameter should be in the format | 46 // // The |auth_service_with_token| parameter should be in the format |
48 // // "auth_service:auth_token". An example would be "oauth2:1/2a3912vd". | 47 // // "auth_service:auth_token". An example would be "oauth2:1/2a3912vd". |
49 // void connect(string uid, string auth_service_with_token); | 48 // void connect(string uid, string auth_service_with_token); |
50 // void disconnect(); | 49 // void disconnect(); |
51 | 50 |
52 namespace { | 51 namespace { |
53 | 52 |
54 const char* kAttrNameAccessCode = "accessCode"; | 53 const char* kAttrNameAccessCode = "accessCode"; |
55 const char* kAttrNameAccessCodeLifetime = "accessCodeLifetime"; | 54 const char* kAttrNameAccessCodeLifetime = "accessCodeLifetime"; |
56 const char* kAttrNameClient = "client"; | 55 const char* kAttrNameClient = "client"; |
57 const char* kAttrNameState = "state"; | 56 const char* kAttrNameState = "state"; |
58 const char* kAttrNameLocalizeString = "localizeString"; | |
59 const char* kAttrNameLogDebugInfo = "logDebugInfo"; | 57 const char* kAttrNameLogDebugInfo = "logDebugInfo"; |
60 const char* kAttrNameOnStateChanged = "onStateChanged"; | 58 const char* kAttrNameOnStateChanged = "onStateChanged"; |
61 const char* kFuncNameConnect = "connect"; | 59 const char* kFuncNameConnect = "connect"; |
62 const char* kFuncNameDisconnect = "disconnect"; | 60 const char* kFuncNameDisconnect = "disconnect"; |
61 const char* kFuncNameLocalize = "localize"; | |
63 | 62 |
64 // States. | 63 // States. |
65 const char* kAttrNameDisconnected = "DISCONNECTED"; | 64 const char* kAttrNameDisconnected = "DISCONNECTED"; |
66 const char* kAttrNameRequestedAccessCode = "REQUESTED_ACCESS_CODE"; | 65 const char* kAttrNameRequestedAccessCode = "REQUESTED_ACCESS_CODE"; |
67 const char* kAttrNameReceivedAccessCode = "RECEIVED_ACCESS_CODE"; | 66 const char* kAttrNameReceivedAccessCode = "RECEIVED_ACCESS_CODE"; |
68 const char* kAttrNameConnected = "CONNECTED"; | 67 const char* kAttrNameConnected = "CONNECTED"; |
69 const char* kAttrNameAffirmingConnection = "AFFIRMING_CONNECTION"; | 68 const char* kAttrNameAffirmingConnection = "AFFIRMING_CONNECTION"; |
70 const char* kAttrNameError = "ERROR"; | 69 const char* kAttrNameError = "ERROR"; |
71 | 70 |
72 const int kMaxLoginAttempts = 5; | 71 const int kMaxLoginAttempts = 5; |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
151 nat_policy_->StartWatching( | 150 nat_policy_->StartWatching( |
152 base::Bind(&HostNPScriptObject::OnNatPolicyUpdate, | 151 base::Bind(&HostNPScriptObject::OnNatPolicyUpdate, |
153 base::Unretained(this))); | 152 base::Unretained(this))); |
154 return true; | 153 return true; |
155 } | 154 } |
156 | 155 |
157 bool HostNPScriptObject::HasMethod(const std::string& method_name) { | 156 bool HostNPScriptObject::HasMethod(const std::string& method_name) { |
158 VLOG(2) << "HasMethod " << method_name; | 157 VLOG(2) << "HasMethod " << method_name; |
159 CHECK_EQ(base::PlatformThread::CurrentId(), np_thread_id_); | 158 CHECK_EQ(base::PlatformThread::CurrentId(), np_thread_id_); |
160 return (method_name == kFuncNameConnect || | 159 return (method_name == kFuncNameConnect || |
161 method_name == kFuncNameDisconnect); | 160 method_name == kFuncNameDisconnect || |
161 method_name == kFuncNameLocalize); | |
162 } | 162 } |
163 | 163 |
164 bool HostNPScriptObject::InvokeDefault(const NPVariant* args, | 164 bool HostNPScriptObject::InvokeDefault(const NPVariant* args, |
165 uint32_t argCount, | 165 uint32_t argCount, |
166 NPVariant* result) { | 166 NPVariant* result) { |
167 VLOG(2) << "InvokeDefault"; | 167 VLOG(2) << "InvokeDefault"; |
168 CHECK_EQ(base::PlatformThread::CurrentId(), np_thread_id_); | 168 CHECK_EQ(base::PlatformThread::CurrentId(), np_thread_id_); |
169 SetException("exception during default invocation"); | 169 SetException("exception during default invocation"); |
170 return false; | 170 return false; |
171 } | 171 } |
172 | 172 |
173 bool HostNPScriptObject::Invoke(const std::string& method_name, | 173 bool HostNPScriptObject::Invoke(const std::string& method_name, |
174 const NPVariant* args, | 174 const NPVariant* args, |
175 uint32_t argCount, | 175 uint32_t argCount, |
176 NPVariant* result) { | 176 NPVariant* result) { |
177 VLOG(2) << "Invoke " << method_name; | 177 VLOG(2) << "Invoke " << method_name; |
178 CHECK_EQ(base::PlatformThread::CurrentId(), np_thread_id_); | 178 CHECK_EQ(base::PlatformThread::CurrentId(), np_thread_id_); |
179 if (method_name == kFuncNameConnect) { | 179 if (method_name == kFuncNameConnect) { |
180 return Connect(args, argCount, result); | 180 return Connect(args, argCount, result); |
181 } else if (method_name == kFuncNameDisconnect) { | 181 } else if (method_name == kFuncNameDisconnect) { |
182 return Disconnect(args, argCount, result); | 182 return Disconnect(args, argCount, result); |
183 } else if (method_name == kFuncNameLocalize) { | |
184 return Localize(args, argCount, result); | |
183 } else { | 185 } else { |
184 SetException("Invoke: unknown method " + method_name); | 186 SetException("Invoke: unknown method " + method_name); |
185 return false; | 187 return false; |
186 } | 188 } |
187 } | 189 } |
188 | 190 |
189 bool HostNPScriptObject::HasProperty(const std::string& property_name) { | 191 bool HostNPScriptObject::HasProperty(const std::string& property_name) { |
190 VLOG(2) << "HasProperty " << property_name; | 192 VLOG(2) << "HasProperty " << property_name; |
191 CHECK_EQ(base::PlatformThread::CurrentId(), np_thread_id_); | 193 CHECK_EQ(base::PlatformThread::CurrentId(), np_thread_id_); |
192 return (property_name == kAttrNameAccessCode || | 194 return (property_name == kAttrNameAccessCode || |
193 property_name == kAttrNameAccessCodeLifetime || | 195 property_name == kAttrNameAccessCodeLifetime || |
194 property_name == kAttrNameClient || | 196 property_name == kAttrNameClient || |
195 property_name == kAttrNameState || | 197 property_name == kAttrNameState || |
196 property_name == kAttrNameLocalizeString || | |
197 property_name == kAttrNameLogDebugInfo || | 198 property_name == kAttrNameLogDebugInfo || |
198 property_name == kAttrNameOnStateChanged || | 199 property_name == kAttrNameOnStateChanged || |
199 property_name == kAttrNameDisconnected || | 200 property_name == kAttrNameDisconnected || |
200 property_name == kAttrNameRequestedAccessCode || | 201 property_name == kAttrNameRequestedAccessCode || |
201 property_name == kAttrNameReceivedAccessCode || | 202 property_name == kAttrNameReceivedAccessCode || |
202 property_name == kAttrNameConnected || | 203 property_name == kAttrNameConnected || |
203 property_name == kAttrNameAffirmingConnection || | 204 property_name == kAttrNameAffirmingConnection || |
204 property_name == kAttrNameError); | 205 property_name == kAttrNameError); |
205 } | 206 } |
206 | 207 |
207 bool HostNPScriptObject::GetProperty(const std::string& property_name, | 208 bool HostNPScriptObject::GetProperty(const std::string& property_name, |
208 NPVariant* result) { | 209 NPVariant* result) { |
209 VLOG(2) << "GetProperty " << property_name; | 210 VLOG(2) << "GetProperty " << property_name; |
210 CHECK_EQ(base::PlatformThread::CurrentId(), np_thread_id_); | 211 CHECK_EQ(base::PlatformThread::CurrentId(), np_thread_id_); |
211 if (!result) { | 212 if (!result) { |
212 SetException("GetProperty: NULL result"); | 213 SetException("GetProperty: NULL result"); |
213 return false; | 214 return false; |
214 } | 215 } |
215 | 216 |
216 if (property_name == kAttrNameOnStateChanged) { | 217 if (property_name == kAttrNameOnStateChanged) { |
217 OBJECT_TO_NPVARIANT(on_state_changed_func_.get(), *result); | 218 OBJECT_TO_NPVARIANT(on_state_changed_func_.get(), *result); |
218 return true; | 219 return true; |
219 } else if (property_name == kAttrNameLocalizeString) { | |
220 OBJECT_TO_NPVARIANT(localize_func_.get(), *result); | |
221 return true; | |
222 } else if (property_name == kAttrNameLogDebugInfo) { | 220 } else if (property_name == kAttrNameLogDebugInfo) { |
223 OBJECT_TO_NPVARIANT(log_debug_info_func_.get(), *result); | 221 OBJECT_TO_NPVARIANT(log_debug_info_func_.get(), *result); |
224 return true; | 222 return true; |
225 } else if (property_name == kAttrNameState) { | 223 } else if (property_name == kAttrNameState) { |
226 INT32_TO_NPVARIANT(state_, *result); | 224 INT32_TO_NPVARIANT(state_, *result); |
227 return true; | 225 return true; |
228 } else if (property_name == kAttrNameAccessCode) { | 226 } else if (property_name == kAttrNameAccessCode) { |
229 *result = NPVariantFromString(access_code_); | 227 *result = NPVariantFromString(access_code_); |
230 return true; | 228 return true; |
231 } else if (property_name == kAttrNameAccessCodeLifetime) { | 229 } else if (property_name == kAttrNameAccessCodeLifetime) { |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
267 if (NPVARIANT_IS_OBJECT(*value)) { | 265 if (NPVARIANT_IS_OBJECT(*value)) { |
268 on_state_changed_func_ = NPVARIANT_TO_OBJECT(*value); | 266 on_state_changed_func_ = NPVARIANT_TO_OBJECT(*value); |
269 return true; | 267 return true; |
270 } else { | 268 } else { |
271 SetException("SetProperty: unexpected type for property " + | 269 SetException("SetProperty: unexpected type for property " + |
272 property_name); | 270 property_name); |
273 } | 271 } |
274 return false; | 272 return false; |
275 } | 273 } |
276 | 274 |
277 if (property_name == kAttrNameLocalizeString) { | |
278 if (NPVARIANT_IS_OBJECT(*value)) { | |
279 localize_func_ = NPVARIANT_TO_OBJECT(*value); | |
280 return true; | |
281 } else { | |
282 SetException("SetProperty: unexpected type for property " + | |
283 property_name); | |
284 } | |
285 return false; | |
286 } | |
287 | |
288 if (property_name == kAttrNameLogDebugInfo) { | 275 if (property_name == kAttrNameLogDebugInfo) { |
289 if (NPVARIANT_IS_OBJECT(*value)) { | 276 if (NPVARIANT_IS_OBJECT(*value)) { |
290 log_debug_info_func_ = NPVARIANT_TO_OBJECT(*value); | 277 log_debug_info_func_ = NPVARIANT_TO_OBJECT(*value); |
291 return true; | 278 return true; |
292 } else { | 279 } else { |
293 SetException("SetProperty: unexpected type for property " + | 280 SetException("SetProperty: unexpected type for property " + |
294 property_name); | 281 property_name); |
295 } | 282 } |
296 return false; | 283 return false; |
297 } | 284 } |
298 | 285 |
299 return false; | 286 return false; |
300 } | 287 } |
301 | 288 |
302 bool HostNPScriptObject::RemoveProperty(const std::string& property_name) { | 289 bool HostNPScriptObject::RemoveProperty(const std::string& property_name) { |
303 VLOG(2) << "RemoveProperty " << property_name; | 290 VLOG(2) << "RemoveProperty " << property_name; |
304 CHECK_EQ(base::PlatformThread::CurrentId(), np_thread_id_); | 291 CHECK_EQ(base::PlatformThread::CurrentId(), np_thread_id_); |
305 return false; | 292 return false; |
306 } | 293 } |
307 | 294 |
308 bool HostNPScriptObject::Enumerate(std::vector<std::string>* values) { | 295 bool HostNPScriptObject::Enumerate(std::vector<std::string>* values) { |
309 VLOG(2) << "Enumerate"; | 296 VLOG(2) << "Enumerate"; |
310 CHECK_EQ(base::PlatformThread::CurrentId(), np_thread_id_); | 297 CHECK_EQ(base::PlatformThread::CurrentId(), np_thread_id_); |
311 const char* entries[] = { | 298 const char* entries[] = { |
312 kAttrNameAccessCode, | 299 kAttrNameAccessCode, |
313 kAttrNameState, | 300 kAttrNameState, |
314 kAttrNameLocalizeString, | |
315 kAttrNameLogDebugInfo, | 301 kAttrNameLogDebugInfo, |
316 kAttrNameOnStateChanged, | 302 kAttrNameOnStateChanged, |
317 kFuncNameConnect, | 303 kFuncNameConnect, |
318 kFuncNameDisconnect, | 304 kFuncNameDisconnect, |
305 kFuncNameLocalize, | |
319 kAttrNameDisconnected, | 306 kAttrNameDisconnected, |
320 kAttrNameRequestedAccessCode, | 307 kAttrNameRequestedAccessCode, |
321 kAttrNameReceivedAccessCode, | 308 kAttrNameReceivedAccessCode, |
322 kAttrNameConnected, | 309 kAttrNameConnected, |
323 kAttrNameAffirmingConnection, | 310 kAttrNameAffirmingConnection, |
324 kAttrNameError | 311 kAttrNameError |
325 }; | 312 }; |
326 for (size_t i = 0; i < arraysize(entries); ++i) { | 313 for (size_t i = 0; i < arraysize(entries); ++i) { |
327 values->push_back(entries[i]); | 314 values->push_back(entries[i]); |
328 } | 315 } |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
476 | 463 |
477 // Create the Host. | 464 // Create the Host. |
478 LOG(INFO) << "Connecting with NAT state: " << nat_traversal_enabled_; | 465 LOG(INFO) << "Connecting with NAT state: " << nat_traversal_enabled_; |
479 host_ = ChromotingHost::Create( | 466 host_ = ChromotingHost::Create( |
480 &host_context_, host_config_, desktop_environment_.get(), | 467 &host_context_, host_config_, desktop_environment_.get(), |
481 access_verifier.release(), nat_traversal_enabled_); | 468 access_verifier.release(), nat_traversal_enabled_); |
482 host_->AddStatusObserver(this); | 469 host_->AddStatusObserver(this); |
483 host_->AddStatusObserver(register_request_.get()); | 470 host_->AddStatusObserver(register_request_.get()); |
484 host_->set_it2me(true); | 471 host_->set_it2me(true); |
485 | 472 |
486 LocalizeStrings(); | 473 { |
474 base::AutoLock auto_lock(ui_strings_lock_); | |
475 host_->SetUiStrings(ui_strings_); | |
476 } | |
487 | 477 |
488 // Start the Host. | 478 // Start the Host. |
489 host_->Start(); | 479 host_->Start(); |
490 | 480 |
491 OnStateChanged(kRequestedAccessCode); | 481 OnStateChanged(kRequestedAccessCode); |
492 return; | 482 return; |
493 } | 483 } |
494 | 484 |
495 bool HostNPScriptObject::Disconnect(const NPVariant* args, | 485 bool HostNPScriptObject::Disconnect(const NPVariant* args, |
496 uint32_t arg_count, | 486 uint32_t arg_count, |
497 NPVariant* result) { | 487 NPVariant* result) { |
498 CHECK_EQ(base::PlatformThread::CurrentId(), np_thread_id_); | 488 CHECK_EQ(base::PlatformThread::CurrentId(), np_thread_id_); |
499 if (arg_count != 0) { | 489 if (arg_count != 0) { |
500 SetException("disconnect: bad number of arguments"); | 490 SetException("disconnect: bad number of arguments"); |
501 return false; | 491 return false; |
502 } | 492 } |
503 | 493 |
504 DisconnectInternal(); | 494 DisconnectInternal(); |
505 | 495 |
506 return true; | 496 return true; |
507 } | 497 } |
508 | 498 |
499 bool HostNPScriptObject::Localize(const NPVariant* args, | |
500 uint32_t arg_count, | |
501 NPVariant* result) { | |
502 CHECK_EQ(base::PlatformThread::CurrentId(), np_thread_id_); | |
503 if (arg_count != 1) { | |
504 SetException("localize: bad number of arguments"); | |
505 return false; | |
506 } | |
507 | |
508 if (NPVARIANT_IS_OBJECT(args[0])) { | |
509 localize_func_ = NPVARIANT_TO_OBJECT(args[0]); | |
Sergey Ulanov
2011/08/29 23:43:32
localize_func_ doesn't need to be member anymore.
Lambros
2011/08/30 00:39:20
Done.
| |
510 LocalizeStrings(); | |
511 return true; | |
512 } else { | |
513 SetException("localize: unexpected type for argument 1"); | |
514 return false; | |
515 } | |
516 } | |
517 | |
509 void HostNPScriptObject::DisconnectInternal() { | 518 void HostNPScriptObject::DisconnectInternal() { |
510 if (MessageLoop::current() != host_context_.main_message_loop()) { | 519 if (MessageLoop::current() != host_context_.main_message_loop()) { |
511 host_context_.main_message_loop()->PostTask( | 520 host_context_.main_message_loop()->PostTask( |
512 FROM_HERE, base::Bind(&HostNPScriptObject::DisconnectInternal, | 521 FROM_HERE, base::Bind(&HostNPScriptObject::DisconnectInternal, |
513 base::Unretained(this))); | 522 base::Unretained(this))); |
514 return; | 523 return; |
515 } | 524 } |
516 | 525 |
517 if (!host_) { | 526 if (!host_) { |
518 disconnected_event_.Signal(); | 527 disconnected_event_.Signal(); |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
639 } | 648 } |
640 } | 649 } |
641 | 650 |
642 void HostNPScriptObject::SetException(const std::string& exception_string) { | 651 void HostNPScriptObject::SetException(const std::string& exception_string) { |
643 CHECK_EQ(base::PlatformThread::CurrentId(), np_thread_id_); | 652 CHECK_EQ(base::PlatformThread::CurrentId(), np_thread_id_); |
644 g_npnetscape_funcs->setexception(parent_, exception_string.c_str()); | 653 g_npnetscape_funcs->setexception(parent_, exception_string.c_str()); |
645 LOG(INFO) << exception_string; | 654 LOG(INFO) << exception_string; |
646 } | 655 } |
647 | 656 |
648 void HostNPScriptObject::LocalizeStrings() { | 657 void HostNPScriptObject::LocalizeStrings() { |
658 DCHECK(plugin_message_loop_proxy_->BelongsToCurrentThread()); | |
659 | |
649 UiStrings ui_strings; | 660 UiStrings ui_strings; |
650 string16 direction; | 661 string16 direction; |
651 LocalizeString("@@bidi_dir", &direction); | 662 LocalizeString("@@bidi_dir", &direction); |
652 ui_strings.direction = UTF16ToUTF8(direction) == "rtl" ? | 663 ui_strings.direction = UTF16ToUTF8(direction) == "rtl" ? |
653 remoting::UiStrings::RTL : remoting::UiStrings::LTR; | 664 remoting::UiStrings::RTL : remoting::UiStrings::LTR; |
654 LocalizeString(/*i18n-content*/"PRODUCT_NAME", &ui_strings.product_name); | 665 LocalizeString(/*i18n-content*/"PRODUCT_NAME", &ui_strings.product_name); |
655 LocalizeString(/*i18n-content*/"DISCONNECT_BUTTON", | 666 LocalizeString(/*i18n-content*/"DISCONNECT_BUTTON", |
656 &ui_strings.disconnect_button_text); | 667 &ui_strings.disconnect_button_text); |
657 LocalizeString( | 668 LocalizeString( |
658 #if defined(OS_WIN) | 669 #if defined(OS_WIN) |
659 /*i18n-content*/"DISCONNECT_BUTTON_PLUS_SHORTCUT_WINDOWS", | 670 /*i18n-content*/"DISCONNECT_BUTTON_PLUS_SHORTCUT_WINDOWS", |
660 #elif defined(OS_MAC) | 671 #elif defined(OS_MAC) |
661 /*i18n-content*/"DISCONNECT_BUTTON_PLUS_SHORTCUT_MAC_OS_X", | 672 /*i18n-content*/"DISCONNECT_BUTTON_PLUS_SHORTCUT_MAC_OS_X", |
662 #else | 673 #else |
663 /*i18n-content*/"DISCONNECT_BUTTON_PLUS_SHORTCUT_LINUX", | 674 /*i18n-content*/"DISCONNECT_BUTTON_PLUS_SHORTCUT_LINUX", |
664 #endif | 675 #endif |
665 &ui_strings.disconnect_button_text_plus_shortcut); | 676 &ui_strings.disconnect_button_text_plus_shortcut); |
666 LocalizeString(/*i18n-content*/"CONTINUE_PROMPT", | 677 LocalizeString(/*i18n-content*/"CONTINUE_PROMPT", |
667 &ui_strings.continue_prompt); | 678 &ui_strings.continue_prompt); |
668 LocalizeString(/*i18n-content*/"CONTINUE_BUTTON", | 679 LocalizeString(/*i18n-content*/"CONTINUE_BUTTON", |
669 &ui_strings.continue_button_text); | 680 &ui_strings.continue_button_text); |
670 LocalizeString(/*i18n-content*/"STOP_SHARING_BUTTON", | 681 LocalizeString(/*i18n-content*/"STOP_SHARING_BUTTON", |
671 &ui_strings.stop_sharing_button_text); | 682 &ui_strings.stop_sharing_button_text); |
672 LocalizeString(/*i18n-content*/"MESSAGE_SHARED", | 683 LocalizeString(/*i18n-content*/"MESSAGE_SHARED", |
673 &ui_strings.disconnect_message); | 684 &ui_strings.disconnect_message); |
674 | 685 |
675 host_->SetUiStrings(ui_strings); | 686 base::AutoLock auto_lock(ui_strings_lock_); |
687 ui_strings_ = ui_strings; | |
676 } | 688 } |
677 | 689 |
678 bool HostNPScriptObject::LocalizeString(const char* tag, string16* result) { | 690 bool HostNPScriptObject::LocalizeString(const char* tag, string16* result) { |
679 NPVariant args[2]; | 691 NPVariant args[2]; |
680 STRINGZ_TO_NPVARIANT(tag, args[0]); | 692 STRINGZ_TO_NPVARIANT(tag, args[0]); |
681 NPVariant np_result; | 693 NPVariant np_result; |
682 bool is_good = g_npnetscape_funcs->invokeDefault( | 694 bool is_good = g_npnetscape_funcs->invokeDefault( |
683 plugin_, localize_func_.get(), &args[0], 1, &np_result); | 695 plugin_, localize_func_.get(), &args[0], 1, &np_result); |
684 if (!is_good) { | 696 if (!is_good) { |
685 LOG(ERROR) << "Localization failed for " << tag; | 697 LOG(ERROR) << "Localization failed for " << tag; |
(...skipping 14 matching lines...) Expand all Loading... | |
700 uint32_t argCount) { | 712 uint32_t argCount) { |
701 NPVariant np_result; | 713 NPVariant np_result; |
702 bool is_good = g_npnetscape_funcs->invokeDefault(plugin_, func, args, | 714 bool is_good = g_npnetscape_funcs->invokeDefault(plugin_, func, args, |
703 argCount, &np_result); | 715 argCount, &np_result); |
704 if (is_good) | 716 if (is_good) |
705 g_npnetscape_funcs->releasevariantvalue(&np_result); | 717 g_npnetscape_funcs->releasevariantvalue(&np_result); |
706 return is_good; | 718 return is_good; |
707 } | 719 } |
708 | 720 |
709 } // namespace remoting | 721 } // namespace remoting |
OLD | NEW |