| 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 "extensions/browser/api/document_scan/document_scan_api.h" | 5 #include "extensions/browser/api/document_scan/document_scan_api.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "content/public/browser/browser_thread.h" | 9 #include "content/public/browser/browser_thread.h" |
| 10 #include "extensions/browser/extension_system.h" | 10 #include "extensions/browser/extension_system.h" |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 58 scanner_descriptions, | 58 scanner_descriptions, |
| 59 const std::string& error) { | 59 const std::string& error) { |
| 60 std::vector<DocumentScanInterface::ScannerDescription>::const_iterator | 60 std::vector<DocumentScanInterface::ScannerDescription>::const_iterator |
| 61 scanner_i = scanner_descriptions.begin(); | 61 scanner_i = scanner_descriptions.begin(); |
| 62 | 62 |
| 63 // If no |scanner_descriptions| is empty, this is an error. If no | 63 // If no |scanner_descriptions| is empty, this is an error. If no |
| 64 // MIME types are specified, the first scanner is chosen. If MIME | 64 // MIME types are specified, the first scanner is chosen. If MIME |
| 65 // types are specified, the first scanner that supports one of these | 65 // types are specified, the first scanner that supports one of these |
| 66 // MIME types is selected. | 66 // MIME types is selected. |
| 67 if (params_->options.mime_types) { | 67 if (params_->options.mime_types) { |
| 68 std::vector<std::string>& mime_types = *params_->options.mime_types.get(); | 68 std::vector<std::string>& mime_types = *params_->options.mime_types; |
| 69 for (; scanner_i != scanner_descriptions.end(); ++scanner_i) { | 69 for (; scanner_i != scanner_descriptions.end(); ++scanner_i) { |
| 70 if (std::find(mime_types.begin(), mime_types.end(), | 70 if (std::find(mime_types.begin(), mime_types.end(), |
| 71 scanner_i->image_mime_type) != mime_types.end()) { | 71 scanner_i->image_mime_type) != mime_types.end()) { |
| 72 break; | 72 break; |
| 73 } | 73 } |
| 74 } | 74 } |
| 75 } | 75 } |
| 76 | 76 |
| 77 if (scanner_i == scanner_descriptions.end()) { | 77 if (scanner_i == scanner_descriptions.end()) { |
| 78 error_ = kScannerNotAvailable; | 78 error_ = kScannerNotAvailable; |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 115 Release(); | 115 Release(); |
| 116 } | 116 } |
| 117 | 117 |
| 118 bool DocumentScanScanFunction::Respond() { | 118 bool DocumentScanScanFunction::Respond() { |
| 119 return error_.empty(); | 119 return error_.empty(); |
| 120 } | 120 } |
| 121 | 121 |
| 122 } // namespace api | 122 } // namespace api |
| 123 | 123 |
| 124 } // namespace extensions | 124 } // namespace extensions |
| OLD | NEW |