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

Unified Diff: device/serial/serial_io_handler_posix.cc

Issue 646053002: Implement permission_broker for serial devices. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix device_unittests. Created 6 years, 2 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « device/serial/serial_io_handler_posix.h ('k') | device/serial/serial_io_handler_win.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: device/serial/serial_io_handler_posix.cc
diff --git a/device/serial/serial_io_handler_posix.cc b/device/serial/serial_io_handler_posix.cc
index a215661be11586b02dad4c2194686cbe51bd1318..020ee4cca2f6d1c88ae2eea6ea26db9b6a20def9 100644
--- a/device/serial/serial_io_handler_posix.cc
+++ b/device/serial/serial_io_handler_posix.cc
@@ -11,7 +11,13 @@
#if defined(OS_LINUX)
#include <linux/serial.h>
-#endif
+#if defined(OS_CHROMEOS)
+#include "base/bind.h"
+#include "base/sys_info.h"
+#include "chromeos/dbus/dbus_thread_manager.h"
+#include "chromeos/dbus/permission_broker_client.h"
+#endif // defined(OS_CHROMEOS)
+#endif // defined(OS_LINUX)
namespace {
@@ -123,8 +129,41 @@ namespace device {
// static
scoped_refptr<SerialIoHandler> SerialIoHandler::Create(
- scoped_refptr<base::MessageLoopProxy> file_thread_message_loop) {
- return new SerialIoHandlerPosix(file_thread_message_loop);
+ scoped_refptr<base::MessageLoopProxy> file_thread_message_loop,
+ scoped_refptr<base::MessageLoopProxy> ui_thread_message_loop) {
+ return new SerialIoHandlerPosix(file_thread_message_loop,
+ ui_thread_message_loop);
+}
+
+void SerialIoHandlerPosix::RequestAccess(
+ const std::string& port,
+ scoped_refptr<base::MessageLoopProxy> file_message_loop,
+ scoped_refptr<base::MessageLoopProxy> ui_message_loop) {
+#if defined(OS_LINUX) && defined(OS_CHROMEOS)
+ if (base::SysInfo::IsRunningOnChromeOS()) {
+ chromeos::PermissionBrokerClient* client =
+ chromeos::DBusThreadManager::Get()->GetPermissionBrokerClient();
+ if (!client) {
+ DVLOG(1) << "Could not get permission_broker client.";
+ OnRequestAccessComplete(port, false /* failure */);
+ return;
+ }
+ // PermissionBrokerClient should be called on the UI thread.
+ ui_message_loop->PostTask(
+ FROM_HERE,
+ base::Bind(
+ &chromeos::PermissionBrokerClient::RequestPathAccess,
+ base::Unretained(client),
+ port,
+ -1,
+ base::Bind(&SerialIoHandler::OnRequestAccessComplete, this, port)));
+ } else {
+ OnRequestAccessComplete(port, true /* success */);
+ return;
+ }
+#else
+ OnRequestAccessComplete(port, true /* success */);
+#endif // defined(OS_LINUX) && defined(OS_CHROMEOS)
}
void SerialIoHandlerPosix::ReadImpl() {
@@ -158,8 +197,9 @@ void SerialIoHandlerPosix::CancelWriteImpl() {
}
SerialIoHandlerPosix::SerialIoHandlerPosix(
- scoped_refptr<base::MessageLoopProxy> file_thread_message_loop)
- : SerialIoHandler(file_thread_message_loop),
+ scoped_refptr<base::MessageLoopProxy> file_thread_message_loop,
+ scoped_refptr<base::MessageLoopProxy> ui_thread_message_loop)
+ : SerialIoHandler(file_thread_message_loop, ui_thread_message_loop),
is_watching_reads_(false),
is_watching_writes_(false) {
}
« no previous file with comments | « device/serial/serial_io_handler_posix.h ('k') | device/serial/serial_io_handler_win.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698