Chromium Code Reviews| Index: chrome/browser/media_galleries/media_scan_manager.cc |
| =================================================================== |
| --- chrome/browser/media_galleries/media_scan_manager.cc (revision 252098) |
| +++ chrome/browser/media_galleries/media_scan_manager.cc (working copy) |
| @@ -212,7 +212,8 @@ |
| // may be to contain media directories. This function tries to find those |
| // immediate container directories. |
| MediaFolderFinder::MediaFolderFinderResults FindContainerScanResults( |
| - const MediaFolderFinder::MediaFolderFinderResults& found_folders) { |
| + const MediaFolderFinder::MediaFolderFinderResults& found_folders, |
| + const std::vector<base::FilePath> sensitive_locations) { |
| DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::FILE)); |
| // Count the number of scan results with the same parent directory. |
| typedef std::map<base::FilePath, int /*count*/> ContainerCandidates; |
| @@ -220,6 +221,19 @@ |
| for (MediaFolderFinder::MediaFolderFinderResults::const_iterator it = |
| found_folders.begin(); it != found_folders.end(); ++it) { |
| base::FilePath parent_directory = it->first.DirName(); |
| + |
| + // Skip sensitive folders and their ancestors. |
| + bool is_sensitive = false; |
| + for (size_t i = 0; i < sensitive_locations.size(); ++i) { |
| + if (parent_directory == sensitive_locations[i] || |
| + parent_directory.IsParent(sensitive_locations[i])) { |
| + is_sensitive = true; |
| + continue; |
|
vandebo (ex-Chrome)
2014/02/25 05:06:55
nit: shouldn't this be a break?
Lei Zhang
2014/02/26 00:58:54
Done.
|
| + } |
| + } |
| + if (is_sensitive) |
| + continue; |
| + |
| ContainerCandidates::iterator existing = candidates.find(parent_directory); |
| if (existing == candidates.end()) { |
| candidates[parent_directory] = 1; |
| @@ -252,11 +266,6 @@ |
| return result; |
| } |
| -void RemoveSensitiveLocations( |
| - MediaFolderFinder::MediaFolderFinderResults* found_folders) { |
| - // TODO(vandebo) Use the greylist from filesystem api. |
| -} |
| - |
| int CountScanResultsForExtension(MediaGalleriesPreferences* preferences, |
| const extensions::Extension* extension, |
| MediaGalleryScanResult* file_counts) { |
| @@ -444,9 +453,12 @@ |
| content::BrowserThread::PostTaskAndReplyWithResult( |
| content::BrowserThread::FILE, FROM_HERE, |
| - base::Bind(FindContainerScanResults, found_folders), |
| + base::Bind(FindContainerScanResults, |
| + found_folders, |
| + folder_finder_->graylisted_folders()), |
| base::Bind(&MediaScanManager::OnFoundContainerDirectories, |
| - weak_factory_.GetWeakPtr(), found_folders)); |
| + weak_factory_.GetWeakPtr(), |
| + found_folders)); |
| } |
| void MediaScanManager::OnFoundContainerDirectories( |
| @@ -456,8 +468,6 @@ |
| folders.insert(found_folders.begin(), found_folders.end()); |
| folders.insert(container_folders.begin(), container_folders.end()); |
| - RemoveSensitiveLocations(&folders); |
| - |
| for (ScanObserverMap::iterator scans_for_profile = observers_.begin(); |
| scans_for_profile != observers_.end(); |
| ++scans_for_profile) { |