| 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/media_galleries/fileapi/media_path_filter.h" | 5 #include "chrome/browser/media_galleries/fileapi/media_path_filter.h" |
| 6 | 6 |
| 7 #if defined(OS_WIN) | 7 #if defined(OS_WIN) |
| 8 #include <windows.h> | 8 #include <windows.h> |
| 9 #endif | 9 #endif |
| 10 | 10 |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 145 MediaPathFilter::~MediaPathFilter() { | 145 MediaPathFilter::~MediaPathFilter() { |
| 146 } | 146 } |
| 147 | 147 |
| 148 bool MediaPathFilter::Match(const base::FilePath& path) { | 148 bool MediaPathFilter::Match(const base::FilePath& path) { |
| 149 return GetType(path) != MEDIA_GALLERY_SCAN_FILE_TYPE_UNKNOWN; | 149 return GetType(path) != MEDIA_GALLERY_SCAN_FILE_TYPE_UNKNOWN; |
| 150 } | 150 } |
| 151 | 151 |
| 152 MediaGalleryScanFileType MediaPathFilter::GetType(const base::FilePath& path) { | 152 MediaGalleryScanFileType MediaPathFilter::GetType(const base::FilePath& path) { |
| 153 EnsureInitialized(); | 153 EnsureInitialized(); |
| 154 MediaFileExtensionMap::const_iterator it = | 154 MediaFileExtensionMap::const_iterator it = |
| 155 media_file_extensions_map_.find( | 155 media_file_extensions_map_.find(base::ToLowerASCII(path.Extension())); |
| 156 base::StringToLowerASCII(path.Extension())); | |
| 157 if (it == media_file_extensions_map_.end()) | 156 if (it == media_file_extensions_map_.end()) |
| 158 return MEDIA_GALLERY_SCAN_FILE_TYPE_UNKNOWN; | 157 return MEDIA_GALLERY_SCAN_FILE_TYPE_UNKNOWN; |
| 159 return static_cast<MediaGalleryScanFileType>(it->second); | 158 return static_cast<MediaGalleryScanFileType>(it->second); |
| 160 } | 159 } |
| 161 | 160 |
| 162 void MediaPathFilter::EnsureInitialized() { | 161 void MediaPathFilter::EnsureInitialized() { |
| 163 DCHECK(sequence_checker_.CalledOnValidSequencedThread()); | 162 DCHECK(sequence_checker_.CalledOnValidSequencedThread()); |
| 164 if (initialized_) | 163 if (initialized_) |
| 165 return; | 164 return; |
| 166 | 165 |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 205 } | 204 } |
| 206 | 205 |
| 207 void MediaPathFilter::AddExtensionToMediaFileExtensionMap( | 206 void MediaPathFilter::AddExtensionToMediaFileExtensionMap( |
| 208 const base::FilePath::CharType* extension, | 207 const base::FilePath::CharType* extension, |
| 209 MediaGalleryScanFileType type) { | 208 MediaGalleryScanFileType type) { |
| 210 base::FilePath::StringType extension_with_sep = | 209 base::FilePath::StringType extension_with_sep = |
| 211 base::FilePath::kExtensionSeparator + | 210 base::FilePath::kExtensionSeparator + |
| 212 base::FilePath::StringType(extension); | 211 base::FilePath::StringType(extension); |
| 213 media_file_extensions_map_[extension_with_sep] |= type; | 212 media_file_extensions_map_[extension_with_sep] |= type; |
| 214 } | 213 } |
| OLD | NEW |