| 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_manager/file_browser_private_a
pi.h" | 5 #include "chrome/browser/chromeos/extensions/file_manager/file_browser_private_a
pi.h" |
| 6 | 6 |
| 7 #include <sys/stat.h> | 7 #include <sys/stat.h> |
| 8 #include <sys/statvfs.h> | 8 #include <sys/statvfs.h> |
| 9 #include <sys/types.h> | 9 #include <sys/types.h> |
| 10 #include <utime.h> | 10 #include <utime.h> |
| (...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 194 mount_info->SetString("mountPath", relative_mount_path.value()); | 194 mount_info->SetString("mountPath", relative_mount_path.value()); |
| 195 } | 195 } |
| 196 | 196 |
| 197 mount_info->SetString("mountCondition", | 197 mount_info->SetString("mountCondition", |
| 198 DiskMountManager::MountConditionToString( | 198 DiskMountManager::MountConditionToString( |
| 199 mount_point_info.mount_condition)); | 199 mount_point_info.mount_condition)); |
| 200 | 200 |
| 201 return mount_info; | 201 return mount_info; |
| 202 } | 202 } |
| 203 | 203 |
| 204 // Gives the extension renderer |host| file |permissions| for the given |path|. | |
| 205 void GrantFilePermissionsToHost(content::RenderViewHost* host, | |
| 206 const base::FilePath& path, | |
| 207 int permissions) { | |
| 208 ChildProcessSecurityPolicy::GetInstance()->GrantPermissionsForFile( | |
| 209 host->GetProcess()->GetID(), path, permissions); | |
| 210 } | |
| 211 | |
| 212 void SetDriveMountPointPermissions( | 204 void SetDriveMountPointPermissions( |
| 213 Profile* profile, | 205 Profile* profile, |
| 214 const std::string& extension_id, | 206 const std::string& extension_id, |
| 215 content::RenderViewHost* render_view_host) { | 207 content::RenderViewHost* render_view_host) { |
| 216 if (!render_view_host || | 208 if (!render_view_host || |
| 217 !render_view_host->GetSiteInstance() || !render_view_host->GetProcess()) { | 209 !render_view_host->GetSiteInstance() || !render_view_host->GetProcess()) { |
| 218 return; | 210 return; |
| 219 } | 211 } |
| 220 | 212 |
| 221 content::SiteInstance* site_instance = render_view_host->GetSiteInstance(); | 213 content::SiteInstance* site_instance = render_view_host->GetSiteInstance(); |
| 222 fileapi::ExternalFileSystemMountPointProvider* provider = | 214 fileapi::ExternalFileSystemMountPointProvider* provider = |
| 223 BrowserContext::GetStoragePartition(profile, site_instance)-> | 215 BrowserContext::GetStoragePartition(profile, site_instance)-> |
| 224 GetFileSystemContext()->external_provider(); | 216 GetFileSystemContext()->external_provider(); |
| 225 if (!provider) | 217 if (!provider) |
| 226 return; | 218 return; |
| 227 | 219 |
| 228 const base::FilePath mount_point = drive::util::GetDriveMountPointPath(); | 220 const base::FilePath mount_point = drive::util::GetDriveMountPointPath(); |
| 229 // Grant R/W permissions to drive 'folder'. File API layer still | 221 // Grant R/W permissions to drive 'folder'. File API layer still |
| 230 // expects this to be satisfied. | 222 // expects this to be satisfied. |
| 231 GrantFilePermissionsToHost(render_view_host, | 223 ChildProcessSecurityPolicy::GetInstance()->GrantReadWriteFile( |
| 232 mount_point, | 224 render_view_host->GetProcess()->GetID(), mount_point); |
| 233 file_handler_util::GetReadWritePermissions()); | |
| 234 | 225 |
| 235 base::FilePath mount_point_virtual; | 226 base::FilePath mount_point_virtual; |
| 236 if (provider->GetVirtualPath(mount_point, &mount_point_virtual)) | 227 if (provider->GetVirtualPath(mount_point, &mount_point_virtual)) |
| 237 provider->GrantFileAccessToExtension(extension_id, mount_point_virtual); | 228 provider->GrantFileAccessToExtension(extension_id, mount_point_virtual); |
| 238 } | 229 } |
| 239 | 230 |
| 240 // Finds an icon in the list of icons. If unable to find an icon of the exact | 231 // Finds an icon in the list of icons. If unable to find an icon of the exact |
| 241 // size requested, returns one with the next larger size. If all icons are | 232 // size requested, returns one with the next larger size. If all icons are |
| 242 // smaller than the preferred size, we'll return the largest one available. | 233 // smaller than the preferred size, we'll return the largest one available. |
| 243 // Icons must be sorted by the icon size, smallest to largest. If there are no | 234 // Icons must be sorted by the icon size, smallest to largest. If there are no |
| (...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 546 if (!provider) | 537 if (!provider) |
| 547 return false; | 538 return false; |
| 548 | 539 |
| 549 // Grant full access to File API from this component extension. | 540 // Grant full access to File API from this component extension. |
| 550 provider->GrantFullAccessToExtension(extension_->id()); | 541 provider->GrantFullAccessToExtension(extension_->id()); |
| 551 | 542 |
| 552 // Grant R/W file permissions to the renderer hosting component | 543 // Grant R/W file permissions to the renderer hosting component |
| 553 // extension for all paths exposed by our local file system provider. | 544 // extension for all paths exposed by our local file system provider. |
| 554 std::vector<base::FilePath> root_dirs = provider->GetRootDirectories(); | 545 std::vector<base::FilePath> root_dirs = provider->GetRootDirectories(); |
| 555 for (size_t i = 0; i < root_dirs.size(); ++i) { | 546 for (size_t i = 0; i < root_dirs.size(); ++i) { |
| 556 ChildProcessSecurityPolicy::GetInstance()->GrantPermissionsForFile( | 547 ChildProcessSecurityPolicy::GetInstance()->GrantReadWriteFile( |
| 557 child_id, root_dirs[i], | 548 child_id, root_dirs[i]); |
| 558 file_handler_util::GetReadWritePermissions()); | |
| 559 } | 549 } |
| 560 return true; | 550 return true; |
| 561 } | 551 } |
| 562 | 552 |
| 563 bool RequestFileSystemFunction::RunImpl() { | 553 bool RequestFileSystemFunction::RunImpl() { |
| 564 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 554 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 565 | 555 |
| 566 if (!dispatcher() || !render_view_host() || !render_view_host()->GetProcess()) | 556 if (!dispatcher() || !render_view_host() || !render_view_host()->GetProcess()) |
| 567 return false; | 557 return false; |
| 568 | 558 |
| (...skipping 2537 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3106 zoom_type = content::PAGE_ZOOM_OUT; | 3096 zoom_type = content::PAGE_ZOOM_OUT; |
| 3107 } else if (operation == "reset") { | 3097 } else if (operation == "reset") { |
| 3108 zoom_type = content::PAGE_ZOOM_RESET; | 3098 zoom_type = content::PAGE_ZOOM_RESET; |
| 3109 } else { | 3099 } else { |
| 3110 NOTREACHED(); | 3100 NOTREACHED(); |
| 3111 return false; | 3101 return false; |
| 3112 } | 3102 } |
| 3113 view_host->Zoom(zoom_type); | 3103 view_host->Zoom(zoom_type); |
| 3114 return true; | 3104 return true; |
| 3115 } | 3105 } |
| OLD | NEW |