Index: chrome/browser/chromeos/extensions/file_browser_private_api.cc |
diff --git a/chrome/browser/chromeos/extensions/file_browser_private_api.cc b/chrome/browser/chromeos/extensions/file_browser_private_api.cc |
index a088918e523926562717e33eefdb69331221b15c..b2517b52ea2cf5965cdd3f974096f5e8e939bef4 100644 |
--- a/chrome/browser/chromeos/extensions/file_browser_private_api.cc |
+++ b/chrome/browser/chromeos/extensions/file_browser_private_api.cc |
@@ -386,6 +386,30 @@ base::DictionaryValue* CreateValueFromMountPoint(Profile* profile, |
} |
#endif // defined(OS_CHROMEOS) |
+// Builds a dictionary from the GDataFile file property information |
+void BuildFilePropertyDictionary(const gdata::GDataFile& file, |
+ base::DictionaryValue* property_dict) { |
+ property_dict->SetString("thumbnailUrl", file.thumbnail_url().spec()); |
+ |
+ base::ListValue *pinned_list = new base::ListValue; |
+ if (file.pinned_state() & gdata::GDataFile::PINNED_STATE_PINNED) |
+ pinned_list->Append(new base::StringValue("pinned")); |
+ if (file.pinned_state() & gdata::GDataFile::PINNED_STATE_PRESENT) |
+ pinned_list->Append(new base::StringValue("present")); |
+ property_dict->Set("pinnedState", pinned_list); |
+ |
+ base::ListValue* authors_list = new base::ListValue; |
+ const gdata::GDataFile::AuthorList& authors = file.authors(); |
+ for (gdata::GDataFile::AuthorList::const_iterator iter = authors.begin(); |
+ iter != authors.end(); ++iter) { |
+ base::DictionaryValue* author_info = new base::DictionaryValue; |
+ author_info->SetString("name", iter->first); |
+ author_info->SetString("email", iter->second); |
+ authors_list->Append(author_info); |
+ } |
+ property_dict->Set("authors", authors_list); |
zel
2012/02/29 23:46:38
remove authors
Greg Spencer (Chromium)
2012/03/01 02:26:32
Done.
|
+} |
+ |
} // namespace |
class RequestLocalFileSystemFunction::LocalFileSystemCallbackDispatcher { |
@@ -1804,3 +1828,70 @@ bool FileDialogStringsFunction::RunImpl() { |
return true; |
} |
+ |
+GetGDataFilePropertiesFunction::GetGDataFilePropertiesFunction() { |
+} |
+ |
+GetGDataFilePropertiesFunction::~GetGDataFilePropertiesFunction() { |
+} |
+ |
+bool GetGDataFilePropertiesFunction::RunImpl() { |
+ if (args_->GetSize() != 1) { |
+ return false; |
+ } |
+ |
+ ListValue* path_list = NULL; |
+ args_->GetList(0, &path_list); |
+ DCHECK(path_list); |
+ |
+ std::string virtual_path; |
+ size_t len = path_list->GetSize(); |
+ UrlList file_urls; |
+ file_urls.reserve(len); |
+ for (size_t i = 0; i < len; ++i) { |
+ path_list->GetString(i, &virtual_path); |
+ file_urls.push_back(GURL(virtual_path)); |
+ } |
+ |
+ GetLocalPathsOnFileThreadAndRunCallbackOnUIThread( |
zel
2012/02/29 23:46:38
You don't need to move things to file thread for g
Greg Spencer (Chromium)
2012/03/01 02:26:32
Done.
|
+ file_urls, |
+ base::Bind( |
+ &GetGDataFilePropertiesFunction::GetLocalPathsResponseOnUIThread, |
+ this)); |
+ return true; |
+} |
+ |
+// If we don't find an entry for a file in the list, we insert an empty |
+// attribute list |
+// If we find an entry, but it's a dictionary instead of a file, then we |
+// insert an empty attribute list. |
+void GetGDataFilePropertiesFunction::GetLocalPathsResponseOnUIThread( |
+ const FilePathList& files) { |
+ base::ListValue* file_info = new base::ListValue; |
achuithb
2012/02/29 23:33:06
Could you please add a DCHECK for CurrentlyOn(Brow
Greg Spencer (Chromium)
2012/03/01 02:26:32
Actually, removed this because Zel says I don't ne
|
+ result_.reset(file_info); |
+ |
+ gdata::GDataFileSystem* file_system = |
+ gdata::GDataFileSystemFactory::GetForProfile(profile_); |
+ DCHECK(file_system); |
+ |
+ for (FilePathList::const_iterator iter = files.begin(); |
+ iter != files.end(); ++iter) { |
+ scoped_refptr<gdata::ReadOnlyFindFileDelegate> find_delegate( |
zel
2012/02/29 23:46:38
yeah, you need a better one here, one that extract
Greg Spencer (Chromium)
2012/03/01 02:26:32
Done.
|
+ new gdata::ReadOnlyFindFileDelegate()); |
+ file_system->FindFileByPath(*iter, find_delegate); |
+ base::DictionaryValue* property_dict = new base::DictionaryValue; |
+ file_info->Append(property_dict); |
+ |
+ gdata::GDataFileBase* entry = find_delegate->file(); |
+ if (!entry) { |
+ property_dict->SetString("error", "NOT_FOUND"); |
+ continue; // Didn't find the file. |
+ } |
+ gdata::GDataFile* file = entry->AsGDataFile(); |
+ if (!file) |
+ continue; // Found a directory, just leave the empty attribute dict. |
+ BuildFilePropertyDictionary(*file, property_dict); |
+ file_info->Append(property_dict); |
+ } |
+ SendResponse(true); |
+} |