Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2707)

Unified Diff: chrome/browser/resources/file_manager/js/metadata/metadata_cache.js

Issue 10255005: [File Manager] Open hosted documents in offline mode (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/resources/file_manager/js/metadata/metadata_cache.js
diff --git a/chrome/browser/resources/file_manager/js/metadata/metadata_cache.js b/chrome/browser/resources/file_manager/js/metadata/metadata_cache.js
index 88e373bb22aa32d18dfa6b036e103ba0adf10bc2..5f19caa113d97799cd7d5aa686f48ffc8adce268 100644
--- a/chrome/browser/resources/file_manager/js/metadata/metadata_cache.js
+++ b/chrome/browser/resources/file_manager/js/metadata/metadata_cache.js
@@ -614,6 +614,20 @@ GDataProvider.prototype.callApi_ = function() {
};
/**
+ * Pattern for Docs urls that are available in the offline mode.
+ */
+GDataProvider.OFFLINE_DOCS_REGEXP = /\/(document|spreadsheet)\//;
+
+/**
+ * @param {GDataFileProperties} data GData file properties.
+ * @return {boolean} True if the file is available offline.
+ */
+GDataProvider.isAvailableOffline = function(data) {
+ return data.isPresent ||
+ (data.isHosted && GDataProvider.OFFLINE_DOCS_REGEXP.exec(data.editUrl));
Dmitry Zvorygin 2012/04/28 10:55:42 I'm not a RegEx guru, but why not 'test' here, ins
Vladislav Kaznacheev 2012/04/28 11:05:21 You are right, |test| is more appropriate. On 201
+};
+
+/**
* Converts API metadata to internal format.
* @param {Object} data Metadata from API call.
* @return {Object} Metadata in internal format.
@@ -626,7 +640,7 @@ GDataProvider.prototype.convert_ = function(data) {
pinned: data.isPinned,
hosted: data.isHosted,
dirty: data.isDirty,
- availableOffline: data.isPresent && !data.isHosted,
+ availableOffline: GDataProvider.isAvailableOffline(data),
contentUrl: (data.contentUrl || '').replace(/\?.*$/gi, ''),
editUrl: data.editUrl || ''
};
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698