OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "chrome/browser/extensions/api/braille_display_private/brlapi_connectio
n.h" | 5 #include "chrome/browser/extensions/api/braille_display_private/brlapi_connectio
n.h" |
6 | 6 |
7 #include "base/chromeos/chromeos_version.h" | |
8 #include "base/message_loop/message_loop.h" | 7 #include "base/message_loop/message_loop.h" |
| 8 #include "base/sys_info.h" |
9 | 9 |
10 namespace extensions { | 10 namespace extensions { |
11 using base::MessageLoopForIO; | 11 using base::MessageLoopForIO; |
12 namespace api { | 12 namespace api { |
13 namespace braille_display_private { | 13 namespace braille_display_private { |
14 | 14 |
15 namespace { | 15 namespace { |
16 // Default virtual terminal. This can be overriden by setting the | 16 // Default virtual terminal. This can be overriden by setting the |
17 // WINDOWPATH environment variable. This is only used when not running | 17 // WINDOWPATH environment variable. This is only used when not running |
18 // under Crhome OS (that is in aura for a Linux desktop). | 18 // under Crhome OS (that is in aura for a Linux desktop). |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
80 libbrlapi_loader_->brlapi_getHandleSize())); | 80 libbrlapi_loader_->brlapi_getHandleSize())); |
81 int fd = libbrlapi_loader_->brlapi__openConnection(handle_.get(), NULL, NULL); | 81 int fd = libbrlapi_loader_->brlapi__openConnection(handle_.get(), NULL, NULL); |
82 if (fd < 0) { | 82 if (fd < 0) { |
83 handle_.reset(); | 83 handle_.reset(); |
84 LOG(ERROR) << "Error connecting to brlapi: " << BrlapiStrError(); | 84 LOG(ERROR) << "Error connecting to brlapi: " << BrlapiStrError(); |
85 return false; | 85 return false; |
86 } | 86 } |
87 int path[2] = {0, 0}; | 87 int path[2] = {0, 0}; |
88 int pathElements = 0; | 88 int pathElements = 0; |
89 #if defined(OS_CHROMEOS) | 89 #if defined(OS_CHROMEOS) |
90 if (base::chromeos::IsRunningOnChromeOS()) | 90 if (base::SysInfo::IsRunningOnChromeOS()) |
91 path[pathElements++] = kDefaultTtyChromeOS; | 91 path[pathElements++] = kDefaultTtyChromeOS; |
92 #endif | 92 #endif |
93 if (pathElements == 0 && getenv("WINDOWPATH") == NULL) | 93 if (pathElements == 0 && getenv("WINDOWPATH") == NULL) |
94 path[pathElements++] = kDefaultTtyLinux; | 94 path[pathElements++] = kDefaultTtyLinux; |
95 if (libbrlapi_loader_->brlapi__enterTtyModeWithPath( | 95 if (libbrlapi_loader_->brlapi__enterTtyModeWithPath( |
96 handle_.get(), path, pathElements, NULL) < 0) { | 96 handle_.get(), path, pathElements, NULL) < 0) { |
97 LOG(ERROR) << "brlapi: couldn't enter tty mode: " << BrlapiStrError(); | 97 LOG(ERROR) << "brlapi: couldn't enter tty mode: " << BrlapiStrError(); |
98 Disconnect(); | 98 Disconnect(); |
99 return false; | 99 return false; |
100 } | 100 } |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
192 if (!handle_) { | 192 if (!handle_) { |
193 BrlapiError()->brlerrno = BRLAPI_ERROR_ILLEGAL_INSTRUCTION; | 193 BrlapiError()->brlerrno = BRLAPI_ERROR_ILLEGAL_INSTRUCTION; |
194 return false; | 194 return false; |
195 } | 195 } |
196 return true; | 196 return true; |
197 } | 197 } |
198 | 198 |
199 } // namespace braille_display_private | 199 } // namespace braille_display_private |
200 } // namespace api | 200 } // namespace api |
201 } // namespace extensions | 201 } // namespace extensions |
OLD | NEW |