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

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

Issue 18344013: fileapi: Rename FileSystemMountProvider to FileSystemBackend (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase 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 17 matching lines...) Expand all
28 #include "chrome/browser/chromeos/drive/file_system_interface.h" 28 #include "chrome/browser/chromeos/drive/file_system_interface.h"
29 #include "chrome/browser/chromeos/drive/file_system_util.h" 29 #include "chrome/browser/chromeos/drive/file_system_util.h"
30 #include "chrome/browser/chromeos/drive/job_list.h" 30 #include "chrome/browser/chromeos/drive/job_list.h"
31 #include "chrome/browser/chromeos/drive/logging.h" 31 #include "chrome/browser/chromeos/drive/logging.h"
32 #include "chrome/browser/chromeos/extensions/file_manager/file_browser_handler.h " 32 #include "chrome/browser/chromeos/extensions/file_manager/file_browser_handler.h "
33 #include "chrome/browser/chromeos/extensions/file_manager/file_browser_private_a pi_factory.h" 33 #include "chrome/browser/chromeos/extensions/file_manager/file_browser_private_a pi_factory.h"
34 #include "chrome/browser/chromeos/extensions/file_manager/file_handler_util.h" 34 #include "chrome/browser/chromeos/extensions/file_manager/file_handler_util.h"
35 #include "chrome/browser/chromeos/extensions/file_manager/file_manager_event_rou ter.h" 35 #include "chrome/browser/chromeos/extensions/file_manager/file_manager_event_rou ter.h"
36 #include "chrome/browser/chromeos/extensions/file_manager/file_manager_util.h" 36 #include "chrome/browser/chromeos/extensions/file_manager/file_manager_util.h"
37 #include "chrome/browser/chromeos/extensions/file_manager/zip_file_creator.h" 37 #include "chrome/browser/chromeos/extensions/file_manager/zip_file_creator.h"
38 #include "chrome/browser/chromeos/fileapi/cros_mount_point_provider.h" 38 #include "chrome/browser/chromeos/fileapi/file_system_backend.h"
39 #include "chrome/browser/chromeos/settings/cros_settings.h" 39 #include "chrome/browser/chromeos/settings/cros_settings.h"
40 #include "chrome/browser/chromeos/system/statistics_provider.h" 40 #include "chrome/browser/chromeos/system/statistics_provider.h"
41 #include "chrome/browser/extensions/api/file_handlers/app_file_handler_util.h" 41 #include "chrome/browser/extensions/api/file_handlers/app_file_handler_util.h"
42 #include "chrome/browser/extensions/extension_function_dispatcher.h" 42 #include "chrome/browser/extensions/extension_function_dispatcher.h"
43 #include "chrome/browser/extensions/extension_function_registry.h" 43 #include "chrome/browser/extensions/extension_function_registry.h"
44 #include "chrome/browser/extensions/extension_service.h" 44 #include "chrome/browser/extensions/extension_service.h"
45 #include "chrome/browser/extensions/extension_system.h" 45 #include "chrome/browser/extensions/extension_system.h"
46 #include "chrome/browser/extensions/extension_tab_util.h" 46 #include "chrome/browser/extensions/extension_tab_util.h"
47 #include "chrome/browser/google_apis/gdata_wapi_parser.h" 47 #include "chrome/browser/google_apis/gdata_wapi_parser.h"
48 #include "chrome/browser/lifetime/application_lifetime.h" 48 #include "chrome/browser/lifetime/application_lifetime.h"
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
212 void SetDriveMountPointPermissions( 212 void SetDriveMountPointPermissions(
213 Profile* profile, 213 Profile* profile,
214 const std::string& extension_id, 214 const std::string& extension_id,
215 content::RenderViewHost* render_view_host) { 215 content::RenderViewHost* render_view_host) {
216 if (!render_view_host || 216 if (!render_view_host ||
217 !render_view_host->GetSiteInstance() || !render_view_host->GetProcess()) { 217 !render_view_host->GetSiteInstance() || !render_view_host->GetProcess()) {
218 return; 218 return;
219 } 219 }
220 220
221 content::SiteInstance* site_instance = render_view_host->GetSiteInstance(); 221 content::SiteInstance* site_instance = render_view_host->GetSiteInstance();
222 fileapi::ExternalFileSystemMountPointProvider* provider = 222 fileapi::ExternalFileSystemBackend* backend =
223 BrowserContext::GetStoragePartition(profile, site_instance)-> 223 BrowserContext::GetStoragePartition(profile, site_instance)->
224 GetFileSystemContext()->external_provider(); 224 GetFileSystemContext()->external_backend();
225 if (!provider) 225 if (!backend)
226 return; 226 return;
227 227
228 const base::FilePath mount_point = drive::util::GetDriveMountPointPath(); 228 const base::FilePath mount_point = drive::util::GetDriveMountPointPath();
229 // Grant R/W permissions to drive 'folder'. File API layer still 229 // Grant R/W permissions to drive 'folder'. File API layer still
230 // expects this to be satisfied. 230 // expects this to be satisfied.
231 GrantFilePermissionsToHost(render_view_host, 231 GrantFilePermissionsToHost(render_view_host,
232 mount_point, 232 mount_point,
233 file_handler_util::GetReadWritePermissions()); 233 file_handler_util::GetReadWritePermissions());
234 234
235 base::FilePath mount_point_virtual; 235 base::FilePath mount_point_virtual;
236 if (provider->GetVirtualPath(mount_point, &mount_point_virtual)) 236 if (backend->GetVirtualPath(mount_point, &mount_point_virtual))
237 provider->GrantFileAccessToExtension(extension_id, mount_point_virtual); 237 backend->GrantFileAccessToExtension(extension_id, mount_point_virtual);
238 } 238 }
239 239
240 // Finds an icon in the list of icons. If unable to find an icon of the exact 240 // 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 241 // 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. 242 // 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 243 // Icons must be sorted by the icon size, smallest to largest. If there are no
244 // icons in the list, returns an empty URL. 244 // icons in the list, returns an empty URL.
245 GURL FindPreferredIcon(const InstalledApp::IconList& icons, 245 GURL FindPreferredIcon(const InstalledApp::IconList& icons,
246 int preferred_size) { 246 int preferred_size) {
247 GURL result; 247 GURL result;
(...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after
533 return false; 533 return false;
534 534
535 // Make sure that only component extension can access the entire 535 // Make sure that only component extension can access the entire
536 // local file system. 536 // local file system.
537 if (extension_->location() != extensions::Manifest::COMPONENT) { 537 if (extension_->location() != extensions::Manifest::COMPONENT) {
538 NOTREACHED() << "Private method access by non-component extension " 538 NOTREACHED() << "Private method access by non-component extension "
539 << extension->id(); 539 << extension->id();
540 return false; 540 return false;
541 } 541 }
542 542
543 fileapi::ExternalFileSystemMountPointProvider* provider = 543 fileapi::ExternalFileSystemBackend* backend =
544 file_system_context->external_provider(); 544 file_system_context->external_backend();
545 if (!provider) 545 if (!backend)
546 return false; 546 return false;
547 547
548 // Grant full access to File API from this component extension. 548 // Grant full access to File API from this component extension.
549 provider->GrantFullAccessToExtension(extension_->id()); 549 backend->GrantFullAccessToExtension(extension_->id());
550 550
551 // Grant R/W file permissions to the renderer hosting component 551 // Grant R/W file permissions to the renderer hosting component
552 // extension for all paths exposed by our local file system provider. 552 // extension for all paths exposed by our local file system backend.
553 std::vector<base::FilePath> root_dirs = provider->GetRootDirectories(); 553 std::vector<base::FilePath> root_dirs = backend->GetRootDirectories();
554 for (size_t i = 0; i < root_dirs.size(); ++i) { 554 for (size_t i = 0; i < root_dirs.size(); ++i) {
555 ChildProcessSecurityPolicy::GetInstance()->GrantPermissionsForFile( 555 ChildProcessSecurityPolicy::GetInstance()->GrantPermissionsForFile(
556 child_id, root_dirs[i], 556 child_id, root_dirs[i],
557 file_handler_util::GetReadWritePermissions()); 557 file_handler_util::GetReadWritePermissions());
558 } 558 }
559 return true; 559 return true;
560 } 560 }
561 561
562 bool RequestFileSystemFunction::RunImpl() { 562 bool RequestFileSystemFunction::RunImpl() {
563 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 563 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
(...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after
899 if (!files_list->GetString(i, &file_url_str)) 899 if (!files_list->GetString(i, &file_url_str))
900 return false; 900 return false;
901 901
902 if (mime_types_list->GetSize() != 0 && 902 if (mime_types_list->GetSize() != 0 &&
903 !mime_types_list->GetString(i, &info.mime_type)) 903 !mime_types_list->GetString(i, &info.mime_type))
904 return false; 904 return false;
905 905
906 GURL file_url(file_url_str); 906 GURL file_url(file_url_str);
907 fileapi::FileSystemURL file_system_url( 907 fileapi::FileSystemURL file_system_url(
908 file_system_context->CrackURL(file_url)); 908 file_system_context->CrackURL(file_url));
909 if (!chromeos::CrosMountPointProvider::CanHandleURL(file_system_url)) 909 if (!chromeos::FileSystemBackend::CanHandleURL(file_system_url))
910 continue; 910 continue;
911 911
912 file_urls.push_back(file_url); 912 file_urls.push_back(file_url);
913 file_paths.push_back(file_system_url.path()); 913 file_paths.push_back(file_system_url.path());
914 914
915 info.file_url = file_url; 915 info.file_url = file_url;
916 info.file_path = file_system_url.path(); 916 info.file_path = file_system_url.path();
917 info_list.push_back(info); 917 info_list.push_back(info);
918 918
919 if (google_apis::ResourceEntry::ClassifyEntryKindByFileExtension( 919 if (google_apis::ResourceEntry::ClassifyEntryKindByFileExtension(
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
1038 GetFileSystemContext(); 1038 GetFileSystemContext();
1039 1039
1040 std::vector<FileSystemURL> file_urls; 1040 std::vector<FileSystemURL> file_urls;
1041 for (size_t i = 0; i < files_list->GetSize(); i++) { 1041 for (size_t i = 0; i < files_list->GetSize(); i++) {
1042 std::string file_url_str; 1042 std::string file_url_str;
1043 if (!files_list->GetString(i, &file_url_str)) { 1043 if (!files_list->GetString(i, &file_url_str)) {
1044 error_ = kInvalidFileUrl; 1044 error_ = kInvalidFileUrl;
1045 return false; 1045 return false;
1046 } 1046 }
1047 FileSystemURL url = file_system_context->CrackURL(GURL(file_url_str)); 1047 FileSystemURL url = file_system_context->CrackURL(GURL(file_url_str));
1048 if (!chromeos::CrosMountPointProvider::CanHandleURL(url)) { 1048 if (!chromeos::FileSystemBackend::CanHandleURL(url)) {
1049 error_ = kInvalidFileUrl; 1049 error_ = kInvalidFileUrl;
1050 return false; 1050 return false;
1051 } 1051 }
1052 file_urls.push_back(url); 1052 file_urls.push_back(url);
1053 } 1053 }
1054 1054
1055 WebContents* web_contents = 1055 WebContents* web_contents =
1056 dispatcher()->delegate()->GetAssociatedWebContents(); 1056 dispatcher()->delegate()->GetAssociatedWebContents();
1057 int32 tab_id = 0; 1057 int32 tab_id = 0;
1058 if (web_contents) 1058 if (web_contents)
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
1156 DCHECK(render_view_host()); 1156 DCHECK(render_view_host());
1157 1157
1158 content::SiteInstance* site_instance = render_view_host()->GetSiteInstance(); 1158 content::SiteInstance* site_instance = render_view_host()->GetSiteInstance();
1159 scoped_refptr<fileapi::FileSystemContext> file_system_context = 1159 scoped_refptr<fileapi::FileSystemContext> file_system_context =
1160 BrowserContext::GetStoragePartition(profile(), site_instance)-> 1160 BrowserContext::GetStoragePartition(profile(), site_instance)->
1161 GetFileSystemContext(); 1161 GetFileSystemContext();
1162 1162
1163 const fileapi::FileSystemURL filesystem_url( 1163 const fileapi::FileSystemURL filesystem_url(
1164 file_system_context->CrackURL(url)); 1164 file_system_context->CrackURL(url));
1165 base::FilePath path; 1165 base::FilePath path;
1166 if (!chromeos::CrosMountPointProvider::CanHandleURL(filesystem_url)) 1166 if (!chromeos::FileSystemBackend::CanHandleURL(filesystem_url))
1167 return base::FilePath(); 1167 return base::FilePath();
1168 return filesystem_url.path(); 1168 return filesystem_url.path();
1169 } 1169 }
1170 1170
1171 void FileBrowserFunction::GetSelectedFileInfo( 1171 void FileBrowserFunction::GetSelectedFileInfo(
1172 const UrlList& file_urls, 1172 const UrlList& file_urls,
1173 bool for_opening, 1173 bool for_opening,
1174 GetSelectedFileInfoCallback callback) { 1174 GetSelectedFileInfoCallback callback) {
1175 scoped_ptr<GetSelectedFileInfoParams> params(new GetSelectedFileInfoParams); 1175 scoped_ptr<GetSelectedFileInfoParams> params(new GetSelectedFileInfoParams);
1176 params->for_opening = for_opening; 1176 params->for_opening = for_opening;
(...skipping 1872 matching lines...) Expand 10 before | Expand all | Expand 10 after
3049 std::string name; 3049 std::string name;
3050 if (!args_->GetString(1, &name)) 3050 if (!args_->GetString(1, &name))
3051 return false; 3051 return false;
3052 3052
3053 content::SiteInstance* site_instance = render_view_host()->GetSiteInstance(); 3053 content::SiteInstance* site_instance = render_view_host()->GetSiteInstance();
3054 scoped_refptr<fileapi::FileSystemContext> file_system_context = 3054 scoped_refptr<fileapi::FileSystemContext> file_system_context =
3055 BrowserContext::GetStoragePartition(profile(), site_instance)-> 3055 BrowserContext::GetStoragePartition(profile(), site_instance)->
3056 GetFileSystemContext(); 3056 GetFileSystemContext();
3057 fileapi::FileSystemURL filesystem_url( 3057 fileapi::FileSystemURL filesystem_url(
3058 file_system_context->CrackURL(GURL(parent_url))); 3058 file_system_context->CrackURL(GURL(parent_url)));
3059 if (!chromeos::CrosMountPointProvider::CanHandleURL(filesystem_url)) 3059 if (!chromeos::FileSystemBackend::CanHandleURL(filesystem_url))
3060 return false; 3060 return false;
3061 3061
3062 // No explicit limit on the length of Drive file names. 3062 // No explicit limit on the length of Drive file names.
3063 if (filesystem_url.type() == fileapi::kFileSystemTypeDrive) { 3063 if (filesystem_url.type() == fileapi::kFileSystemTypeDrive) {
3064 SetResult(new base::FundamentalValue(true)); 3064 SetResult(new base::FundamentalValue(true));
3065 SendResponse(true); 3065 SendResponse(true);
3066 return true; 3066 return true;
3067 } 3067 }
3068 3068
3069 base::PostTaskAndReplyWithResult( 3069 base::PostTaskAndReplyWithResult(
(...skipping 24 matching lines...) Expand all
3094 zoom_type = content::PAGE_ZOOM_OUT; 3094 zoom_type = content::PAGE_ZOOM_OUT;
3095 } else if (operation == "reset") { 3095 } else if (operation == "reset") {
3096 zoom_type = content::PAGE_ZOOM_RESET; 3096 zoom_type = content::PAGE_ZOOM_RESET;
3097 } else { 3097 } else {
3098 NOTREACHED(); 3098 NOTREACHED();
3099 return false; 3099 return false;
3100 } 3100 }
3101 view_host->Zoom(zoom_type); 3101 view_host->Zoom(zoom_type);
3102 return true; 3102 return true;
3103 } 3103 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698