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

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

Issue 10083067: gdata: Support opening zip file on Google Docs. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: gdata: Support opening zip file on Google Docs Created 8 years, 8 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
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 997 matching lines...) Expand 10 before | Expand all | Expand 10 after
1008 const std::string& mount_type_str, 1008 const std::string& mount_type_str,
1009 const SelectedFileInfoList& files) { 1009 const SelectedFileInfoList& files) {
1010 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 1010 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
1011 1011
1012 if (!files.size()) { 1012 if (!files.size()) {
1013 SendResponse(false); 1013 SendResponse(false);
1014 return; 1014 return;
1015 } 1015 }
1016 1016
1017 #if defined(OS_CHROMEOS) 1017 #if defined(OS_CHROMEOS)
1018 FilePath source_file = files[0].path; 1018 const FilePath& source_path = files[0].path;
1019 const FilePath::StringType& display_name = files[0].display_name;
1020 // Check if the source path is under GData cache directory.
1021 gdata::GDataSystemService* system_service =
1022 gdata::GDataSystemServiceFactory::GetForProfile(profile_);
1023 gdata::GDataFileSystem* file_system =
1024 system_service ? system_service->file_system() : NULL;
1025 if (file_system && file_system->IsUnderGDataCacheDirectory(source_path)) {
1026 file_system->SetMountedState(
1027 source_path,
1028 true,
1029 base::Bind(&AddMountFunction::OnMountedStateSet, this, mount_type_str,
1030 display_name));
1031 } else {
1032 OnMountedStateSet(mount_type_str, display_name,
1033 base::PLATFORM_FILE_OK, source_path);
1034 }
1035 #else
1036 SendResponse(true);
1037 #endif // defined(OS_CHROMEOS)
1038 }
1039
1040 void AddMountFunction::OnMountedStateSet(const std::string& mount_type,
1041 const FilePath::StringType& file_name,
1042 base::PlatformFileError error,
1043 const FilePath& file_path) {
1044 #if defined(OS_CHROMEOS)
1045 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
1019 DiskMountManager* disk_mount_manager = DiskMountManager::GetInstance(); 1046 DiskMountManager* disk_mount_manager = DiskMountManager::GetInstance();
1020 // MountPath() takes a std::string. 1047 // MountPath() takes a std::string.
1021 disk_mount_manager->MountPath(source_file.AsUTF8Unsafe(), 1048 disk_mount_manager->MountPath(file_path.AsUTF8Unsafe(),
1022 DiskMountManager::MountTypeFromString(mount_type_str)); 1049 FilePath(file_name).Extension(),
1050 DiskMountManager::MountTypeFromString(
1051 mount_type));
1052 SendResponse(true);
1023 #endif // defined(OS_CHROMEOS) 1053 #endif // defined(OS_CHROMEOS)
1024
1025 SendResponse(true);
1026 } 1054 }
1027 1055
1028 RemoveMountFunction::RemoveMountFunction() { 1056 RemoveMountFunction::RemoveMountFunction() {
1029 } 1057 }
1030 1058
1031 RemoveMountFunction::~RemoveMountFunction() { 1059 RemoveMountFunction::~RemoveMountFunction() {
1032 } 1060 }
1033 1061
1034 bool RemoveMountFunction::RunImpl() { 1062 bool RemoveMountFunction::RunImpl() {
1035 if (args_->GetSize() != 1) { 1063 if (args_->GetSize() != 1) {
(...skipping 15 matching lines...) Expand all
1051 1079
1052 void RemoveMountFunction::GetLocalPathsResponseOnUIThread( 1080 void RemoveMountFunction::GetLocalPathsResponseOnUIThread(
1053 const SelectedFileInfoList& files) { 1081 const SelectedFileInfoList& files) {
1054 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 1082 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
1055 1083
1056 if (files.size() != 1) { 1084 if (files.size() != 1) {
1057 SendResponse(false); 1085 SendResponse(false);
1058 return; 1086 return;
1059 } 1087 }
1060 #if defined(OS_CHROMEOS) 1088 #if defined(OS_CHROMEOS)
1061 DiskMountManager::GetInstance()->UnmountPath(files[0].path.value()); 1089 DiskMountManager* disk_mount_manager = DiskMountManager::GetInstance();
1062 #endif 1090 if (!disk_mount_manager) {
1091 SendResponse(false);
1092 return;
1093 }
1063 1094
1095 const std::string& mount_path = files[0].path.value();
1096 const DiskMountManager::MountPointMap& mount_points =
1097 disk_mount_manager->mount_points();
1098 // Look up source_path from mount_path first, because the mount_path will
1099 // be deleted from the MountPointMap once it is unmounted.
1100 DiskMountManager::MountPointMap::const_iterator it =
1101 mount_points.find(mount_path);
1102 if (it == mount_points.end()) {
1103 SendResponse(false);
1104 return;
1105 }
1106 FilePath source_path = FilePath(it->second.source_path);
1107 // Unmount archive at mount_path.
1108 disk_mount_manager->UnmountPath(mount_path);
1109 // Check if the source path is under GData cache directory.
1110 gdata::GDataSystemService* system_service =
1111 gdata::GDataSystemServiceFactory::GetForProfile(profile_);
1112 gdata::GDataFileSystem* file_system =
1113 system_service ? system_service->file_system() : NULL;
1114 if (file_system && file_system->IsUnderGDataCacheDirectory(source_path)) {
1115 file_system->SetMountedState(
1116 source_path,
1117 false,
1118 base::Bind(&RemoveMountFunction::OnMountedStateSet, this));
1119 } else {
1120 OnMountedStateSet(base::PLATFORM_FILE_OK, source_path);
1121 }
1122 #else
1064 SendResponse(true); 1123 SendResponse(true);
1124 #endif // defined(OS_CHROMEOS)
1125 }
1126
1127 void RemoveMountFunction::OnMountedStateSet(base::PlatformFileError error,
1128 const FilePath& /* file_path */) {
1129 #if defined(OS_CHROMEOS)
1130 SendResponse(true);
1131 #endif // defined(OS_CHROMEOS)
1065 } 1132 }
1066 1133
1067 GetMountPointsFunction::GetMountPointsFunction() { 1134 GetMountPointsFunction::GetMountPointsFunction() {
1068 } 1135 }
1069 1136
1070 GetMountPointsFunction::~GetMountPointsFunction() { 1137 GetMountPointsFunction::~GetMountPointsFunction() {
1071 } 1138 }
1072 1139
1073 bool GetMountPointsFunction::RunImpl() { 1140 bool GetMountPointsFunction::RunImpl() {
1074 if (args_->GetSize()) 1141 if (args_->GetSize())
(...skipping 921 matching lines...) Expand 10 before | Expand all | Expand 10 after
1996 if (value->GetBoolean("cellularDisabled", &tmp)) { 2063 if (value->GetBoolean("cellularDisabled", &tmp)) {
1997 service->SetBoolean(prefs::kDisableGDataOverCellular, tmp); 2064 service->SetBoolean(prefs::kDisableGDataOverCellular, tmp);
1998 } 2065 }
1999 2066
2000 if (value->GetBoolean("hostedFilesDisabled", &tmp)) { 2067 if (value->GetBoolean("hostedFilesDisabled", &tmp)) {
2001 service->SetBoolean(prefs::kDisableGDataHostedFiles, tmp); 2068 service->SetBoolean(prefs::kDisableGDataHostedFiles, tmp);
2002 } 2069 }
2003 2070
2004 return true; 2071 return true;
2005 } 2072 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698