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 @@ ...@@ -14,6 +14,7 @@
#include "base/time/time.h" #include "base/time/time.h"
#include "chrome/browser/chromeos/drive/file_system_util.h" #include "chrome/browser/chromeos/drive/file_system_util.h"
#include "content/public/browser/browser_thread.h" #include "content/public/browser/browser_thread.h"
#include "google_apis/drive/gdata_wapi_parser.h"
#include "net/base/escape.h" #include "net/base/escape.h"
using content::BrowserThread; using content::BrowserThread;
...@@ -161,11 +162,24 @@ bool IsEligibleEntry(const ResourceEntry& entry, ...@@ -161,11 +162,24 @@ bool IsEligibleEntry(const ResourceEntry& entry,
return entry.shared_with_me(); return entry.shared_with_me();
if (options & SEARCH_METADATA_OFFLINE) { if (options & SEARCH_METADATA_OFFLINE) {
if (entry.file_specific_info().is_hosted_document()) if (entry.file_specific_info().is_hosted_document()) {
return true; // Not all hosted documents are cached by Drive offline app.
FileCacheEntry cache_entry; // http://support.google.com/drive/bin/answer.py?hl=en&answer=1628467
it->GetCacheEntry(&cache_entry); switch (google_apis::ResourceEntry::GetEntryKindFromExtension(
return cache_entry.is_present(); 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". // Exclude "drive", "drive/root", and "drive/other".
......
...@@ -535,6 +535,17 @@ std::string ResourceEntry::GetHostedDocumentExtension() const { ...@@ -535,6 +535,17 @@ std::string ResourceEntry::GetHostedDocumentExtension() const {
return std::string(); 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 // static
int ResourceEntry::ClassifyEntryKindByFileExtension( int ResourceEntry::ClassifyEntryKindByFileExtension(
const base::FilePath& file_path) { const base::FilePath& file_path) {
...@@ -543,12 +554,7 @@ int ResourceEntry::ClassifyEntryKindByFileExtension( ...@@ -543,12 +554,7 @@ int ResourceEntry::ClassifyEntryKindByFileExtension(
#else #else
std::string file_extension = file_path.Extension(); std::string file_extension = file_path.Extension();
#endif #endif
for (size_t i = 0; i < arraysize(kEntryKindMap); ++i) { return ClassifyEntryKind(GetEntryKindFromExtension(file_extension));
const char* document_extension = kEntryKindMap[i].extension;
if (document_extension && file_extension == document_extension)
return ClassifyEntryKind(kEntryKindMap[i].kind);
}
return 0;
} }
// static // static
......
...@@ -509,6 +509,9 @@ class ResourceEntry : public CommonMetadata { ...@@ -509,6 +509,9 @@ class ResourceEntry : public CommonMetadata {
KIND_OF_FILE = 1 << 4, 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 // Classifies the EntryKind. The returned value is a bitmask of
// EntryKindClass. For example, DOCUMENT is classified as // EntryKindClass. For example, DOCUMENT is classified as
// KIND_OF_HOSTED_DOCUMENT and KIND_OF_GOOGLE_DOCUMENT, hence the returned // 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