| 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 "chrome/browser/chromeos/login/camera_detector.h" | 5 #include "chrome/browser/chromeos/login/camera_detector.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
| 9 #include "base/string_split.h" | 9 #include "base/string_split.h" |
| 10 #include "base/string_util.h" | 10 #include "base/string_util.h" |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 50 void CameraDetector::CheckPresence() { | 50 void CameraDetector::CheckPresence() { |
| 51 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); | 51 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); |
| 52 | 52 |
| 53 bool present = false; | 53 bool present = false; |
| 54 | 54 |
| 55 system::UdevInfoProvider* udev_info = system::UdevInfoProvider::GetInstance(); | 55 system::UdevInfoProvider* udev_info = system::UdevInfoProvider::GetInstance(); |
| 56 // We do a quick check using udev database because opening each /dev/videoX | 56 // We do a quick check using udev database because opening each /dev/videoX |
| 57 // device may trigger costly device initialization. | 57 // device may trigger costly device initialization. |
| 58 using file_util::FileEnumerator; | 58 using file_util::FileEnumerator; |
| 59 FileEnumerator file_enum( | 59 FileEnumerator file_enum( |
| 60 FilePath(kV4LSubsystemDir), | 60 FilePath(kV4LSubsystemDir), false /* not recursive */, |
| 61 false, // Don't recurse. | 61 FileEnumerator::FILES | FileEnumerator::SHOW_SYM_LINKS); |
| 62 static_cast<FileEnumerator::FileType>( | |
| 63 FileEnumerator::FILES | FileEnumerator::SHOW_SYM_LINKS)); | |
| 64 for (FilePath path = file_enum.Next(); !path.empty(); | 62 for (FilePath path = file_enum.Next(); !path.empty(); |
| 65 path = file_enum.Next()) { | 63 path = file_enum.Next()) { |
| 66 std::string v4l_capabilities; | 64 std::string v4l_capabilities; |
| 67 if (udev_info->QueryDeviceProperty(path.value(), kV4LCapabilities, | 65 if (udev_info->QueryDeviceProperty(path.value(), kV4LCapabilities, |
| 68 &v4l_capabilities)) { | 66 &v4l_capabilities)) { |
| 69 std::vector<std::string> caps; | 67 std::vector<std::string> caps; |
| 70 base::SplitString(v4l_capabilities, kV4LCapabilitiesDelim, &caps); | 68 base::SplitString(v4l_capabilities, kV4LCapabilitiesDelim, &caps); |
| 71 if (find(caps.begin(), caps.end(), kV4LCaptureCapability) != caps.end()) { | 69 if (find(caps.begin(), caps.end(), kV4LCaptureCapability) != caps.end()) { |
| 72 present = true; | 70 present = true; |
| 73 break; | 71 break; |
| 74 } | 72 } |
| 75 } | 73 } |
| 76 } | 74 } |
| 77 | 75 |
| 78 camera_presence_ = present ? kCameraPresent : kCameraAbsent; | 76 camera_presence_ = present ? kCameraPresent : kCameraAbsent; |
| 79 presence_check_in_progress_ = false; | 77 presence_check_in_progress_ = false; |
| 80 | 78 |
| 81 DVLOG(1) << "Camera presence state: " << camera_presence_; | 79 DVLOG(1) << "Camera presence state: " << camera_presence_; |
| 82 } | 80 } |
| 83 | 81 |
| 84 } // namespace chromeos | 82 } // namespace chromeos |
| OLD | NEW |