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

Side by Side Diff: chrome/browser/chromeos/extensions/file_manager/file_browser_private_api.cc

Issue 18129002: Update the child process security policy to use explicit permission grants. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Change RVH to use FileChooserParam mode Created 7 years, 5 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
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 #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
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()->GrantCreateReadWriteFile(
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 301 matching lines...) Expand 10 before | Expand all | Expand 10 after
545 if (!provider) 536 if (!provider)
546 return false; 537 return false;
547 538
548 // Grant full access to File API from this component extension. 539 // Grant full access to File API from this component extension.
549 provider->GrantFullAccessToExtension(extension_->id()); 540 provider->GrantFullAccessToExtension(extension_->id());
550 541
551 // Grant R/W file permissions to the renderer hosting component 542 // Grant R/W file permissions to the renderer hosting component
552 // extension for all paths exposed by our local file system provider. 543 // extension for all paths exposed by our local file system provider.
553 std::vector<base::FilePath> root_dirs = provider->GetRootDirectories(); 544 std::vector<base::FilePath> root_dirs = provider->GetRootDirectories();
554 for (size_t i = 0; i < root_dirs.size(); ++i) { 545 for (size_t i = 0; i < root_dirs.size(); ++i) {
555 ChildProcessSecurityPolicy::GetInstance()->GrantPermissionsForFile( 546 ChildProcessSecurityPolicy::GetInstance()->GrantCreateReadWriteFile(
556 child_id, root_dirs[i], 547 child_id, root_dirs[i]);
557 file_handler_util::GetReadWritePermissions());
558 } 548 }
559 return true; 549 return true;
560 } 550 }
561 551
562 bool RequestFileSystemFunction::RunImpl() { 552 bool RequestFileSystemFunction::RunImpl() {
563 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 553 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
564 554
565 if (!dispatcher() || !render_view_host() || !render_view_host()->GetProcess()) 555 if (!dispatcher() || !render_view_host() || !render_view_host()->GetProcess())
566 return false; 556 return false;
567 557
(...skipping 2526 matching lines...) Expand 10 before | Expand all | Expand 10 after
3094 zoom_type = content::PAGE_ZOOM_OUT; 3084 zoom_type = content::PAGE_ZOOM_OUT;
3095 } else if (operation == "reset") { 3085 } else if (operation == "reset") {
3096 zoom_type = content::PAGE_ZOOM_RESET; 3086 zoom_type = content::PAGE_ZOOM_RESET;
3097 } else { 3087 } else {
3098 NOTREACHED(); 3088 NOTREACHED();
3099 return false; 3089 return false;
3100 } 3090 }
3101 view_host->Zoom(zoom_type); 3091 view_host->Zoom(zoom_type);
3102 return true; 3092 return true;
3103 } 3093 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698