OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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_file_system_backend.h" | 5 #include "chrome/browser/media_galleries/fileapi/media_file_system_backend.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
84 | 84 |
85 ExtensionService* extension_service = | 85 ExtensionService* extension_service = |
86 extensions::ExtensionSystem::Get(profile)->extension_service(); | 86 extensions::ExtensionSystem::Get(profile)->extension_service(); |
87 const extensions::Extension* extension = | 87 const extensions::Extension* extension = |
88 extension_service->GetExtensionById(storage_domain, | 88 extension_service->GetExtensionById(storage_domain, |
89 false /*include disabled*/); | 89 false /*include disabled*/); |
90 std::string expected_mount_prefix = | 90 std::string expected_mount_prefix = |
91 MediaFileSystemBackend::ConstructMountName( | 91 MediaFileSystemBackend::ConstructMountName( |
92 profile->GetPath(), storage_domain, kInvalidMediaGalleryPrefId); | 92 profile->GetPath(), storage_domain, kInvalidMediaGalleryPrefId); |
93 MediaGalleryPrefId pref_id = kInvalidMediaGalleryPrefId; | 93 MediaGalleryPrefId pref_id = kInvalidMediaGalleryPrefId; |
94 if (extension && | 94 if (extension && extension->id() == storage_domain && |
95 extension->id() == storage_domain && | 95 base::StartsWithASCII(mount_point, expected_mount_prefix, true) && |
96 StartsWithASCII(mount_point, expected_mount_prefix, true) && | |
97 base::StringToUint64(mount_point.substr(expected_mount_prefix.size()), | 96 base::StringToUint64(mount_point.substr(expected_mount_prefix.size()), |
98 &pref_id) && | 97 &pref_id) && |
99 pref_id != kInvalidMediaGalleryPrefId) { | 98 pref_id != kInvalidMediaGalleryPrefId) { |
100 MediaGalleriesPreferences* preferences = | 99 MediaGalleriesPreferences* preferences = |
101 g_browser_process->media_file_system_registry()->GetPreferences( | 100 g_browser_process->media_file_system_registry()->GetPreferences( |
102 profile); | 101 profile); |
103 preferences->EnsureInitialized( | 102 preferences->EnsureInitialized( |
104 base::Bind(&OnPreferencesInit, rvh, extension, pref_id, callback)); | 103 base::Bind(&OnPreferencesInit, rvh, extension, pref_id, callback)); |
105 return; | 104 return; |
106 } | 105 } |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
190 } | 189 } |
191 | 190 |
192 const base::FilePath& virtual_path = filesystem_url.path(); | 191 const base::FilePath& virtual_path = filesystem_url.path(); |
193 if (virtual_path.ReferencesParent()) | 192 if (virtual_path.ReferencesParent()) |
194 return false; | 193 return false; |
195 std::vector<base::FilePath::StringType> components; | 194 std::vector<base::FilePath::StringType> components; |
196 virtual_path.GetComponents(&components); | 195 virtual_path.GetComponents(&components); |
197 if (components.empty()) | 196 if (components.empty()) |
198 return false; | 197 return false; |
199 std::string mount_point = base::FilePath(components[0]).AsUTF8Unsafe(); | 198 std::string mount_point = base::FilePath(components[0]).AsUTF8Unsafe(); |
200 if (!StartsWithASCII(mount_point, kMediaGalleryMountPrefix, true)) | 199 if (!base::StartsWithASCII(mount_point, kMediaGalleryMountPrefix, true)) |
201 return false; | 200 return false; |
202 | 201 |
203 const content::ResourceRequestInfo* request_info = | 202 const content::ResourceRequestInfo* request_info = |
204 content::ResourceRequestInfo::ForRequest(url_request); | 203 content::ResourceRequestInfo::ForRequest(url_request); |
205 if (!request_info) | 204 if (!request_info) |
206 return false; | 205 return false; |
207 | 206 |
208 content::BrowserThread::PostTask( | 207 content::BrowserThread::PostTask( |
209 content::BrowserThread::UI, | 208 content::BrowserThread::UI, |
210 FROM_HERE, | 209 FROM_HERE, |
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
377 | 376 |
378 const storage::ChangeObserverList* MediaFileSystemBackend::GetChangeObservers( | 377 const storage::ChangeObserverList* MediaFileSystemBackend::GetChangeObservers( |
379 storage::FileSystemType type) const { | 378 storage::FileSystemType type) const { |
380 return NULL; | 379 return NULL; |
381 } | 380 } |
382 | 381 |
383 const storage::AccessObserverList* MediaFileSystemBackend::GetAccessObservers( | 382 const storage::AccessObserverList* MediaFileSystemBackend::GetAccessObservers( |
384 storage::FileSystemType type) const { | 383 storage::FileSystemType type) const { |
385 return NULL; | 384 return NULL; |
386 } | 385 } |
OLD | NEW |