OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/json/json_reader.h" | 8 #include "base/json/json_reader.h" |
9 #include "base/json/json_writer.h" | 9 #include "base/json/json_writer.h" |
10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
(...skipping 627 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
638 | 638 |
639 HostNPScriptObject::HostNPScriptObject( | 639 HostNPScriptObject::HostNPScriptObject( |
640 NPP plugin, | 640 NPP plugin, |
641 NPObject* parent, | 641 NPObject* parent, |
642 scoped_refptr<AutoThreadTaskRunner> plugin_task_runner) | 642 scoped_refptr<AutoThreadTaskRunner> plugin_task_runner) |
643 : plugin_(plugin), | 643 : plugin_(plugin), |
644 parent_(parent), | 644 parent_(parent), |
645 plugin_task_runner_(plugin_task_runner), | 645 plugin_task_runner_(plugin_task_runner), |
646 am_currently_logging_(false), | 646 am_currently_logging_(false), |
647 state_(kDisconnected), | 647 state_(kDisconnected), |
648 daemon_controller_(DaemonController::Create()), | |
649 weak_factory_(this), | 648 weak_factory_(this), |
650 weak_ptr_(weak_factory_.GetWeakPtr()) { | 649 weak_ptr_(weak_factory_.GetWeakPtr()) { |
651 DCHECK(plugin_task_runner_->BelongsToCurrentThread()); | 650 DCHECK(plugin_task_runner_->BelongsToCurrentThread()); |
652 | 651 |
653 // Set the thread task runner for the plugin thread so that timers and other | 652 // Set the thread task runner for the plugin thread so that timers and other |
654 // code using |base::ThreadTaskRunnerHandle| could be used on the plugin | 653 // code using |base::ThreadTaskRunnerHandle| could be used on the plugin |
655 // thread. | 654 // thread. |
656 // | 655 // |
657 // If component build is used, Chrome and the plugin may end up sharing base | 656 // If component build is used, Chrome and the plugin may end up sharing base |
658 // binary. This means that the instance of |base::ThreadTaskRunnerHandle| | 657 // binary. This means that the instance of |base::ThreadTaskRunnerHandle| |
659 // created by Chrome for the current thread is shared as well. This routinely | 658 // created by Chrome for the current thread is shared as well. This routinely |
660 // happens in the development setting so the below check for | 659 // happens in the development setting so the below check for |
661 // |!base::ThreadTaskRunnerHandle::IsSet()| is a hack/workaround allowing this | 660 // |!base::ThreadTaskRunnerHandle::IsSet()| is a hack/workaround allowing this |
662 // configuration to work. It lets the plugin to access Chrome's message loop | 661 // configuration to work. It lets the plugin to access Chrome's message loop |
663 // directly via |base::ThreadTaskRunnerHandle|. This is safe as long as both | 662 // directly via |base::ThreadTaskRunnerHandle|. This is safe as long as both |
664 // Chrome and the plugin are built from the same version of the sources. | 663 // Chrome and the plugin are built from the same version of the sources. |
665 if (!base::ThreadTaskRunnerHandle::IsSet()) { | 664 if (!base::ThreadTaskRunnerHandle::IsSet()) { |
666 plugin_task_runner_handle_.reset( | 665 plugin_task_runner_handle_.reset( |
667 new base::ThreadTaskRunnerHandle(plugin_task_runner_)); | 666 new base::ThreadTaskRunnerHandle(plugin_task_runner_)); |
668 } | 667 } |
669 | 668 |
669 daemon_controller_ = DaemonController::Create(); | |
670 | |
670 ServiceUrls* service_urls = ServiceUrls::GetInstance(); | 671 ServiceUrls* service_urls = ServiceUrls::GetInstance(); |
671 bool xmpp_server_valid = net::ParseHostAndPort( | 672 bool xmpp_server_valid = net::ParseHostAndPort( |
672 service_urls->xmpp_server_address(), | 673 service_urls->xmpp_server_address(), |
673 &xmpp_server_config_.host, &xmpp_server_config_.port); | 674 &xmpp_server_config_.host, &xmpp_server_config_.port); |
674 // For the plugin, this is always the default address, which must be valid. | 675 // For the plugin, this is always the default address, which must be valid. |
675 DCHECK(xmpp_server_valid); | 676 DCHECK(xmpp_server_valid); |
676 xmpp_server_config_.use_tls = service_urls->xmpp_server_use_tls(); | 677 xmpp_server_config_.use_tls = service_urls->xmpp_server_use_tls(); |
677 directory_bot_jid_ = service_urls->directory_bot_jid(); | 678 directory_bot_jid_ = service_urls->directory_bot_jid(); |
678 | 679 |
679 // Create worker thread for encryption key generation and loading the paired | 680 // Create worker thread for encryption key generation and loading the paired |
(...skipping 568 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1248 return false; | 1249 return false; |
1249 } | 1250 } |
1250 | 1251 |
1251 if (config_dict->HasKey(kHostIdConfigPath) || | 1252 if (config_dict->HasKey(kHostIdConfigPath) || |
1252 config_dict->HasKey(kXmppLoginConfigPath)) { | 1253 config_dict->HasKey(kXmppLoginConfigPath)) { |
1253 SetException("updateDaemonConfig: trying to update immutable config " | 1254 SetException("updateDaemonConfig: trying to update immutable config " |
1254 "parameters"); | 1255 "parameters"); |
1255 return false; | 1256 return false; |
1256 } | 1257 } |
1257 | 1258 |
1258 // TODO(wez): Pass a static method here, that will post the result | |
1259 // back to us on the right thread (crbug.com/156257). | |
1260 daemon_controller_->UpdateConfig( | 1259 daemon_controller_->UpdateConfig( |
1261 config_dict.Pass(), | 1260 config_dict.Pass(), |
1262 base::Bind(&HostNPScriptObject::InvokeAsyncResultCallback, | 1261 base::Bind(&HostNPScriptObject::InvokeAsyncResultCallback, |
1263 base::Unretained(this), callback_obj)); | 1262 base::Unretained(this), callback_obj)); |
1264 return true; | 1263 return true; |
1265 } | 1264 } |
1266 | 1265 |
1267 bool HostNPScriptObject::GetDaemonConfig(const NPVariant* args, | 1266 bool HostNPScriptObject::GetDaemonConfig(const NPVariant* args, |
1268 uint32_t arg_count, | 1267 uint32_t arg_count, |
1269 NPVariant* result) { | 1268 NPVariant* result) { |
1270 if (arg_count != 1) { | 1269 if (arg_count != 1) { |
1271 SetException("getDaemonConfig: bad number of arguments"); | 1270 SetException("getDaemonConfig: bad number of arguments"); |
1272 return false; | 1271 return false; |
1273 } | 1272 } |
1274 | 1273 |
1275 ScopedRefNPObject callback_obj(ObjectFromNPVariant(args[0])); | 1274 ScopedRefNPObject callback_obj(ObjectFromNPVariant(args[0])); |
1276 if (!callback_obj.get()) { | 1275 if (!callback_obj.get()) { |
1277 SetException("getDaemonConfig: invalid callback parameter"); | 1276 SetException("getDaemonConfig: invalid callback parameter"); |
1278 return false; | 1277 return false; |
1279 } | 1278 } |
1280 | 1279 |
1281 // TODO(wez): Pass a static method here, that will post the result | |
1282 // back to us on the right thread (crbug.com/156257). | |
1283 daemon_controller_->GetConfig( | 1280 daemon_controller_->GetConfig( |
1284 base::Bind(&HostNPScriptObject::InvokeGetDaemonConfigCallback, | 1281 base::Bind(&HostNPScriptObject::InvokeGetDaemonConfigCallback, |
1285 base::Unretained(this), callback_obj)); | 1282 base::Unretained(this), callback_obj)); |
1286 | 1283 |
1287 return true; | 1284 return true; |
1288 } | 1285 } |
1289 | 1286 |
1290 bool HostNPScriptObject::GetDaemonVersion(const NPVariant* args, | 1287 bool HostNPScriptObject::GetDaemonVersion(const NPVariant* args, |
1291 uint32_t arg_count, | 1288 uint32_t arg_count, |
1292 NPVariant* result) { | 1289 NPVariant* result) { |
1293 if (arg_count != 1) { | 1290 if (arg_count != 1) { |
1294 SetException("getDaemonVersion: bad number of arguments"); | 1291 SetException("getDaemonVersion: bad number of arguments"); |
1295 return false; | 1292 return false; |
1296 } | 1293 } |
1297 | 1294 |
1298 ScopedRefNPObject callback_obj(ObjectFromNPVariant(args[0])); | 1295 ScopedRefNPObject callback_obj(ObjectFromNPVariant(args[0])); |
1299 if (!callback_obj.get()) { | 1296 if (!callback_obj.get()) { |
1300 SetException("getDaemonVersion: invalid callback parameter"); | 1297 SetException("getDaemonVersion: invalid callback parameter"); |
1301 return false; | 1298 return false; |
1302 } | 1299 } |
1303 | 1300 |
1304 // TODO(wez): Pass a static method here, that will post the result | |
1305 // back to us on the right thread (crbug.com/156257). | |
1306 daemon_controller_->GetVersion( | 1301 daemon_controller_->GetVersion( |
1307 base::Bind(&HostNPScriptObject::InvokeGetDaemonVersionCallback, | 1302 base::Bind(&HostNPScriptObject::InvokeGetDaemonVersionCallback, |
1308 base::Unretained(this), callback_obj)); | 1303 base::Unretained(this), callback_obj)); |
1309 | 1304 |
1310 return true; | 1305 return true; |
1311 } | 1306 } |
1312 | 1307 |
1313 bool HostNPScriptObject::GetPairedClients(const NPVariant* args, | 1308 bool HostNPScriptObject::GetPairedClients(const NPVariant* args, |
1314 uint32_t arg_count, | 1309 uint32_t arg_count, |
1315 NPVariant* result) { | 1310 NPVariant* result) { |
(...skipping 26 matching lines...) Expand all Loading... | |
1342 SetException("getUsageStatsConsent: bad number of arguments"); | 1337 SetException("getUsageStatsConsent: bad number of arguments"); |
1343 return false; | 1338 return false; |
1344 } | 1339 } |
1345 | 1340 |
1346 ScopedRefNPObject callback_obj(ObjectFromNPVariant(args[0])); | 1341 ScopedRefNPObject callback_obj(ObjectFromNPVariant(args[0])); |
1347 if (!callback_obj.get()) { | 1342 if (!callback_obj.get()) { |
1348 SetException("getUsageStatsConsent: invalid callback parameter"); | 1343 SetException("getUsageStatsConsent: invalid callback parameter"); |
1349 return false; | 1344 return false; |
1350 } | 1345 } |
1351 | 1346 |
1352 // TODO(wez): Pass a static method here, that will post the result | |
1353 // back to us on the right thread (crbug.com/156257). | |
1354 daemon_controller_->GetUsageStatsConsent( | 1347 daemon_controller_->GetUsageStatsConsent( |
1355 base::Bind(&HostNPScriptObject::InvokeGetUsageStatsConsentCallback, | 1348 base::Bind(&HostNPScriptObject::InvokeGetUsageStatsConsentCallback, |
1356 base::Unretained(this), callback_obj)); | 1349 base::Unretained(this), callback_obj)); |
1357 return true; | 1350 return true; |
1358 } | 1351 } |
1359 | 1352 |
1360 bool HostNPScriptObject::StartDaemon(const NPVariant* args, | 1353 bool HostNPScriptObject::StartDaemon(const NPVariant* args, |
1361 uint32_t arg_count, | 1354 uint32_t arg_count, |
1362 NPVariant* result) { | 1355 NPVariant* result) { |
1363 DCHECK(plugin_task_runner_->BelongsToCurrentThread()); | 1356 DCHECK(plugin_task_runner_->BelongsToCurrentThread()); |
(...skipping 18 matching lines...) Expand all Loading... | |
1382 SetException("startDaemon: invalid consent parameter"); | 1375 SetException("startDaemon: invalid consent parameter"); |
1383 return false; | 1376 return false; |
1384 } | 1377 } |
1385 | 1378 |
1386 ScopedRefNPObject callback_obj(ObjectFromNPVariant(args[2])); | 1379 ScopedRefNPObject callback_obj(ObjectFromNPVariant(args[2])); |
1387 if (!callback_obj.get()) { | 1380 if (!callback_obj.get()) { |
1388 SetException("startDaemon: invalid callback parameter"); | 1381 SetException("startDaemon: invalid callback parameter"); |
1389 return false; | 1382 return false; |
1390 } | 1383 } |
1391 | 1384 |
1392 // TODO(wez): Pass a static method here, that will post the result | |
1393 // back to us on the right thread (crbug.com/156257). | |
1394 daemon_controller_->SetConfigAndStart( | 1385 daemon_controller_->SetConfigAndStart( |
1395 config_dict.Pass(), | 1386 config_dict.Pass(), |
1396 NPVARIANT_TO_BOOLEAN(args[1]), | 1387 NPVARIANT_TO_BOOLEAN(args[1]), |
1397 base::Bind(&HostNPScriptObject::InvokeAsyncResultCallback, | 1388 base::Bind(&HostNPScriptObject::InvokeAsyncResultCallback, |
1398 base::Unretained(this), callback_obj)); | 1389 base::Unretained(this), callback_obj)); |
1399 return true; | 1390 return true; |
1400 } | 1391 } |
1401 | 1392 |
1402 bool HostNPScriptObject::StopDaemon(const NPVariant* args, | 1393 bool HostNPScriptObject::StopDaemon(const NPVariant* args, |
1403 uint32_t arg_count, | 1394 uint32_t arg_count, |
1404 NPVariant* result) { | 1395 NPVariant* result) { |
1405 DCHECK(plugin_task_runner_->BelongsToCurrentThread()); | 1396 DCHECK(plugin_task_runner_->BelongsToCurrentThread()); |
1406 | 1397 |
1407 if (arg_count != 1) { | 1398 if (arg_count != 1) { |
1408 SetException("stopDaemon: bad number of arguments"); | 1399 SetException("stopDaemon: bad number of arguments"); |
1409 return false; | 1400 return false; |
1410 } | 1401 } |
1411 | 1402 |
1412 ScopedRefNPObject callback_obj(ObjectFromNPVariant(args[0])); | 1403 ScopedRefNPObject callback_obj(ObjectFromNPVariant(args[0])); |
1413 if (!callback_obj.get()) { | 1404 if (!callback_obj.get()) { |
1414 SetException("stopDaemon: invalid callback parameter"); | 1405 SetException("stopDaemon: invalid callback parameter"); |
1415 return false; | 1406 return false; |
1416 } | 1407 } |
1417 | 1408 |
1418 // TODO(wez): Pass a static method here, that will post the result | |
1419 // back to us on the right thread (crbug.com/156257). | |
1420 daemon_controller_->Stop( | 1409 daemon_controller_->Stop( |
1421 base::Bind(&HostNPScriptObject::InvokeAsyncResultCallback, | 1410 base::Bind(&HostNPScriptObject::InvokeAsyncResultCallback, |
1422 base::Unretained(this), callback_obj)); | 1411 base::Unretained(this), callback_obj)); |
1423 return true; | 1412 return true; |
1424 } | 1413 } |
1425 | 1414 |
1426 void HostNPScriptObject::NotifyStateChanged(State state) { | 1415 void HostNPScriptObject::NotifyStateChanged(State state) { |
1427 DCHECK(plugin_task_runner_->BelongsToCurrentThread()); | 1416 DCHECK(plugin_task_runner_->BelongsToCurrentThread()); |
1428 | 1417 |
1429 state_ = state; | 1418 state_ = state; |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1551 params[0] = NPVariantFromString(private_key); | 1540 params[0] = NPVariantFromString(private_key); |
1552 params[1] = NPVariantFromString(public_key); | 1541 params[1] = NPVariantFromString(public_key); |
1553 InvokeAndIgnoreResult(callback.get(), params, arraysize(params)); | 1542 InvokeAndIgnoreResult(callback.get(), params, arraysize(params)); |
1554 g_npnetscape_funcs->releasevariantvalue(&(params[0])); | 1543 g_npnetscape_funcs->releasevariantvalue(&(params[0])); |
1555 g_npnetscape_funcs->releasevariantvalue(&(params[1])); | 1544 g_npnetscape_funcs->releasevariantvalue(&(params[1])); |
1556 } | 1545 } |
1557 | 1546 |
1558 void HostNPScriptObject::InvokeAsyncResultCallback( | 1547 void HostNPScriptObject::InvokeAsyncResultCallback( |
1559 const ScopedRefNPObject& callback, | 1548 const ScopedRefNPObject& callback, |
1560 DaemonController::AsyncResult result) { | 1549 DaemonController::AsyncResult result) { |
1561 if (!plugin_task_runner_->BelongsToCurrentThread()) { | 1550 DCHECK(plugin_task_runner_->BelongsToCurrentThread()); |
1562 plugin_task_runner_->PostTask( | |
1563 FROM_HERE, base::Bind( | |
1564 &HostNPScriptObject::InvokeAsyncResultCallback, | |
1565 weak_ptr_, callback, result)); | |
1566 return; | |
1567 } | |
1568 | 1551 |
1569 NPVariant result_var; | 1552 NPVariant result_var; |
1570 INT32_TO_NPVARIANT(static_cast<int32>(result), result_var); | 1553 INT32_TO_NPVARIANT(static_cast<int32>(result), result_var); |
1571 InvokeAndIgnoreResult(callback.get(), &result_var, 1); | 1554 InvokeAndIgnoreResult(callback.get(), &result_var, 1); |
1572 g_npnetscape_funcs->releasevariantvalue(&result_var); | 1555 g_npnetscape_funcs->releasevariantvalue(&result_var); |
1573 } | 1556 } |
1574 | 1557 |
1575 void HostNPScriptObject::InvokeBooleanCallback( | 1558 void HostNPScriptObject::InvokeBooleanCallback( |
1576 const ScopedRefNPObject& callback, bool result) { | 1559 const ScopedRefNPObject& callback, bool result) { |
1577 if (!plugin_task_runner_->BelongsToCurrentThread()) { | 1560 if (!plugin_task_runner_->BelongsToCurrentThread()) { |
Wez
2013/09/10 09:05:37
nit: This can be replaced by DCHECK(plugin_task_ru
alexeypa (please no reviews)
2013/09/10 16:59:22
Done.
| |
1578 plugin_task_runner_->PostTask( | 1561 plugin_task_runner_->PostTask( |
1579 FROM_HERE, base::Bind( | 1562 FROM_HERE, base::Bind( |
1580 &HostNPScriptObject::InvokeBooleanCallback, | 1563 &HostNPScriptObject::InvokeBooleanCallback, |
1581 weak_ptr_, callback, result)); | 1564 weak_ptr_, callback, result)); |
1582 return; | 1565 return; |
1583 } | 1566 } |
1584 | 1567 |
1585 NPVariant result_var; | 1568 NPVariant result_var; |
1586 BOOLEAN_TO_NPVARIANT(result, result_var); | 1569 BOOLEAN_TO_NPVARIANT(result, result_var); |
1587 InvokeAndIgnoreResult(callback.get(), &result_var, 1); | 1570 InvokeAndIgnoreResult(callback.get(), &result_var, 1); |
1588 g_npnetscape_funcs->releasevariantvalue(&result_var); | 1571 g_npnetscape_funcs->releasevariantvalue(&result_var); |
1589 } | 1572 } |
1590 | 1573 |
1591 void HostNPScriptObject::InvokeGetDaemonConfigCallback( | 1574 void HostNPScriptObject::InvokeGetDaemonConfigCallback( |
1592 const ScopedRefNPObject& callback, | 1575 const ScopedRefNPObject& callback, |
1593 scoped_ptr<base::DictionaryValue> config) { | 1576 scoped_ptr<base::DictionaryValue> config) { |
1594 if (!plugin_task_runner_->BelongsToCurrentThread()) { | 1577 DCHECK(plugin_task_runner_->BelongsToCurrentThread()); |
1595 plugin_task_runner_->PostTask( | |
1596 FROM_HERE, base::Bind( | |
1597 &HostNPScriptObject::InvokeGetDaemonConfigCallback, | |
1598 weak_ptr_, callback, base::Passed(&config))); | |
1599 return; | |
1600 } | |
1601 | 1578 |
1602 // There is no easy way to create a dictionary from an NPAPI plugin | 1579 // There is no easy way to create a dictionary from an NPAPI plugin |
1603 // so we have to serialize the dictionary to pass it to JavaScript. | 1580 // so we have to serialize the dictionary to pass it to JavaScript. |
1604 std::string config_str; | 1581 std::string config_str; |
1605 if (config.get()) | 1582 if (config.get()) |
1606 base::JSONWriter::Write(config.get(), &config_str); | 1583 base::JSONWriter::Write(config.get(), &config_str); |
1607 | 1584 |
1608 NPVariant config_val = NPVariantFromString(config_str); | 1585 NPVariant config_val = NPVariantFromString(config_str); |
1609 InvokeAndIgnoreResult(callback.get(), &config_val, 1); | 1586 InvokeAndIgnoreResult(callback.get(), &config_val, 1); |
1610 g_npnetscape_funcs->releasevariantvalue(&config_val); | 1587 g_npnetscape_funcs->releasevariantvalue(&config_val); |
1611 } | 1588 } |
1612 | 1589 |
1613 void HostNPScriptObject::InvokeGetDaemonVersionCallback( | 1590 void HostNPScriptObject::InvokeGetDaemonVersionCallback( |
1614 const ScopedRefNPObject& callback, const std::string& version) { | 1591 const ScopedRefNPObject& callback, const std::string& version) { |
1615 if (!plugin_task_runner_->BelongsToCurrentThread()) { | 1592 DCHECK(plugin_task_runner_->BelongsToCurrentThread()); |
1616 plugin_task_runner_->PostTask( | |
1617 FROM_HERE, base::Bind( | |
1618 &HostNPScriptObject::InvokeGetDaemonVersionCallback, | |
1619 weak_ptr_, callback, version)); | |
1620 return; | |
1621 } | |
1622 | 1593 |
1623 NPVariant version_val = NPVariantFromString(version); | 1594 NPVariant version_val = NPVariantFromString(version); |
1624 InvokeAndIgnoreResult(callback.get(), &version_val, 1); | 1595 InvokeAndIgnoreResult(callback.get(), &version_val, 1); |
1625 g_npnetscape_funcs->releasevariantvalue(&version_val); | 1596 g_npnetscape_funcs->releasevariantvalue(&version_val); |
1626 } | 1597 } |
1627 | 1598 |
1628 void HostNPScriptObject::InvokeGetPairedClientsCallback( | 1599 void HostNPScriptObject::InvokeGetPairedClientsCallback( |
1629 const ScopedRefNPObject& callback, | 1600 const ScopedRefNPObject& callback, |
1630 scoped_ptr<base::ListValue> paired_clients) { | 1601 scoped_ptr<base::ListValue> paired_clients) { |
1631 if (!plugin_task_runner_->BelongsToCurrentThread()) { | 1602 if (!plugin_task_runner_->BelongsToCurrentThread()) { |
1632 plugin_task_runner_->PostTask( | 1603 plugin_task_runner_->PostTask( |
1633 FROM_HERE, base::Bind( | 1604 FROM_HERE, base::Bind( |
1634 &HostNPScriptObject::InvokeGetPairedClientsCallback, | 1605 &HostNPScriptObject::InvokeGetPairedClientsCallback, |
1635 weak_ptr_, callback, base::Passed(&paired_clients))); | 1606 weak_ptr_, callback, base::Passed(&paired_clients))); |
1636 return; | 1607 return; |
1637 } | 1608 } |
1638 | 1609 |
1639 std::string paired_clients_json; | 1610 std::string paired_clients_json; |
1640 base::JSONWriter::Write(paired_clients.get(), &paired_clients_json); | 1611 base::JSONWriter::Write(paired_clients.get(), &paired_clients_json); |
1641 | 1612 |
1642 NPVariant paired_clients_val = NPVariantFromString(paired_clients_json); | 1613 NPVariant paired_clients_val = NPVariantFromString(paired_clients_json); |
1643 InvokeAndIgnoreResult(callback.get(), &paired_clients_val, 1); | 1614 InvokeAndIgnoreResult(callback.get(), &paired_clients_val, 1); |
1644 g_npnetscape_funcs->releasevariantvalue(&paired_clients_val); | 1615 g_npnetscape_funcs->releasevariantvalue(&paired_clients_val); |
1645 } | 1616 } |
1646 | 1617 |
1647 void HostNPScriptObject::InvokeGetUsageStatsConsentCallback( | 1618 void HostNPScriptObject::InvokeGetUsageStatsConsentCallback( |
1648 const ScopedRefNPObject& callback, | 1619 const ScopedRefNPObject& callback, |
1649 bool supported, | 1620 const DaemonController::UsageStatsConsent& consent) { |
1650 bool allowed, | 1621 DCHECK(plugin_task_runner_->BelongsToCurrentThread()); |
1651 bool set_by_policy) { | |
1652 if (!plugin_task_runner_->BelongsToCurrentThread()) { | |
1653 plugin_task_runner_->PostTask( | |
1654 FROM_HERE, base::Bind( | |
1655 &HostNPScriptObject::InvokeGetUsageStatsConsentCallback, | |
1656 weak_ptr_, callback, supported, allowed, | |
1657 set_by_policy)); | |
1658 return; | |
1659 } | |
1660 | 1622 |
1661 NPVariant params[3]; | 1623 NPVariant params[3]; |
1662 BOOLEAN_TO_NPVARIANT(supported, params[0]); | 1624 BOOLEAN_TO_NPVARIANT(consent.supported, params[0]); |
1663 BOOLEAN_TO_NPVARIANT(allowed, params[1]); | 1625 BOOLEAN_TO_NPVARIANT(consent.allowed, params[1]); |
1664 BOOLEAN_TO_NPVARIANT(set_by_policy, params[2]); | 1626 BOOLEAN_TO_NPVARIANT(consent.set_by_policy, params[2]); |
1665 InvokeAndIgnoreResult(callback.get(), params, arraysize(params)); | 1627 InvokeAndIgnoreResult(callback.get(), params, arraysize(params)); |
1666 g_npnetscape_funcs->releasevariantvalue(&(params[0])); | 1628 g_npnetscape_funcs->releasevariantvalue(&(params[0])); |
1667 g_npnetscape_funcs->releasevariantvalue(&(params[1])); | 1629 g_npnetscape_funcs->releasevariantvalue(&(params[1])); |
1668 g_npnetscape_funcs->releasevariantvalue(&(params[2])); | 1630 g_npnetscape_funcs->releasevariantvalue(&(params[2])); |
1669 } | 1631 } |
1670 | 1632 |
1671 void HostNPScriptObject::LogDebugInfo(const std::string& message) { | 1633 void HostNPScriptObject::LogDebugInfo(const std::string& message) { |
1672 DCHECK(plugin_task_runner_->BelongsToCurrentThread()); | 1634 DCHECK(plugin_task_runner_->BelongsToCurrentThread()); |
1673 | 1635 |
1674 if (log_debug_info_func_.get()) { | 1636 if (log_debug_info_func_.get()) { |
(...skipping 24 matching lines...) Expand all Loading... | |
1699 } | 1661 } |
1700 | 1662 |
1701 void HostNPScriptObject::SetException(const std::string& exception_string) { | 1663 void HostNPScriptObject::SetException(const std::string& exception_string) { |
1702 DCHECK(plugin_task_runner_->BelongsToCurrentThread()); | 1664 DCHECK(plugin_task_runner_->BelongsToCurrentThread()); |
1703 | 1665 |
1704 g_npnetscape_funcs->setexception(parent_, exception_string.c_str()); | 1666 g_npnetscape_funcs->setexception(parent_, exception_string.c_str()); |
1705 LOG(INFO) << exception_string; | 1667 LOG(INFO) << exception_string; |
1706 } | 1668 } |
1707 | 1669 |
1708 } // namespace remoting | 1670 } // namespace remoting |
OLD | NEW |