OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/webcam_private/webcam_private_api.h" | 5 #include "chrome/browser/extensions/api/webcam_private/webcam_private_api.h" |
6 | 6 |
7 #include <fcntl.h> | 7 #include <fcntl.h> |
8 #include <linux/videodev2.h> | 8 #include <linux/videodev2.h> |
9 #include <stdio.h> | 9 #include <stdio.h> |
10 #include <sys/ioctl.h> | 10 #include <sys/ioctl.h> |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
48 } // namespace | 48 } // namespace |
49 | 49 |
50 namespace extensions { | 50 namespace extensions { |
51 | 51 |
52 WebcamPrivateSetFunction::WebcamPrivateSetFunction() { | 52 WebcamPrivateSetFunction::WebcamPrivateSetFunction() { |
53 } | 53 } |
54 | 54 |
55 WebcamPrivateSetFunction::~WebcamPrivateSetFunction() { | 55 WebcamPrivateSetFunction::~WebcamPrivateSetFunction() { |
56 } | 56 } |
57 | 57 |
58 bool WebcamPrivateSetFunction::RunImpl() { | 58 bool WebcamPrivateSetFunction::RunSync() { |
59 // Get parameters | 59 // Get parameters |
60 scoped_ptr<api::webcam_private::Set::Params> params( | 60 scoped_ptr<api::webcam_private::Set::Params> params( |
61 api::webcam_private::Set::Params::Create(*args_)); | 61 api::webcam_private::Set::Params::Create(*args_)); |
62 EXTENSION_FUNCTION_VALIDATE(params.get()); | 62 EXTENSION_FUNCTION_VALIDATE(params.get()); |
63 | 63 |
64 base::ScopedFD fd = | 64 base::ScopedFD fd = |
65 OpenWebcam(extension_id(), browser_context(), params->webcam_id); | 65 OpenWebcam(extension_id(), browser_context(), params->webcam_id); |
66 if (!fd.is_valid()) { | 66 if (!fd.is_valid()) { |
67 SetError(kUnknownWebcam); | 67 SetError(kUnknownWebcam); |
68 return false; | 68 return false; |
(...skipping 16 matching lines...) Expand all Loading... |
85 | 85 |
86 return true; | 86 return true; |
87 } | 87 } |
88 | 88 |
89 WebcamPrivateGetFunction::WebcamPrivateGetFunction() { | 89 WebcamPrivateGetFunction::WebcamPrivateGetFunction() { |
90 } | 90 } |
91 | 91 |
92 WebcamPrivateGetFunction::~WebcamPrivateGetFunction() { | 92 WebcamPrivateGetFunction::~WebcamPrivateGetFunction() { |
93 } | 93 } |
94 | 94 |
95 bool WebcamPrivateGetFunction::RunImpl() { | 95 bool WebcamPrivateGetFunction::RunSync() { |
96 // Get parameters | 96 // Get parameters |
97 scoped_ptr<api::webcam_private::Get::Params> params( | 97 scoped_ptr<api::webcam_private::Get::Params> params( |
98 api::webcam_private::Get::Params::Create(*args_)); | 98 api::webcam_private::Get::Params::Create(*args_)); |
99 EXTENSION_FUNCTION_VALIDATE(params.get()); | 99 EXTENSION_FUNCTION_VALIDATE(params.get()); |
100 | 100 |
101 base::ScopedFD fd = | 101 base::ScopedFD fd = |
102 OpenWebcam(extension_id(), browser_context(), params->webcam_id); | 102 OpenWebcam(extension_id(), browser_context(), params->webcam_id); |
103 if (!fd.is_valid()) { | 103 if (!fd.is_valid()) { |
104 SetError(kUnknownWebcam); | 104 SetError(kUnknownWebcam); |
105 return false; | 105 return false; |
(...skipping 17 matching lines...) Expand all Loading... |
123 | 123 |
124 return true; | 124 return true; |
125 } | 125 } |
126 | 126 |
127 WebcamPrivateResetFunction::WebcamPrivateResetFunction() { | 127 WebcamPrivateResetFunction::WebcamPrivateResetFunction() { |
128 } | 128 } |
129 | 129 |
130 WebcamPrivateResetFunction::~WebcamPrivateResetFunction() { | 130 WebcamPrivateResetFunction::~WebcamPrivateResetFunction() { |
131 } | 131 } |
132 | 132 |
133 bool WebcamPrivateResetFunction::RunImpl() { | 133 bool WebcamPrivateResetFunction::RunSync() { |
134 // Get parameters | 134 // Get parameters |
135 scoped_ptr<api::webcam_private::Reset::Params> params( | 135 scoped_ptr<api::webcam_private::Reset::Params> params( |
136 api::webcam_private::Reset::Params::Create(*args_)); | 136 api::webcam_private::Reset::Params::Create(*args_)); |
137 EXTENSION_FUNCTION_VALIDATE(params.get()); | 137 EXTENSION_FUNCTION_VALIDATE(params.get()); |
138 | 138 |
139 base::ScopedFD fd = | 139 base::ScopedFD fd = |
140 OpenWebcam(extension_id(), browser_context(), params->webcam_id); | 140 OpenWebcam(extension_id(), browser_context(), params->webcam_id); |
141 if (!fd.is_valid()) { | 141 if (!fd.is_valid()) { |
142 SetError(kUnknownWebcam); | 142 SetError(kUnknownWebcam); |
143 return false; | 143 return false; |
(...skipping 11 matching lines...) Expand all Loading... |
155 | 155 |
156 if (params->config.zoom) { | 156 if (params->config.zoom) { |
157 const int kDefaultZoom = 100; | 157 const int kDefaultZoom = 100; |
158 SetWebcamParameter(fd.get(), V4L2_CID_ZOOM_ABSOLUTE, kDefaultZoom); | 158 SetWebcamParameter(fd.get(), V4L2_CID_ZOOM_ABSOLUTE, kDefaultZoom); |
159 } | 159 } |
160 | 160 |
161 return true; | 161 return true; |
162 } | 162 } |
163 | 163 |
164 } // namespace extensions | 164 } // namespace extensions |
OLD | NEW |