| 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/prefs/pref_service.h" | 7 #include "base/prefs/pref_service.h" |
| 8 #include "base/strings/stringprintf.h" | 8 #include "base/strings/stringprintf.h" |
| 9 #include "chrome/browser/chromeos/drive/drive_app_registry.h" | 9 #include "chrome/browser/chromeos/drive/drive_app_registry.h" |
| 10 #include "chrome/browser/chromeos/drive/drive_integration_service.h" | 10 #include "chrome/browser/chromeos/drive/drive_integration_service.h" |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 78 std::string file_url_str; | 78 std::string file_url_str; |
| 79 if (args_->GetSize() != 1 || !args_->GetString(0, &file_url_str)) | 79 if (args_->GetSize() != 1 || !args_->GetString(0, &file_url_str)) |
| 80 return false; | 80 return false; |
| 81 | 81 |
| 82 GURL file_url = GURL(file_url_str); | 82 GURL file_url = GURL(file_url_str); |
| 83 file_path_ = drive::util::ExtractDrivePath( | 83 file_path_ = drive::util::ExtractDrivePath( |
| 84 file_manager::util::GetLocalPathFromURL( | 84 file_manager::util::GetLocalPathFromURL( |
| 85 render_view_host(), profile(), file_url)); | 85 render_view_host(), profile(), file_url)); |
| 86 | 86 |
| 87 properties_.reset(new base::DictionaryValue); | 87 properties_.reset(new base::DictionaryValue); |
| 88 properties_->SetString("fileUrl", file_url.spec()); | |
| 89 | 88 |
| 90 // Start getting the file info. | 89 // Start getting the file info. |
| 91 drive::FileSystemInterface* file_system = | 90 drive::FileSystemInterface* file_system = |
| 92 drive::util::GetFileSystemByProfile(profile()); | 91 drive::util::GetFileSystemByProfile(profile()); |
| 93 if (!file_system) { | 92 if (!file_system) { |
| 94 // |file_system| is NULL if Drive is disabled or not mounted. | 93 // |file_system| is NULL if Drive is disabled or not mounted. |
| 95 CompleteGetFileProperties(drive::FILE_ERROR_FAILED); | 94 CompleteGetFileProperties(drive::FILE_ERROR_FAILED); |
| 96 return true; | 95 return true; |
| 97 } | 96 } |
| 98 | 97 |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 176 // returns false. | 175 // returns false. |
| 177 properties_->SetBoolean("isPinned", cache_entry.is_pinned()); | 176 properties_->SetBoolean("isPinned", cache_entry.is_pinned()); |
| 178 properties_->SetBoolean("isPresent", cache_entry.is_present()); | 177 properties_->SetBoolean("isPresent", cache_entry.is_present()); |
| 179 properties_->SetBoolean("isDirty", cache_entry.is_dirty()); | 178 properties_->SetBoolean("isDirty", cache_entry.is_dirty()); |
| 180 | 179 |
| 181 CompleteGetFileProperties(drive::FILE_ERROR_OK); | 180 CompleteGetFileProperties(drive::FILE_ERROR_OK); |
| 182 } | 181 } |
| 183 | 182 |
| 184 void FileBrowserPrivateGetDriveEntryPropertiesFunction:: | 183 void FileBrowserPrivateGetDriveEntryPropertiesFunction:: |
| 185 CompleteGetFileProperties(drive::FileError error) { | 184 CompleteGetFileProperties(drive::FileError error) { |
| 186 if (error != drive::FILE_ERROR_OK) | |
| 187 properties_->SetInteger("errorCode", error); | |
| 188 SetResult(properties_.release()); | 185 SetResult(properties_.release()); |
| 189 SendResponse(true); | 186 SendResponse(true); |
| 190 } | 187 } |
| 191 | 188 |
| 192 FileBrowserPrivatePinDriveFileFunction:: | 189 FileBrowserPrivatePinDriveFileFunction:: |
| 193 FileBrowserPrivatePinDriveFileFunction() { | 190 FileBrowserPrivatePinDriveFileFunction() { |
| 194 } | 191 } |
| 195 | 192 |
| 196 FileBrowserPrivatePinDriveFileFunction:: | 193 FileBrowserPrivatePinDriveFileFunction:: |
| 197 ~FileBrowserPrivatePinDriveFileFunction() { | 194 ~FileBrowserPrivatePinDriveFileFunction() { |
| (...skipping 512 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 710 error_ = "Share Url for this item is not available."; | 707 error_ = "Share Url for this item is not available."; |
| 711 SendResponse(false); | 708 SendResponse(false); |
| 712 return; | 709 return; |
| 713 } | 710 } |
| 714 | 711 |
| 715 SetResult(new base::StringValue(share_url.spec())); | 712 SetResult(new base::StringValue(share_url.spec())); |
| 716 SendResponse(true); | 713 SendResponse(true); |
| 717 } | 714 } |
| 718 | 715 |
| 719 } // namespace extensions | 716 } // namespace extensions |
| OLD | NEW |