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

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

Issue 9836086: Added logic that will return the result of the first chunk of root feed and continue fetching the r… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fixed asserts in browser_tests Created 8 years, 9 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 <utility> 7 #include <utility>
8 8
9 #include "base/base64.h" 9 #include "base/base64.h"
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
170 } 170 }
171 171
172 mount_info->SetString("mountCondition", 172 mount_info->SetString("mountCondition",
173 DiskMountManager::MountConditionToString( 173 DiskMountManager::MountConditionToString(
174 mount_point_info.mount_condition)); 174 mount_point_info.mount_condition));
175 175
176 return mount_info; 176 return mount_info;
177 } 177 }
178 #endif // defined(OS_CHROMEOS) 178 #endif // defined(OS_CHROMEOS)
179 179
180
181 // Gives the extension renderer |host| file |permissions| for the given |path|.
182 void GrantFilePermissionsToHost(content::RenderViewHost* host,
183 const FilePath& path,
184 int permissions) {
185 ChildProcessSecurityPolicy::GetInstance()->GrantPermissionsForFile(
186 host->GetProcess()->GetID(), path, permissions);
187 }
188
180 // Given a file url, find the virtual FilePath associated with it. 189 // Given a file url, find the virtual FilePath associated with it.
181 FilePath GetVirtualPathFromURL(const GURL& file_url) { 190 FilePath GetVirtualPathFromURL(const GURL& file_url) {
182 FilePath virtual_path; 191 FilePath virtual_path;
183 fileapi::FileSystemType type = fileapi::kFileSystemTypeUnknown; 192 fileapi::FileSystemType type = fileapi::kFileSystemTypeUnknown;
184 GURL file_origin_url; 193 GURL file_origin_url;
185 if (!CrackFileSystemURL(file_url, &file_origin_url, &type, &virtual_path) || 194 if (!CrackFileSystemURL(file_url, &file_origin_url, &type, &virtual_path) ||
186 type != fileapi::kFileSystemTypeExternal) { 195 type != fileapi::kFileSystemTypeExternal) {
187 NOTREACHED(); 196 NOTREACHED();
188 return FilePath(); 197 return FilePath();
189 } 198 }
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
340 this, 349 this,
341 source_url_, 350 source_url_,
342 render_view_host()->GetProcess()->GetID())); 351 render_view_host()->GetProcess()->GetID()));
343 // Will finish asynchronously. 352 // Will finish asynchronously.
344 return true; 353 return true;
345 } 354 }
346 355
347 void RequestLocalFileSystemFunction::RespondSuccessOnUIThread( 356 void RequestLocalFileSystemFunction::RespondSuccessOnUIThread(
348 const std::string& name, const GURL& root_path) { 357 const std::string& name, const GURL& root_path) {
349 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 358 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
359 // Add gdata mount point immediately when we kick of first instance of file
360 // manager. The actual mount event will be sent to UI only when we perform
361 // proper authentication.
362 AddGDataMountPoint();
350 result_.reset(new DictionaryValue()); 363 result_.reset(new DictionaryValue());
351 DictionaryValue* dict = reinterpret_cast<DictionaryValue*>(result_.get()); 364 DictionaryValue* dict = reinterpret_cast<DictionaryValue*>(result_.get());
352 dict->SetString("name", name); 365 dict->SetString("name", name);
353 dict->SetString("path", root_path.spec()); 366 dict->SetString("path", root_path.spec());
354 dict->SetInteger("error", base::PLATFORM_FILE_OK); 367 dict->SetInteger("error", base::PLATFORM_FILE_OK);
355 SendResponse(true); 368 SendResponse(true);
356 } 369 }
357 370
371 void RequestLocalFileSystemFunction::AddGDataMountPoint() {
372 fileapi::ExternalFileSystemMountPointProvider* provider =
373 BrowserContext::GetFileSystemContext(profile_)->external_provider();
374 const FilePath mount_point = gdata::util::GetGDataMountPointPath();
375 if (!provider || provider->HasMountPoint(mount_point))
376 return;
377
378 // Grant R/W permissions to gdata 'folder'. File API layer still
379 // expects this to be satisfied.
380 GrantFilePermissionsToHost(render_view_host(),
381 mount_point,
382 file_handler_util::GetReadWritePermissions());
383
384 // Grant R/W permission for tmp and pinned cache folder.
385 gdata::GDataSystemService* system_service =
386 gdata::GDataSystemServiceFactory::GetForProfile(profile_);
387 DCHECK(system_service);
388 gdata::GDataFileSystem* gdata_file_system = system_service->file_system();
389
390 // We check permissions for raw cache file paths only for read-only
391 // operations (when fileEntry.file() is called), so read only permissions
392 // should be sufficient for all cache paths. For the rest of supported
393 // operations the file access check is done for gdata/ paths.
394 GrantFilePermissionsToHost(render_view_host(),
395 gdata_file_system->GetGDataCacheTmpDirectory(),
396 file_handler_util::GetReadOnlyPermissions());
397 GrantFilePermissionsToHost(
398 render_view_host(),
399 gdata_file_system->GetGDataCachePersistentDirectory(),
400 file_handler_util::GetReadOnlyPermissions());
401
402 provider->AddRemoteMountPoint(
403 mount_point,
404 new gdata::GDataFileSystemProxy(gdata_file_system));
405
406 FilePath mount_point_virtual;
407 if (provider->GetVirtualPath(mount_point, &mount_point_virtual))
408 provider->GrantFileAccessToExtension(extension_id(), mount_point_virtual);
409 }
410
358 void RequestLocalFileSystemFunction::RespondFailedOnUIThread( 411 void RequestLocalFileSystemFunction::RespondFailedOnUIThread(
359 base::PlatformFileError error_code) { 412 base::PlatformFileError error_code) {
360 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 413 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
361 error_ = base::StringPrintf(kFileError, static_cast<int>(error_code)); 414 error_ = base::StringPrintf(kFileError, static_cast<int>(error_code));
362 SendResponse(false); 415 SendResponse(false);
363 } 416 }
364 417
365 bool FileWatchBrowserFunctionBase::GetLocalFilePath( 418 bool FileWatchBrowserFunctionBase::GetLocalFilePath(
366 const GURL& file_url, FilePath* local_path, FilePath* virtual_path) { 419 const GURL& file_url, FilePath* local_path, FilePath* virtual_path) {
367 GURL file_origin_url; 420 GURL file_origin_url;
(...skipping 532 matching lines...) Expand 10 before | Expand all | Expand 10 after
900 this, 953 this,
901 mount_type_str)); 954 mount_type_str));
902 break; 955 break;
903 } 956 }
904 } 957 }
905 #endif // defined(OS_CHROMEOS) 958 #endif // defined(OS_CHROMEOS)
906 959
907 return true; 960 return true;
908 } 961 }
909 962
910 void AddMountFunction::GrantFilePermissionsToHost(const FilePath& path,
911 int permissions) {
912 ChildProcessSecurityPolicy::GetInstance()->GrantPermissionsForFile(
913 render_view_host()->GetProcess()->GetID(), path, permissions);
914 }
915
916 void AddMountFunction::AddGDataMountPoint() {
917 fileapi::ExternalFileSystemMountPointProvider* provider =
918 BrowserContext::GetFileSystemContext(profile_)->external_provider();
919 const FilePath mount_point = gdata::util::GetGDataMountPointPath();
920 if (!provider || provider->HasMountPoint(mount_point))
921 return;
922
923 // Grant R/W permissions to gdata 'folder'. File API layer still
924 // expects this to be satisfied.
925 GrantFilePermissionsToHost(mount_point,
926 file_handler_util::GetReadWritePermissions());
927
928 // Grant R/W permission for tmp and pinned cache folder.
929 gdata::GDataSystemService* system_service =
930 gdata::GDataSystemServiceFactory::GetForProfile(profile_);
931 DCHECK(system_service);
932 gdata::GDataFileSystem* gdata_file_system = system_service->file_system();
933
934 // We check permissions for raw cache file paths only for read-only
935 // operations (when fileEntry.file() is called), so read only permissions
936 // should be sufficient for all cache paths. For the rest of supported
937 // operations the file access check is done for gdata/ paths.
938 GrantFilePermissionsToHost(gdata_file_system->GetGDataCacheTmpDirectory(),
939 file_handler_util::GetReadOnlyPermissions());
940 GrantFilePermissionsToHost(
941 gdata_file_system->GetGDataCachePersistentDirectory(),
942 file_handler_util::GetReadOnlyPermissions());
943
944 provider->AddRemoteMountPoint(
945 mount_point,
946 new gdata::GDataFileSystemProxy(gdata_file_system));
947
948 FilePath mount_point_virtual;
949 if (provider->GetVirtualPath(mount_point, &mount_point_virtual))
950 provider->GrantFileAccessToExtension(extension_id(), mount_point_virtual);
951 }
952
953 void AddMountFunction::RaiseGDataMountEvent(gdata::GDataErrorCode error) { 963 void AddMountFunction::RaiseGDataMountEvent(gdata::GDataErrorCode error) {
954 chromeos::MountError error_code = error == gdata::HTTP_SUCCESS ? 964 chromeos::MountError error_code = error == gdata::HTTP_SUCCESS ?
955 chromeos::MOUNT_ERROR_NONE : chromeos::MOUNT_ERROR_NOT_AUTHENTICATED; 965 chromeos::MOUNT_ERROR_NONE : chromeos::MOUNT_ERROR_NOT_AUTHENTICATED;
956 DiskMountManager::MountPointInfo mount_info( 966 DiskMountManager::MountPointInfo mount_info(
957 gdata::util::GetGDataMountPointPathAsString(), 967 gdata::util::GetGDataMountPointPathAsString(),
958 gdata::util::GetGDataMountPointPathAsString(), 968 gdata::util::GetGDataMountPointPathAsString(),
959 chromeos::MOUNT_TYPE_GDATA, 969 chromeos::MOUNT_TYPE_GDATA,
960 chromeos::disks::MOUNT_CONDITION_NONE); 970 chromeos::disks::MOUNT_CONDITION_NONE);
961 // Raise mount event 971 // Raise mount event
962 FileBrowserEventRouterFactory::GetForProfile(profile_)-> 972 FileBrowserEventRouterFactory::GetForProfile(profile_)->
963 MountCompleted(DiskMountManager::MOUNTING, error_code, mount_info); 973 MountCompleted(DiskMountManager::MOUNTING, error_code, mount_info);
964 } 974 }
965 975
966 void AddMountFunction::OnGDataAuthentication(gdata::GDataErrorCode error, 976 void AddMountFunction::OnGDataAuthentication(gdata::GDataErrorCode error,
967 const std::string& token) { 977 const std::string& token) {
968 if (error == gdata::HTTP_SUCCESS)
969 AddGDataMountPoint();
970
971 RaiseGDataMountEvent(error); 978 RaiseGDataMountEvent(error);
972 SendResponse(true); 979 SendResponse(true);
973 } 980 }
974 981
975 void AddMountFunction::GetLocalPathsResponseOnUIThread( 982 void AddMountFunction::GetLocalPathsResponseOnUIThread(
976 const std::string& mount_type_str, 983 const std::string& mount_type_str,
977 const SelectedFileInfoList& files) { 984 const SelectedFileInfoList& files) {
978 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 985 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
979 986
980 if (!files.size()) { 987 if (!files.size()) {
(...skipping 455 matching lines...) Expand 10 before | Expand all | Expand 10 after
1436 SET_STRING(IDS_FILE_BROWSER, TAR_GZIP_ARCHIVE_FILE_TYPE); 1443 SET_STRING(IDS_FILE_BROWSER, TAR_GZIP_ARCHIVE_FILE_TYPE);
1437 SET_STRING(IDS_FILE_BROWSER, PLAIN_TEXT_FILE_TYPE); 1444 SET_STRING(IDS_FILE_BROWSER, PLAIN_TEXT_FILE_TYPE);
1438 SET_STRING(IDS_FILE_BROWSER, PDF_DOCUMENT_FILE_TYPE); 1445 SET_STRING(IDS_FILE_BROWSER, PDF_DOCUMENT_FILE_TYPE);
1439 SET_STRING(IDS_FILE_BROWSER, WORD_DOCUMENT_FILE_TYPE); 1446 SET_STRING(IDS_FILE_BROWSER, WORD_DOCUMENT_FILE_TYPE);
1440 SET_STRING(IDS_FILE_BROWSER, POWERPOINT_PRESENTATION_FILE_TYPE); 1447 SET_STRING(IDS_FILE_BROWSER, POWERPOINT_PRESENTATION_FILE_TYPE);
1441 SET_STRING(IDS_FILE_BROWSER, EXCEL_FILE_TYPE); 1448 SET_STRING(IDS_FILE_BROWSER, EXCEL_FILE_TYPE);
1442 1449
1443 SET_STRING(IDS_FILE_BROWSER, GDOC_DOCUMENT_FILE_TYPE); 1450 SET_STRING(IDS_FILE_BROWSER, GDOC_DOCUMENT_FILE_TYPE);
1444 SET_STRING(IDS_FILE_BROWSER, GSHEET_DOCUMENT_FILE_TYPE); 1451 SET_STRING(IDS_FILE_BROWSER, GSHEET_DOCUMENT_FILE_TYPE);
1445 SET_STRING(IDS_FILE_BROWSER, GSLIDES_DOCUMENT_FILE_TYPE); 1452 SET_STRING(IDS_FILE_BROWSER, GSLIDES_DOCUMENT_FILE_TYPE);
1446 SET_STRING(IDS_FILE_BROWSER, GSLIDES_DOCUMENT_FILE_TYPE); 1453 SET_STRING(IDS_FILE_BROWSER, GDRAW_DOCUMENT_FILE_TYPE);
1447 SET_STRING(IDS_FILE_BROWSER, GTABLE_DOCUMENT_FILE_TYPE); 1454 SET_STRING(IDS_FILE_BROWSER, GTABLE_DOCUMENT_FILE_TYPE);
1448 1455
1456
1449 SET_STRING(IDS_FILE_BROWSER, AUDIO_PLAYER_TITLE); 1457 SET_STRING(IDS_FILE_BROWSER, AUDIO_PLAYER_TITLE);
1450 #undef SET_STRING 1458 #undef SET_STRING
1451 1459
1452 dict->SetString("PDF_VIEW_ENABLED", 1460 dict->SetString("PDF_VIEW_ENABLED",
1453 file_manager_util::ShouldBeOpenedWithPdfPlugin(".pdf") ? 1461 file_manager_util::ShouldBeOpenedWithPdfPlugin(".pdf") ?
1454 "true" : "false"); 1462 "true" : "false");
1455 1463
1456 ChromeURLDataManager::DataSource::SetFontAndTextDirection(dict); 1464 ChromeURLDataManager::DataSource::SetFontAndTextDirection(dict);
1457 1465
1458 if (!profile_->GetPrefs()->GetBoolean(prefs::kDisableGData)) 1466 if (!profile_->GetPrefs()->GetBoolean(prefs::kDisableGData))
(...skipping 439 matching lines...) Expand 10 before | Expand all | Expand 10 after
1898 local_source_file, 1906 local_source_file,
1899 remote_destination_file, 1907 remote_destination_file,
1900 base::Bind(&TransferFileFunction::OnTransferCompleted, 1908 base::Bind(&TransferFileFunction::OnTransferCompleted,
1901 this)); 1909 this));
1902 } 1910 }
1903 1911
1904 void TransferFileFunction::OnTransferCompleted( 1912 void TransferFileFunction::OnTransferCompleted(
1905 base::PlatformFileError error) { 1913 base::PlatformFileError error) {
1906 SendResponse(error == base::PLATFORM_FILE_OK); 1914 SendResponse(error == base::PLATFORM_FILE_OK);
1907 } 1915 }
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/extensions/file_browser_private_api.h ('k') | chrome/browser/chromeos/gdata/gdata_file_system.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698