| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/private_api_drive.h" | 5 #include "chrome/browser/chromeos/extensions/file_manager/private_api_drive.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "chrome/browser/browser_process.h" | 8 #include "chrome/browser/browser_process.h" |
| 9 #include "chrome/browser/chromeos/drive/drive_integration_service.h" | 9 #include "chrome/browser/chromeos/drive/drive_integration_service.h" |
| 10 #include "chrome/browser/chromeos/extensions/file_manager/private_api_util.h" | 10 #include "chrome/browser/chromeos/extensions/file_manager/private_api_util.h" |
| (...skipping 900 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 911 drive::util::GetFileSystemByProfile(GetProfile()); | 911 drive::util::GetFileSystemByProfile(GetProfile()); |
| 912 if (!file_system) { | 912 if (!file_system) { |
| 913 // |file_system| is NULL if Drive is disabled or not mounted. | 913 // |file_system| is NULL if Drive is disabled or not mounted. |
| 914 SetError("Drive is disabled or not mounted."); | 914 SetError("Drive is disabled or not mounted."); |
| 915 SetResult(new base::StringValue("")); // Intentionally returns a blank. | 915 SetResult(new base::StringValue("")); // Intentionally returns a blank. |
| 916 return false; | 916 return false; |
| 917 } | 917 } |
| 918 | 918 |
| 919 const base::FilePath path = file_manager::util::GetLocalPathFromURL( | 919 const base::FilePath path = file_manager::util::GetLocalPathFromURL( |
| 920 render_view_host(), GetProfile(), GURL(params->url)); | 920 render_view_host(), GetProfile(), GURL(params->url)); |
| 921 DCHECK(drive::util::IsUnderDriveMountPoint(path)); | 921 if (!drive::util::IsUnderDriveMountPoint(path)) { |
| 922 SetError("The given file is not in Drive."); |
| 923 SetResult(new base::StringValue("")); // Intentionally returns a blank. |
| 924 return false; |
| 925 } |
| 922 base::FilePath file_path = drive::util::ExtractDrivePath(path); | 926 base::FilePath file_path = drive::util::ExtractDrivePath(path); |
| 923 | 927 |
| 924 file_system->GetResourceEntry( | 928 file_system->GetResourceEntry( |
| 925 file_path, | 929 file_path, |
| 926 base::Bind(&FileBrowserPrivateGetDownloadUrlFunction::OnGetResourceEntry, | 930 base::Bind(&FileBrowserPrivateGetDownloadUrlFunction::OnGetResourceEntry, |
| 927 this)); | 931 this)); |
| 928 return true; | 932 return true; |
| 929 } | 933 } |
| 930 | 934 |
| 931 void FileBrowserPrivateGetDownloadUrlFunction::OnGetResourceEntry( | 935 void FileBrowserPrivateGetDownloadUrlFunction::OnGetResourceEntry( |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 971 return; | 975 return; |
| 972 } | 976 } |
| 973 | 977 |
| 974 const std::string url = download_url_ + "?access_token=" + access_token; | 978 const std::string url = download_url_ + "?access_token=" + access_token; |
| 975 SetResult(new base::StringValue(url)); | 979 SetResult(new base::StringValue(url)); |
| 976 | 980 |
| 977 SendResponse(true); | 981 SendResponse(true); |
| 978 } | 982 } |
| 979 | 983 |
| 980 } // namespace extensions | 984 } // namespace extensions |
| OLD | NEW |