Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(96)

Side by Side Diff: chrome/browser/media_gallery/media_file_system_registry.cc

Issue 11297002: [Media Gallery] Added code to support mtp device media file system on Windows. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase + Fixed win compile error by implementing GetMTPStorageInfoFromDeviceId in TestStorageNotifi… Created 7 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | chrome/browser/media_gallery/media_file_system_registry_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 // MediaFileSystemRegistry implementation. 5 // MediaFileSystemRegistry implementation.
6 6
7 #include "chrome/browser/media_gallery/media_file_system_registry.h" 7 #include "chrome/browser/media_gallery/media_file_system_registry.h"
8 8
9 #include <set> 9 #include <set>
10 #include <vector> 10 #include <vector>
11 11
12 #include "base/bind.h" 12 #include "base/bind.h"
13 #include "base/callback.h" 13 #include "base/callback.h"
14 #include "base/command_line.h"
14 #include "base/file_path.h" 15 #include "base/file_path.h"
15 #include "base/json/json_writer.h" 16 #include "base/json/json_writer.h"
16 #include "base/path_service.h" 17 #include "base/path_service.h"
17 #include "base/stl_util.h" 18 #include "base/stl_util.h"
18 #include "base/string_number_conversions.h" 19 #include "base/string_number_conversions.h"
19 #include "base/string_util.h" 20 #include "base/string_util.h"
20 #include "base/system_monitor/system_monitor.h" 21 #include "base/system_monitor/system_monitor.h"
21 #include "base/utf_string_conversions.h" 22 #include "base/utf_string_conversions.h"
22 #include "base/values.h" 23 #include "base/values.h"
23 #include "chrome/browser/extensions/extension_service.h" 24 #include "chrome/browser/extensions/extension_service.h"
24 #include "chrome/browser/extensions/extension_system.h" 25 #include "chrome/browser/extensions/extension_system.h"
25 #include "chrome/browser/media_gallery/media_file_system_context.h" 26 #include "chrome/browser/media_gallery/media_file_system_context.h"
26 #include "chrome/browser/media_gallery/media_galleries_preferences_factory.h" 27 #include "chrome/browser/media_gallery/media_galleries_preferences_factory.h"
27 #include "chrome/browser/media_gallery/scoped_mtp_device_map_entry.h" 28 #include "chrome/browser/media_gallery/scoped_mtp_device_map_entry.h"
28 #include "chrome/browser/prefs/pref_service.h" 29 #include "chrome/browser/prefs/pref_service.h"
29 #include "chrome/browser/profiles/profile.h" 30 #include "chrome/browser/profiles/profile.h"
30 #include "chrome/browser/system_monitor/media_storage_util.h" 31 #include "chrome/browser/system_monitor/media_storage_util.h"
31 #include "chrome/common/chrome_notification_types.h" 32 #include "chrome/common/chrome_notification_types.h"
32 #include "chrome/common/chrome_paths.h" 33 #include "chrome/common/chrome_paths.h"
34 #include "chrome/common/chrome_switches.h"
33 #include "chrome/common/extensions/extension_constants.h" 35 #include "chrome/common/extensions/extension_constants.h"
34 #include "chrome/common/extensions/extension_set.h" 36 #include "chrome/common/extensions/extension_set.h"
35 #include "chrome/common/extensions/extension.h" 37 #include "chrome/common/extensions/extension.h"
36 #include "chrome/common/pref_names.h" 38 #include "chrome/common/pref_names.h"
37 #include "content/public/browser/browser_thread.h" 39 #include "content/public/browser/browser_thread.h"
38 #include "content/public/browser/notification_details.h" 40 #include "content/public/browser/notification_details.h"
39 #include "content/public/browser/notification_observer.h" 41 #include "content/public/browser/notification_observer.h"
40 #include "content/public/browser/notification_registrar.h" 42 #include "content/public/browser/notification_registrar.h"
41 #include "content/public/browser/notification_source.h" 43 #include "content/public/browser/notification_source.h"
42 #include "content/public/browser/notification_types.h" 44 #include "content/public/browser/notification_types.h"
(...skipping 12 matching lines...) Expand all
55 57
56 namespace chrome { 58 namespace chrome {
57 59
58 namespace { 60 namespace {
59 61
60 struct InvalidatedGalleriesInfo { 62 struct InvalidatedGalleriesInfo {
61 std::set<ExtensionGalleriesHost*> extension_hosts; 63 std::set<ExtensionGalleriesHost*> extension_hosts;
62 std::set<MediaGalleryPrefId> pref_ids; 64 std::set<MediaGalleryPrefId> pref_ids;
63 }; 65 };
64 66
67 #if defined(SUPPORT_MTP_DEVICE_FILESYSTEM)
68 // Returns true if the media transfer protocol (MTP) device operations are
69 // allowed for this platform.
70 // TODO(kmadhusu): Remove this function after fixing crbug.com/154835.
71 bool IsMTPDeviceMediaOperationsEnabled() {
72 #if defined(OS_WIN)
73 return CommandLine::ForCurrentProcess()->HasSwitch(
74 switches::kEnableMediaTransferProtocolDeviceOperations);
75 #endif
76 return true;
77 }
78 #endif
79
65 } // namespace 80 } // namespace
66 81
67 MediaFileSystemInfo::MediaFileSystemInfo(const std::string& fs_name, 82 MediaFileSystemInfo::MediaFileSystemInfo(const std::string& fs_name,
68 const FilePath& fs_path, 83 const FilePath& fs_path,
69 const std::string& filesystem_id, 84 const std::string& filesystem_id,
70 MediaGalleryPrefId pref_id, 85 MediaGalleryPrefId pref_id,
71 uint64 transient_device_id, 86 uint64 transient_device_id,
72 bool removable, 87 bool removable,
73 bool media_device) 88 bool media_device)
74 : name(fs_name), 89 : name(fs_name),
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 // Revoke the file system for |id| if this extension has created one for |id|. 158 // Revoke the file system for |id| if this extension has created one for |id|.
144 void RevokeGalleryByPrefId(MediaGalleryPrefId id) { 159 void RevokeGalleryByPrefId(MediaGalleryPrefId id) {
145 PrefIdFsInfoMap::iterator gallery = pref_id_map_.find(id); 160 PrefIdFsInfoMap::iterator gallery = pref_id_map_.find(id);
146 if (gallery == pref_id_map_.end()) 161 if (gallery == pref_id_map_.end())
147 return; 162 return;
148 163
149 file_system_context_->RevokeFileSystem(gallery->second.fsid); 164 file_system_context_->RevokeFileSystem(gallery->second.fsid);
150 pref_id_map_.erase(gallery); 165 pref_id_map_.erase(gallery);
151 166
152 #if defined(SUPPORT_MTP_DEVICE_FILESYSTEM) 167 #if defined(SUPPORT_MTP_DEVICE_FILESYSTEM)
153 MediaDeviceEntryReferencesMap::iterator mtp_device_host = 168 if (IsMTPDeviceMediaOperationsEnabled()) {
154 media_device_map_references_.find(id); 169 MediaDeviceEntryReferencesMap::iterator mtp_device_host =
155 if (mtp_device_host != media_device_map_references_.end()) 170 media_device_map_references_.find(id);
156 media_device_map_references_.erase(mtp_device_host); 171 if (mtp_device_host != media_device_map_references_.end())
172 media_device_map_references_.erase(mtp_device_host);
173 }
157 #endif 174 #endif
158 175
159 if (pref_id_map_.empty()) { 176 if (pref_id_map_.empty()) {
160 rph_refs_.clear(); 177 rph_refs_.clear();
161 CleanUp(); 178 CleanUp();
162 } 179 }
163 } 180 }
164 181
165 // Indicate that the passed |rvh| will reference the file system ids created 182 // Indicate that the passed |rvh| will reference the file system ids created
166 // by this class. It is safe to call this multiple times with the same RVH. 183 // by this class. It is safe to call this multiple times with the same RVH.
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
266 FilePath path = gallery_info.AbsolutePath(); 283 FilePath path = gallery_info.AbsolutePath();
267 if (!MediaStorageUtil::CanCreateFileSystem(device_id, path)) 284 if (!MediaStorageUtil::CanCreateFileSystem(device_id, path))
268 continue; 285 continue;
269 286
270 std::string fsid; 287 std::string fsid;
271 if (MediaStorageUtil::IsMassStorageDevice(device_id)) { 288 if (MediaStorageUtil::IsMassStorageDevice(device_id)) {
272 fsid = file_system_context_->RegisterFileSystemForMassStorage( 289 fsid = file_system_context_->RegisterFileSystemForMassStorage(
273 device_id, path); 290 device_id, path);
274 } else { 291 } else {
275 #if defined(SUPPORT_MTP_DEVICE_FILESYSTEM) 292 #if defined(SUPPORT_MTP_DEVICE_FILESYSTEM)
293 if (!IsMTPDeviceMediaOperationsEnabled())
294 continue;
295
276 scoped_refptr<ScopedMTPDeviceMapEntry> mtp_device_host; 296 scoped_refptr<ScopedMTPDeviceMapEntry> mtp_device_host;
277 fsid = file_system_context_->RegisterFileSystemForMTPDevice( 297 fsid = file_system_context_->RegisterFileSystemForMTPDevice(
278 device_id, path, &mtp_device_host); 298 device_id, path, &mtp_device_host);
279 DCHECK(mtp_device_host.get()); 299 DCHECK(mtp_device_host.get());
280 media_device_map_references_[pref_id] = mtp_device_host; 300 media_device_map_references_[pref_id] = mtp_device_host;
281 #else 301 #else
282 NOTIMPLEMENTED(); 302 NOTIMPLEMENTED();
283 continue; 303 continue;
284 #endif 304 #endif
285 } 305 }
(...skipping 458 matching lines...) Expand 10 before | Expand all | Expand 10 after
744 764
745 PrefChangeRegistrarMap::iterator pref_it = 765 PrefChangeRegistrarMap::iterator pref_it =
746 pref_change_registrar_map_.find(profile); 766 pref_change_registrar_map_.find(profile);
747 DCHECK(pref_it != pref_change_registrar_map_.end()); 767 DCHECK(pref_it != pref_change_registrar_map_.end());
748 delete pref_it->second; 768 delete pref_it->second;
749 pref_change_registrar_map_.erase(pref_it); 769 pref_change_registrar_map_.erase(pref_it);
750 } 770 }
751 } 771 }
752 772
753 } // namespace chrome 773 } // namespace chrome
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/media_gallery/media_file_system_registry_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698