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/chromeos/extensions/file_browser_private_api.h" | 5 #include "chrome/browser/chromeos/extensions/file_browser_private_api.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/base64.h" | 9 #include "base/base64.h" |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
191 GrantFilePermissionsToHost(render_view_host, | 191 GrantFilePermissionsToHost(render_view_host, |
192 mount_point, | 192 mount_point, |
193 file_handler_util::GetReadWritePermissions()); | 193 file_handler_util::GetReadWritePermissions()); |
194 | 194 |
195 // Grant R/W permission for tmp and pinned cache folder. | 195 // Grant R/W permission for tmp and pinned cache folder. |
196 gdata::GDataSystemService* system_service = | 196 gdata::GDataSystemService* system_service = |
197 gdata::GDataSystemServiceFactory::GetForProfile(profile); | 197 gdata::GDataSystemServiceFactory::GetForProfile(profile); |
198 // |system_service| is NULL if incognito window / guest login. | 198 // |system_service| is NULL if incognito window / guest login. |
199 if (!system_service || !system_service->file_system()) | 199 if (!system_service || !system_service->file_system()) |
200 return; | 200 return; |
201 gdata::GDataFileSystem* gdata_file_system = system_service->file_system(); | 201 gdata::GDataCache* cache = system_service->cache(); |
202 | 202 |
203 // We check permissions for raw cache file paths only for read-only | 203 // We check permissions for raw cache file paths only for read-only |
204 // operations (when fileEntry.file() is called), so read only permissions | 204 // operations (when fileEntry.file() is called), so read only permissions |
205 // should be sufficient for all cache paths. For the rest of supported | 205 // should be sufficient for all cache paths. For the rest of supported |
206 // operations the file access check is done for drive/ paths. | 206 // operations the file access check is done for drive/ paths. |
207 GrantFilePermissionsToHost(render_view_host, | 207 GrantFilePermissionsToHost(render_view_host, |
208 gdata_file_system->GetCacheDirectoryPath( | 208 cache->GetCacheDirectoryPath( |
209 gdata::GDataCache::CACHE_TYPE_TMP), | 209 gdata::GDataCache::CACHE_TYPE_TMP), |
210 file_handler_util::GetReadOnlyPermissions()); | 210 file_handler_util::GetReadOnlyPermissions()); |
211 GrantFilePermissionsToHost( | 211 GrantFilePermissionsToHost( |
212 render_view_host, | 212 render_view_host, |
213 gdata_file_system->GetCacheDirectoryPath( | 213 cache->GetCacheDirectoryPath( |
214 gdata::GDataCache::CACHE_TYPE_PERSISTENT), | 214 gdata::GDataCache::CACHE_TYPE_PERSISTENT), |
215 file_handler_util::GetReadOnlyPermissions()); | 215 file_handler_util::GetReadOnlyPermissions()); |
216 | 216 |
| 217 gdata::GDataFileSystem* gdata_file_system = system_service->file_system(); |
217 provider->AddRemoteMountPoint( | 218 provider->AddRemoteMountPoint( |
218 mount_point, | 219 mount_point, |
219 new gdata::GDataFileSystemProxy(gdata_file_system)); | 220 new gdata::GDataFileSystemProxy(gdata_file_system)); |
220 | 221 |
221 FilePath mount_point_virtual; | 222 FilePath mount_point_virtual; |
222 if (provider->GetVirtualPath(mount_point, &mount_point_virtual)) | 223 if (provider->GetVirtualPath(mount_point, &mount_point_virtual)) |
223 provider->GrantFileAccessToExtension(extension_id, mount_point_virtual); | 224 provider->GrantFileAccessToExtension(extension_id, mount_point_virtual); |
224 } | 225 } |
225 | 226 |
226 // Given a file url, find the virtual FilePath associated with it. | 227 // Given a file url, find the virtual FilePath associated with it. |
(...skipping 769 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
996 return; | 997 return; |
997 } | 998 } |
998 | 999 |
999 const FilePath& source_path = files[0].path; | 1000 const FilePath& source_path = files[0].path; |
1000 const FilePath::StringType& display_name = files[0].display_name; | 1001 const FilePath::StringType& display_name = files[0].display_name; |
1001 // Check if the source path is under GData cache directory. | 1002 // Check if the source path is under GData cache directory. |
1002 gdata::GDataSystemService* system_service = | 1003 gdata::GDataSystemService* system_service = |
1003 gdata::GDataSystemServiceFactory::GetForProfile(profile_); | 1004 gdata::GDataSystemServiceFactory::GetForProfile(profile_); |
1004 gdata::GDataFileSystem* file_system = | 1005 gdata::GDataFileSystem* file_system = |
1005 system_service ? system_service->file_system() : NULL; | 1006 system_service ? system_service->file_system() : NULL; |
1006 if (file_system && file_system->IsUnderGDataCacheDirectory(source_path)) { | 1007 gdata::GDataCache* cache = |
| 1008 system_service ? system_service->cache() : NULL; |
| 1009 if (file_system && cache && cache->IsUnderGDataCacheDirectory(source_path)) { |
1007 file_system->SetMountedState( | 1010 file_system->SetMountedState( |
1008 source_path, | 1011 source_path, |
1009 true, | 1012 true, |
1010 base::Bind(&AddMountFunction::OnMountedStateSet, this, mount_type_str, | 1013 base::Bind(&AddMountFunction::OnMountedStateSet, this, mount_type_str, |
1011 display_name)); | 1014 display_name)); |
1012 } else { | 1015 } else { |
1013 OnMountedStateSet(mount_type_str, display_name, | 1016 OnMountedStateSet(mount_type_str, display_name, |
1014 base::PLATFORM_FILE_OK, source_path); | 1017 base::PLATFORM_FILE_OK, source_path); |
1015 } | 1018 } |
1016 } | 1019 } |
(...skipping 1113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2130 gdata::GDataSystemService* system_service = | 2133 gdata::GDataSystemService* system_service = |
2131 gdata::GDataSystemServiceFactory::GetForProfile(profile_); | 2134 gdata::GDataSystemServiceFactory::GetForProfile(profile_); |
2132 if (!system_service || !system_service->file_system()) | 2135 if (!system_service || !system_service->file_system()) |
2133 return false; | 2136 return false; |
2134 | 2137 |
2135 FilePath directory_path = GetVirtualPathFromURL(GURL(file_url_as_string)); | 2138 FilePath directory_path = GetVirtualPathFromURL(GURL(file_url_as_string)); |
2136 system_service->file_system()->RequestDirectoryRefresh(directory_path); | 2139 system_service->file_system()->RequestDirectoryRefresh(directory_path); |
2137 | 2140 |
2138 return true; | 2141 return true; |
2139 } | 2142 } |
OLD | NEW |