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

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: remove useless headers. 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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 #include "chrome/browser/ui/webui/extensions/extension_icon_source.h" 42 #include "chrome/browser/ui/webui/extensions/extension_icon_source.h"
43 #include "chrome/common/extensions/extension.h" 43 #include "chrome/common/extensions/extension.h"
44 #include "chrome/common/extensions/extension_constants.h" 44 #include "chrome/common/extensions/extension_constants.h"
45 #include "chrome/common/extensions/extension_icon_set.h" 45 #include "chrome/common/extensions/extension_icon_set.h"
46 #include "chrome/common/extensions/file_browser_handler.h" 46 #include "chrome/common/extensions/file_browser_handler.h"
47 #include "chrome/common/pref_names.h" 47 #include "chrome/common/pref_names.h"
48 #include "chromeos/disks/disk_mount_manager.h" 48 #include "chromeos/disks/disk_mount_manager.h"
49 #include "content/public/browser/child_process_security_policy.h" 49 #include "content/public/browser/child_process_security_policy.h"
50 #include "content/public/browser/render_process_host.h" 50 #include "content/public/browser/render_process_host.h"
51 #include "content/public/browser/render_view_host.h" 51 #include "content/public/browser/render_view_host.h"
52 #include "content/public/browser/storage_partition.h"
52 #include "googleurl/src/gurl.h" 53 #include "googleurl/src/gurl.h"
53 #include "grit/generated_resources.h" 54 #include "grit/generated_resources.h"
54 #include "grit/platform_locale_settings.h" 55 #include "grit/platform_locale_settings.h"
55 #include "net/base/escape.h" 56 #include "net/base/escape.h"
56 #include "ui/base/dialogs/selected_file_info.h" 57 #include "ui/base/dialogs/selected_file_info.h"
57 #include "ui/base/l10n/l10n_util.h" 58 #include "ui/base/l10n/l10n_util.h"
58 #include "webkit/chromeos/fileapi/cros_mount_point_provider.h" 59 #include "webkit/chromeos/fileapi/cros_mount_point_provider.h"
59 #include "webkit/fileapi/file_system_context.h" 60 #include "webkit/fileapi/file_system_context.h"
60 #include "webkit/fileapi/file_system_file_util.h" 61 #include "webkit/fileapi/file_system_file_util.h"
61 #include "webkit/fileapi/file_system_operation_context.h" 62 #include "webkit/fileapi/file_system_operation_context.h"
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
168 int permissions) { 169 int permissions) {
169 ChildProcessSecurityPolicy::GetInstance()->GrantPermissionsForFile( 170 ChildProcessSecurityPolicy::GetInstance()->GrantPermissionsForFile(
170 host->GetProcess()->GetID(), path, permissions); 171 host->GetProcess()->GetID(), path, permissions);
171 } 172 }
172 173
173 void AddDriveMountPoint( 174 void AddDriveMountPoint(
174 Profile* profile, 175 Profile* profile,
175 const std::string& extension_id, 176 const std::string& extension_id,
176 content::RenderViewHost* render_view_host) { 177 content::RenderViewHost* render_view_host) {
177 fileapi::ExternalFileSystemMountPointProvider* provider = 178 fileapi::ExternalFileSystemMountPointProvider* provider =
178 BrowserContext::GetFileSystemContext(profile)->external_provider(); 179 BrowserContext::GetDefaultStoragePartition(profile)->
180 GetFileSystemContext()->external_provider();
179 if (!provider) 181 if (!provider)
180 return; 182 return;
181 183
182 const FilePath mount_point = gdata::util::GetDriveMountPointPath(); 184 const FilePath mount_point = gdata::util::GetDriveMountPointPath();
183 if (!render_view_host || !render_view_host->GetProcess()) 185 if (!render_view_host || !render_view_host->GetProcess())
184 return; 186 return;
185 187
186 // Grant R/W permissions to drive 'folder'. File API layer still 188 // Grant R/W permissions to drive 'folder'. File API layer still
187 // expects this to be satisfied. 189 // expects this to be satisfied.
188 GrantFilePermissionsToHost(render_view_host, 190 GrantFilePermissionsToHost(render_view_host,
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after
446 file_system_context, 448 file_system_context,
447 child_id, 449 child_id,
448 GetExtension())); 450 GetExtension()));
449 } 451 }
450 452
451 bool RequestLocalFileSystemFunction::RunImpl() { 453 bool RequestLocalFileSystemFunction::RunImpl() {
452 if (!dispatcher() || !render_view_host() || !render_view_host()->GetProcess()) 454 if (!dispatcher() || !render_view_host() || !render_view_host()->GetProcess())
453 return false; 455 return false;
454 456
455 scoped_refptr<fileapi::FileSystemContext> file_system_context = 457 scoped_refptr<fileapi::FileSystemContext> file_system_context =
456 BrowserContext::GetFileSystemContext(profile_); 458 BrowserContext::GetDefaultStoragePartition(profile_)->
459 GetFileSystemContext();
457 BrowserThread::PostTask( 460 BrowserThread::PostTask(
458 BrowserThread::FILE, FROM_HERE, 461 BrowserThread::FILE, FROM_HERE,
459 base::Bind( 462 base::Bind(
460 &RequestLocalFileSystemFunction::RequestOnFileThread, 463 &RequestLocalFileSystemFunction::RequestOnFileThread,
461 this, 464 this,
462 file_system_context, 465 file_system_context,
463 source_url_, 466 source_url_,
464 render_view_host()->GetProcess()->GetID())); 467 render_view_host()->GetProcess()->GetID()));
465 // Will finish asynchronously. 468 // Will finish asynchronously.
466 return true; 469 return true;
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
508 if (!render_view_host() || !render_view_host()->GetProcess()) 511 if (!render_view_host() || !render_view_host()->GetProcess())
509 return false; 512 return false;
510 513
511 // First param is url of a file to watch. 514 // First param is url of a file to watch.
512 std::string url; 515 std::string url;
513 if (!args_->GetString(0, &url) || url.empty()) 516 if (!args_->GetString(0, &url) || url.empty())
514 return false; 517 return false;
515 518
516 GURL file_watch_url(url); 519 GURL file_watch_url(url);
517 scoped_refptr<fileapi::FileSystemContext> file_system_context = 520 scoped_refptr<fileapi::FileSystemContext> file_system_context =
518 BrowserContext::GetFileSystemContext(profile_); 521 BrowserContext::GetDefaultStoragePartition(profile_)->
522 GetFileSystemContext();
519 BrowserThread::PostTask( 523 BrowserThread::PostTask(
520 BrowserThread::FILE, FROM_HERE, 524 BrowserThread::FILE, FROM_HERE,
521 base::Bind( 525 base::Bind(
522 &FileWatchBrowserFunctionBase::RunFileWatchOperationOnFileThread, 526 &FileWatchBrowserFunctionBase::RunFileWatchOperationOnFileThread,
523 this, 527 this,
524 file_system_context, 528 file_system_context,
525 FileBrowserEventRouterFactory::GetForProfile(profile_), 529 FileBrowserEventRouterFactory::GetForProfile(profile_),
526 file_watch_url, 530 file_watch_url,
527 extension_id())); 531 extension_id()));
528 532
(...skipping 435 matching lines...) Expand 10 before | Expand all | Expand 10 after
964 LOG(WARNING) << "No associated tab contents"; 968 LOG(WARNING) << "No associated tab contents";
965 return 0; 969 return 0;
966 } 970 }
967 return ExtensionTabUtil::GetTabId(web_contents); 971 return ExtensionTabUtil::GetTabId(web_contents);
968 } 972 }
969 973
970 void FileBrowserFunction::GetLocalPathsOnFileThreadAndRunCallbackOnUIThread( 974 void FileBrowserFunction::GetLocalPathsOnFileThreadAndRunCallbackOnUIThread(
971 const UrlList& file_urls, 975 const UrlList& file_urls,
972 GetLocalPathsCallback callback) { 976 GetLocalPathsCallback callback) {
973 scoped_refptr<fileapi::FileSystemContext> file_system_context = 977 scoped_refptr<fileapi::FileSystemContext> file_system_context =
974 BrowserContext::GetFileSystemContext(profile_); 978 BrowserContext::GetDefaultStoragePartition(profile())->
979 GetFileSystemContext();
975 BrowserThread::PostTask( 980 BrowserThread::PostTask(
976 BrowserThread::FILE, FROM_HERE, 981 BrowserThread::FILE, FROM_HERE,
977 base::Bind( 982 base::Bind(
978 &FileBrowserFunction::GetLocalPathsOnFileThread, 983 &FileBrowserFunction::GetLocalPathsOnFileThread,
979 this, 984 this,
980 file_system_context, file_urls, callback)); 985 file_system_context, file_urls, callback));
981 } 986 }
982 987
983 // GetFileSystemRootPathOnFileThread can only be called from the file thread, 988 // GetFileSystemRootPathOnFileThread can only be called from the file thread,
984 // so here we are. This function takes a vector of virtual paths, converts 989 // so here we are. This function takes a vector of virtual paths, converts
(...skipping 1511 matching lines...) Expand 10 before | Expand all | Expand 10 after
2496 2501
2497 SearchDriveFunction::~SearchDriveFunction() {} 2502 SearchDriveFunction::~SearchDriveFunction() {}
2498 2503
2499 bool SearchDriveFunction::RunImpl() { 2504 bool SearchDriveFunction::RunImpl() {
2500 if (!args_->GetString(0, &query_)) 2505 if (!args_->GetString(0, &query_))
2501 return false; 2506 return false;
2502 2507
2503 if (!args_->GetString(1, &next_feed_)) 2508 if (!args_->GetString(1, &next_feed_))
2504 return false; 2509 return false;
2505 2510
2506 BrowserContext::GetFileSystemContext(profile())->OpenFileSystem( 2511 BrowserContext::GetDefaultStoragePartition(profile())->
2507 source_url_.GetOrigin(), fileapi::kFileSystemTypeExternal, false, 2512 GetFileSystemContext()->OpenFileSystem(
2508 base::Bind(&SearchDriveFunction::OnFileSystemOpened, this)); 2513 source_url_.GetOrigin(), fileapi::kFileSystemTypeExternal, false,
2514 base::Bind(&SearchDriveFunction::OnFileSystemOpened, this));
2509 return true; 2515 return true;
2510 } 2516 }
2511 2517
2512 void SearchDriveFunction::OnFileSystemOpened( 2518 void SearchDriveFunction::OnFileSystemOpened(
2513 base::PlatformFileError result, 2519 base::PlatformFileError result,
2514 const std::string& file_system_name, 2520 const std::string& file_system_name,
2515 const GURL& file_system_url) { 2521 const GURL& file_system_url) {
2516 if (result != base::PLATFORM_FILE_OK) { 2522 if (result != base::PLATFORM_FILE_OK) {
2517 SendResponse(false); 2523 SendResponse(false);
2518 return; 2524 return;
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
2612 gdata::DriveSystemService* system_service = 2618 gdata::DriveSystemService* system_service =
2613 gdata::DriveSystemServiceFactory::GetForProfile(profile_); 2619 gdata::DriveSystemServiceFactory::GetForProfile(profile_);
2614 if (!system_service || !system_service->file_system()) 2620 if (!system_service || !system_service->file_system())
2615 return false; 2621 return false;
2616 2622
2617 FilePath directory_path = GetVirtualPathFromURL(GURL(file_url_as_string)); 2623 FilePath directory_path = GetVirtualPathFromURL(GURL(file_url_as_string));
2618 system_service->file_system()->RequestDirectoryRefresh(directory_path); 2624 system_service->file_system()->RequestDirectoryRefresh(directory_path);
2619 2625
2620 return true; 2626 return true;
2621 } 2627 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698