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

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

Issue 10909182: Make FileSystemContext respect StoragePartitions. filesystem:// urls will be properly isolated (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: patch unittest fix from michael Created 8 years, 3 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_browser_private_api.h" 5 #include "chrome/browser/chromeos/extensions/file_browser_private_api.h"
6 6
7 #include <sys/statvfs.h> 7 #include <sys/statvfs.h>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/base64.h" 10 #include "base/base64.h"
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 #include "chrome/common/chrome_version_info.h" 43 #include "chrome/common/chrome_version_info.h"
44 #include "chrome/common/extensions/extension.h" 44 #include "chrome/common/extensions/extension.h"
45 #include "chrome/common/extensions/extension_constants.h" 45 #include "chrome/common/extensions/extension_constants.h"
46 #include "chrome/common/extensions/extension_icon_set.h" 46 #include "chrome/common/extensions/extension_icon_set.h"
47 #include "chrome/common/extensions/file_browser_handler.h" 47 #include "chrome/common/extensions/file_browser_handler.h"
48 #include "chrome/common/pref_names.h" 48 #include "chrome/common/pref_names.h"
49 #include "chromeos/disks/disk_mount_manager.h" 49 #include "chromeos/disks/disk_mount_manager.h"
50 #include "content/public/browser/child_process_security_policy.h" 50 #include "content/public/browser/child_process_security_policy.h"
51 #include "content/public/browser/render_process_host.h" 51 #include "content/public/browser/render_process_host.h"
52 #include "content/public/browser/render_view_host.h" 52 #include "content/public/browser/render_view_host.h"
53 #include "content/public/browser/storage_partition.h"
53 #include "googleurl/src/gurl.h" 54 #include "googleurl/src/gurl.h"
54 #include "grit/generated_resources.h" 55 #include "grit/generated_resources.h"
55 #include "grit/platform_locale_settings.h" 56 #include "grit/platform_locale_settings.h"
56 #include "net/base/escape.h" 57 #include "net/base/escape.h"
57 #include "ui/base/dialogs/selected_file_info.h" 58 #include "ui/base/dialogs/selected_file_info.h"
58 #include "ui/base/l10n/l10n_util.h" 59 #include "ui/base/l10n/l10n_util.h"
59 #include "webkit/chromeos/fileapi/cros_mount_point_provider.h" 60 #include "webkit/chromeos/fileapi/cros_mount_point_provider.h"
60 #include "webkit/fileapi/file_system_context.h" 61 #include "webkit/fileapi/file_system_context.h"
61 #include "webkit/fileapi/file_system_file_util.h" 62 #include "webkit/fileapi/file_system_file_util.h"
62 #include "webkit/fileapi/file_system_operation_context.h" 63 #include "webkit/fileapi/file_system_operation_context.h"
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
169 int permissions) { 170 int permissions) {
170 ChildProcessSecurityPolicy::GetInstance()->GrantPermissionsForFile( 171 ChildProcessSecurityPolicy::GetInstance()->GrantPermissionsForFile(
171 host->GetProcess()->GetID(), path, permissions); 172 host->GetProcess()->GetID(), path, permissions);
172 } 173 }
173 174
174 void AddDriveMountPoint( 175 void AddDriveMountPoint(
175 Profile* profile, 176 Profile* profile,
176 const std::string& extension_id, 177 const std::string& extension_id,
177 content::RenderViewHost* render_view_host) { 178 content::RenderViewHost* render_view_host) {
178 fileapi::ExternalFileSystemMountPointProvider* provider = 179 fileapi::ExternalFileSystemMountPointProvider* provider =
179 BrowserContext::GetFileSystemContext(profile)->external_provider(); 180 BrowserContext::GetDefaultStoragePartition(profile)->
181 GetFileSystemContext()->external_provider();
180 if (!provider) 182 if (!provider)
181 return; 183 return;
182 184
183 const FilePath mount_point = gdata::util::GetDriveMountPointPath(); 185 const FilePath mount_point = gdata::util::GetDriveMountPointPath();
184 if (!render_view_host || !render_view_host->GetProcess()) 186 if (!render_view_host || !render_view_host->GetProcess())
185 return; 187 return;
186 188
187 // Grant R/W permissions to drive 'folder'. File API layer still 189 // Grant R/W permissions to drive 'folder'. File API layer still
188 // expects this to be satisfied. 190 // expects this to be satisfied.
189 GrantFilePermissionsToHost(render_view_host, 191 GrantFilePermissionsToHost(render_view_host,
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after
447 file_system_context, 449 file_system_context,
448 child_id, 450 child_id,
449 GetExtension())); 451 GetExtension()));
450 } 452 }
451 453
452 bool RequestLocalFileSystemFunction::RunImpl() { 454 bool RequestLocalFileSystemFunction::RunImpl() {
453 if (!dispatcher() || !render_view_host() || !render_view_host()->GetProcess()) 455 if (!dispatcher() || !render_view_host() || !render_view_host()->GetProcess())
454 return false; 456 return false;
455 457
456 scoped_refptr<fileapi::FileSystemContext> file_system_context = 458 scoped_refptr<fileapi::FileSystemContext> file_system_context =
457 BrowserContext::GetFileSystemContext(profile_); 459 BrowserContext::GetDefaultStoragePartition(profile_)->
460 GetFileSystemContext();
458 BrowserThread::PostTask( 461 BrowserThread::PostTask(
459 BrowserThread::FILE, FROM_HERE, 462 BrowserThread::FILE, FROM_HERE,
460 base::Bind( 463 base::Bind(
461 &RequestLocalFileSystemFunction::RequestOnFileThread, 464 &RequestLocalFileSystemFunction::RequestOnFileThread,
462 this, 465 this,
463 file_system_context, 466 file_system_context,
464 source_url_, 467 source_url_,
465 render_view_host()->GetProcess()->GetID())); 468 render_view_host()->GetProcess()->GetID()));
466 // Will finish asynchronously. 469 // Will finish asynchronously.
467 return true; 470 return true;
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
509 if (!render_view_host() || !render_view_host()->GetProcess()) 512 if (!render_view_host() || !render_view_host()->GetProcess())
510 return false; 513 return false;
511 514
512 // First param is url of a file to watch. 515 // First param is url of a file to watch.
513 std::string url; 516 std::string url;
514 if (!args_->GetString(0, &url) || url.empty()) 517 if (!args_->GetString(0, &url) || url.empty())
515 return false; 518 return false;
516 519
517 GURL file_watch_url(url); 520 GURL file_watch_url(url);
518 scoped_refptr<fileapi::FileSystemContext> file_system_context = 521 scoped_refptr<fileapi::FileSystemContext> file_system_context =
519 BrowserContext::GetFileSystemContext(profile_); 522 BrowserContext::GetStoragePartition(profile_,
523 render_view_host()->GetSiteInstance())->GetFileSystemContext();
520 BrowserThread::PostTask( 524 BrowserThread::PostTask(
521 BrowserThread::FILE, FROM_HERE, 525 BrowserThread::FILE, FROM_HERE,
522 base::Bind( 526 base::Bind(
523 &FileWatchBrowserFunctionBase::RunFileWatchOperationOnFileThread, 527 &FileWatchBrowserFunctionBase::RunFileWatchOperationOnFileThread,
524 this, 528 this,
525 file_system_context, 529 file_system_context,
526 FileBrowserEventRouterFactory::GetForProfile(profile_), 530 FileBrowserEventRouterFactory::GetForProfile(profile_),
527 file_watch_url, 531 file_watch_url,
528 extension_id())); 532 extension_id()));
529 533
(...skipping 435 matching lines...) Expand 10 before | Expand all | Expand 10 after
965 LOG(WARNING) << "No associated tab contents"; 969 LOG(WARNING) << "No associated tab contents";
966 return 0; 970 return 0;
967 } 971 }
968 return ExtensionTabUtil::GetTabId(web_contents); 972 return ExtensionTabUtil::GetTabId(web_contents);
969 } 973 }
970 974
971 void FileBrowserFunction::GetLocalPathsOnFileThreadAndRunCallbackOnUIThread( 975 void FileBrowserFunction::GetLocalPathsOnFileThreadAndRunCallbackOnUIThread(
972 const UrlList& file_urls, 976 const UrlList& file_urls,
973 GetLocalPathsCallback callback) { 977 GetLocalPathsCallback callback) {
974 scoped_refptr<fileapi::FileSystemContext> file_system_context = 978 scoped_refptr<fileapi::FileSystemContext> file_system_context =
975 BrowserContext::GetFileSystemContext(profile_); 979 BrowserContext::GetDefaultStoragePartition(profile())->
980 GetFileSystemContext();
976 BrowserThread::PostTask( 981 BrowserThread::PostTask(
977 BrowserThread::FILE, FROM_HERE, 982 BrowserThread::FILE, FROM_HERE,
978 base::Bind( 983 base::Bind(
979 &FileBrowserFunction::GetLocalPathsOnFileThread, 984 &FileBrowserFunction::GetLocalPathsOnFileThread,
980 this, 985 this,
981 file_system_context, file_urls, callback)); 986 file_system_context, file_urls, callback));
982 } 987 }
983 988
984 // GetFileSystemRootPathOnFileThread can only be called from the file thread, 989 // GetFileSystemRootPathOnFileThread can only be called from the file thread,
985 // so here we are. This function takes a vector of virtual paths, converts 990 // so here we are. This function takes a vector of virtual paths, converts
(...skipping 1496 matching lines...) Expand 10 before | Expand all | Expand 10 after
2482 2487
2483 SearchDriveFunction::~SearchDriveFunction() {} 2488 SearchDriveFunction::~SearchDriveFunction() {}
2484 2489
2485 bool SearchDriveFunction::RunImpl() { 2490 bool SearchDriveFunction::RunImpl() {
2486 if (!args_->GetString(0, &query_)) 2491 if (!args_->GetString(0, &query_))
2487 return false; 2492 return false;
2488 2493
2489 if (!args_->GetString(1, &next_feed_)) 2494 if (!args_->GetString(1, &next_feed_))
2490 return false; 2495 return false;
2491 2496
2492 BrowserContext::GetFileSystemContext(profile())->OpenFileSystem( 2497 BrowserContext::GetStoragePartition(
2493 source_url_.GetOrigin(), fileapi::kFileSystemTypeExternal, false, 2498 profile(),
2494 base::Bind(&SearchDriveFunction::OnFileSystemOpened, this)); 2499 render_view_host()->GetSiteInstance())->
michaeln 2012/09/15 01:48:33 In some places in this module, we're looking up th
awong 2012/09/15 02:05:02 Good catch. I'm not sure. I'm reverting them all t
2500 GetFileSystemContext()->OpenFileSystem(
2501 source_url_.GetOrigin(), fileapi::kFileSystemTypeExternal, false,
2502 base::Bind(&SearchDriveFunction::OnFileSystemOpened, this));
2495 return true; 2503 return true;
2496 } 2504 }
2497 2505
2498 void SearchDriveFunction::OnFileSystemOpened( 2506 void SearchDriveFunction::OnFileSystemOpened(
2499 base::PlatformFileError result, 2507 base::PlatformFileError result,
2500 const std::string& file_system_name, 2508 const std::string& file_system_name,
2501 const GURL& file_system_url) { 2509 const GURL& file_system_url) {
2502 if (result != base::PLATFORM_FILE_OK) { 2510 if (result != base::PLATFORM_FILE_OK) {
2503 SendResponse(false); 2511 SendResponse(false);
2504 return; 2512 return;
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
2598 gdata::DriveSystemService* system_service = 2606 gdata::DriveSystemService* system_service =
2599 gdata::DriveSystemServiceFactory::GetForProfile(profile_); 2607 gdata::DriveSystemServiceFactory::GetForProfile(profile_);
2600 if (!system_service || !system_service->file_system()) 2608 if (!system_service || !system_service->file_system())
2601 return false; 2609 return false;
2602 2610
2603 FilePath directory_path = GetVirtualPathFromURL(GURL(file_url_as_string)); 2611 FilePath directory_path = GetVirtualPathFromURL(GURL(file_url_as_string));
2604 system_service->file_system()->RequestDirectoryRefresh(directory_path); 2612 system_service->file_system()->RequestDirectoryRefresh(directory_path);
2605 2613
2606 return true; 2614 return true;
2607 } 2615 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698