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

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

Issue 14884015: drive: Remove DriveFileType (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 7 years, 7 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 1281 matching lines...) Expand 10 before | Expand all | Expand 10 after
1292 // When opening a drive file, we should get local file path. 1292 // When opening a drive file, we should get local file path.
1293 if (params->for_opening && 1293 if (params->for_opening &&
1294 drive::util::IsUnderDriveMountPoint(file_path)) { 1294 drive::util::IsUnderDriveMountPoint(file_path)) {
1295 drive::DriveSystemService* system_service = 1295 drive::DriveSystemService* system_service =
1296 drive::DriveSystemServiceFactory::GetForProfile(profile_); 1296 drive::DriveSystemServiceFactory::GetForProfile(profile_);
1297 // |system_service| is NULL if Drive is disabled. 1297 // |system_service| is NULL if Drive is disabled.
1298 if (!system_service) { 1298 if (!system_service) {
1299 ContinueGetSelectedFileInfo(params.Pass(), 1299 ContinueGetSelectedFileInfo(params.Pass(),
1300 drive::FILE_ERROR_FAILED, 1300 drive::FILE_ERROR_FAILED,
1301 base::FilePath(), 1301 base::FilePath(),
1302 std::string(), 1302 scoped_ptr<drive::ResourceEntry>());
1303 drive::REGULAR_FILE);
1304 return; 1303 return;
1305 } 1304 }
1306 system_service->file_system()->GetFileByPath( 1305 system_service->file_system()->GetFileByPath(
1307 drive::util::ExtractDrivePath(file_path), 1306 drive::util::ExtractDrivePath(file_path),
1308 base::Bind(&FileBrowserFunction::ContinueGetSelectedFileInfo, 1307 base::Bind(&FileBrowserFunction::ContinueGetSelectedFileInfo,
1309 this, 1308 this,
1310 base::Passed(&params))); 1309 base::Passed(&params)));
1311 return; 1310 return;
1312 } else { 1311 } else {
1313 params->selected_files.push_back( 1312 params->selected_files.push_back(
1314 ui::SelectedFileInfo(file_path, base::FilePath())); 1313 ui::SelectedFileInfo(file_path, base::FilePath()));
1315 } 1314 }
1316 } 1315 }
1317 params->callback.Run(params->selected_files); 1316 params->callback.Run(params->selected_files);
1318 } 1317 }
1319 1318
1320 void FileBrowserFunction::ContinueGetSelectedFileInfo( 1319 void FileBrowserFunction::ContinueGetSelectedFileInfo(
1321 scoped_ptr<GetSelectedFileInfoParams> params, 1320 scoped_ptr<GetSelectedFileInfoParams> params,
1322 drive::FileError error, 1321 drive::FileError error,
1323 const base::FilePath& local_file_path, 1322 const base::FilePath& local_file_path,
1324 const std::string& mime_type, 1323 scoped_ptr<drive::ResourceEntry> entry) {
1325 drive::DriveFileType file_type) {
1326 const int index = params->selected_files.size(); 1324 const int index = params->selected_files.size();
1327 const base::FilePath& file_path = params->file_paths[index]; 1325 const base::FilePath& file_path = params->file_paths[index];
1328 base::FilePath local_path; 1326 base::FilePath local_path;
1329 if (error == drive::FILE_ERROR_OK) { 1327 if (error == drive::FILE_ERROR_OK) {
1330 local_path = local_file_path; 1328 local_path = local_file_path;
1331 } else { 1329 } else {
1332 DLOG(ERROR) << "Failed to get " << file_path.value() 1330 DLOG(ERROR) << "Failed to get " << file_path.value()
1333 << " with error code: " << error; 1331 << " with error code: " << error;
1334 } 1332 }
1335 params->selected_files.push_back(ui::SelectedFileInfo(file_path, local_path)); 1333 params->selected_files.push_back(ui::SelectedFileInfo(file_path, local_path));
(...skipping 1217 matching lines...) Expand 10 before | Expand all | Expand 10 after
2553 return; 2551 return;
2554 } 2552 }
2555 2553
2556 // Get the file on the top of the queue. 2554 // Get the file on the top of the queue.
2557 base::FilePath drive_path = remaining_drive_paths_.front(); 2555 base::FilePath drive_path = remaining_drive_paths_.front();
2558 2556
2559 drive::DriveSystemService* system_service = 2557 drive::DriveSystemService* system_service =
2560 drive::DriveSystemServiceFactory::GetForProfile(profile_); 2558 drive::DriveSystemServiceFactory::GetForProfile(profile_);
2561 // |system_service| is NULL if Drive is disabled. 2559 // |system_service| is NULL if Drive is disabled.
2562 if (!system_service) { 2560 if (!system_service) {
2563 OnFileReady(drive::FILE_ERROR_FAILED, 2561 OnFileReady(drive::FILE_ERROR_FAILED, drive_path,
2564 drive_path, 2562 scoped_ptr<drive::ResourceEntry>());
2565 "", // mime_type
2566 drive::REGULAR_FILE);
2567 return; 2563 return;
2568 } 2564 }
2569 2565
2570 system_service->file_system()->GetFileByPath( 2566 system_service->file_system()->GetFileByPath(
2571 drive_path, 2567 drive_path,
2572 base::Bind(&GetDriveFilesFunction::OnFileReady, this)); 2568 base::Bind(&GetDriveFilesFunction::OnFileReady, this));
2573 } 2569 }
2574 2570
2575 2571
2576 void GetDriveFilesFunction::OnFileReady( 2572 void GetDriveFilesFunction::OnFileReady(
2577 drive::FileError error, 2573 drive::FileError error,
2578 const base::FilePath& local_path, 2574 const base::FilePath& local_path,
2579 const std::string& unused_mime_type, 2575 scoped_ptr<drive::ResourceEntry> entry) {
2580 drive::DriveFileType file_type) {
2581 base::FilePath drive_path = remaining_drive_paths_.front(); 2576 base::FilePath drive_path = remaining_drive_paths_.front();
2582 2577
2583 if (error == drive::FILE_ERROR_OK) { 2578 if (error == drive::FILE_ERROR_OK) {
2584 local_paths_->Append(new base::StringValue(local_path.value())); 2579 local_paths_->Append(new base::StringValue(local_path.value()));
2585 DVLOG(1) << "Got " << drive_path.value() << " as " << local_path.value(); 2580 DVLOG(1) << "Got " << drive_path.value() << " as " << local_path.value();
2586 2581
2587 // TODO(benchan): If the file is a hosted document, a temporary JSON file 2582 // TODO(benchan): If the file is a hosted document, a temporary JSON file
2588 // is created to represent the document. The JSON file is not cached and 2583 // is created to represent the document. The JSON file is not cached and
2589 // should be deleted after use. We need to somehow communicate with 2584 // should be deleted after use. We need to somehow communicate with
2590 // file_manager.js to manage the lifetime of the temporary file. 2585 // file_manager.js to manage the lifetime of the temporary file.
(...skipping 567 matching lines...) Expand 10 before | Expand all | Expand 10 after
3158 OpenNewWindowFunction::OpenNewWindowFunction() {} 3153 OpenNewWindowFunction::OpenNewWindowFunction() {}
3159 3154
3160 OpenNewWindowFunction::~OpenNewWindowFunction() {} 3155 OpenNewWindowFunction::~OpenNewWindowFunction() {}
3161 3156
3162 bool OpenNewWindowFunction::RunImpl() { 3157 bool OpenNewWindowFunction::RunImpl() {
3163 std::string url; 3158 std::string url;
3164 EXTENSION_FUNCTION_VALIDATE(args_->GetString(0, &url)); 3159 EXTENSION_FUNCTION_VALIDATE(args_->GetString(0, &url));
3165 file_manager_util::OpenNewWindow(profile_, GURL(url)); 3160 file_manager_util::OpenNewWindow(profile_, GURL(url));
3166 return true; 3161 return true;
3167 } 3162 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698