Commit 0b2b1ed2 authored by kinaba@chromium.org's avatar kinaba@chromium.org

Google drive forms should not appear in the "offline" tab of Files.app.

They are not offline available.
See the comments added in the patch and metadata_cache.js.

BUG=none

Review URL: https://codereview.chromium.org/103013004

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@243361 0039d316-1c4b-4281-b951-d872f2087c98
parent bbda18e5
......@@ -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".
......
......@@ -535,6 +535,17 @@ std::string ResourceEntry::GetHostedDocumentExtension() const {
return std::string();
}
// 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) {
......@@ -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
......
......@@ -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
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment