| 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,15 @@
|
| 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.
|
| + for (size_t i = 0; i < sensitive_locations.size(); ++i) {
|
| + if (parent_directory == sensitive_locations[i] ||
|
| + parent_directory.IsParent(sensitive_locations[i])) {
|
| + continue;
|
| + }
|
| + }
|
| +
|
| ContainerCandidates::iterator existing = candidates.find(parent_directory);
|
| if (existing == candidates.end()) {
|
| candidates[parent_directory] = 1;
|
| @@ -252,11 +262,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) {
|
| @@ -435,7 +440,8 @@
|
|
|
| void MediaScanManager::OnScanCompleted(
|
| bool success,
|
| - const MediaFolderFinder::MediaFolderFinderResults& found_folders) {
|
| + const MediaFolderFinder::MediaFolderFinderResults& found_folders,
|
| + const std::vector<base::FilePath>& sensitive_locations) {
|
| DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
|
| if (!folder_finder_ || !success) {
|
| folder_finder_.reset();
|
| @@ -444,9 +450,12 @@
|
|
|
| content::BrowserThread::PostTaskAndReplyWithResult(
|
| content::BrowserThread::FILE, FROM_HERE,
|
| - base::Bind(FindContainerScanResults, found_folders),
|
| + base::Bind(FindContainerScanResults,
|
| + found_folders,
|
| + sensitive_locations),
|
| base::Bind(&MediaScanManager::OnFoundContainerDirectories,
|
| - weak_factory_.GetWeakPtr(), found_folders));
|
| + weak_factory_.GetWeakPtr(),
|
| + found_folders));
|
| }
|
|
|
| void MediaScanManager::OnFoundContainerDirectories(
|
| @@ -456,8 +465,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) {
|
|
|