diff options
-rw-r--r-- | chrome/browser/chromeos/drive/search_metadata.cc | 24 | ||||
-rw-r--r-- | google_apis/drive/gdata_wapi_parser.cc | 18 | ||||
-rw-r--r-- | google_apis/drive/gdata_wapi_parser.h | 3 |
3 files changed, 34 insertions, 11 deletions
diff --git a/chrome/browser/chromeos/drive/search_metadata.cc b/chrome/browser/chromeos/drive/search_metadata.cc index 8886356..6b1d950 100644 --- a/chrome/browser/chromeos/drive/search_metadata.cc +++ b/chrome/browser/chromeos/drive/search_metadata.cc @@ -14,6 +14,7 @@ #include "base/time/time.h" #include "chrome/browser/chromeos/drive/file_system_util.h" #include "content/public/browser/browser_thread.h" +#include "google_apis/drive/gdata_wapi_parser.h" #include "net/base/escape.h" using content::BrowserThread; @@ -161,11 +162,24 @@ bool IsEligibleEntry(const ResourceEntry& entry, return entry.shared_with_me(); if (options & SEARCH_METADATA_OFFLINE) { - if (entry.file_specific_info().is_hosted_document()) - return true; - FileCacheEntry cache_entry; - it->GetCacheEntry(&cache_entry); - return cache_entry.is_present(); + if (entry.file_specific_info().is_hosted_document()) { + // Not all hosted documents are cached by Drive offline app. + // http://support.google.com/drive/bin/answer.py?hl=en&answer=1628467 + switch (google_apis::ResourceEntry::GetEntryKindFromExtension( + entry.file_specific_info().document_extension())) { + case google_apis::ENTRY_KIND_DOCUMENT: + case google_apis::ENTRY_KIND_SPREADSHEET: + case google_apis::ENTRY_KIND_PRESENTATION: + case google_apis::ENTRY_KIND_DRAWING: + return true; + default: + return false; + } + } else { + FileCacheEntry cache_entry; + it->GetCacheEntry(&cache_entry); + return cache_entry.is_present(); + } } // Exclude "drive", "drive/root", and "drive/other". diff --git a/google_apis/drive/gdata_wapi_parser.cc b/google_apis/drive/gdata_wapi_parser.cc index 1951c17..2f3c978 100644 --- a/google_apis/drive/gdata_wapi_parser.cc +++ b/google_apis/drive/gdata_wapi_parser.cc @@ -536,6 +536,17 @@ std::string ResourceEntry::GetHostedDocumentExtension() const { } // static +DriveEntryKind ResourceEntry::GetEntryKindFromExtension( + const std::string& extension) { + for (size_t i = 0; i < arraysize(kEntryKindMap); ++i) { + const char* document_extension = kEntryKindMap[i].extension; + if (document_extension && extension == document_extension) + return kEntryKindMap[i].kind; + } + return ENTRY_KIND_UNKNOWN; +} + +// static int ResourceEntry::ClassifyEntryKindByFileExtension( const base::FilePath& file_path) { #if defined(OS_WIN) @@ -543,12 +554,7 @@ int ResourceEntry::ClassifyEntryKindByFileExtension( #else std::string file_extension = file_path.Extension(); #endif - for (size_t i = 0; i < arraysize(kEntryKindMap); ++i) { - const char* document_extension = kEntryKindMap[i].extension; - if (document_extension && file_extension == document_extension) - return ClassifyEntryKind(kEntryKindMap[i].kind); - } - return 0; + return ClassifyEntryKind(GetEntryKindFromExtension(file_extension)); } // static diff --git a/google_apis/drive/gdata_wapi_parser.h b/google_apis/drive/gdata_wapi_parser.h index 0c89c11..a7ac493 100644 --- a/google_apis/drive/gdata_wapi_parser.h +++ b/google_apis/drive/gdata_wapi_parser.h @@ -509,6 +509,9 @@ class ResourceEntry : public CommonMetadata { KIND_OF_FILE = 1 << 4, }; + // Returns the kind enum corresponding to the extension in form ".xxx". + static DriveEntryKind GetEntryKindFromExtension(const std::string& extension); + // Classifies the EntryKind. The returned value is a bitmask of // EntryKindClass. For example, DOCUMENT is classified as // KIND_OF_HOSTED_DOCUMENT and KIND_OF_GOOGLE_DOCUMENT, hence the returned |