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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 /** 5 /**
6 * MetadataCache is a map from url to an object containing properties. 6 * MetadataCache is a map from url to an object containing properties.
7 * Properties are divided by types, and all properties of one type are accessed 7 * Properties are divided by types, and all properties of one type are accessed
8 * at once. 8 * at once.
9 * Some of the properties: 9 * Some of the properties:
10 * { 10 * {
(...skipping 596 matching lines...) Expand 10 before | Expand all | Expand 10 after
607 var self = this; 607 var self = this;
608 608
609 chrome.fileBrowserPrivate.getGDataFileProperties(urls, function(props) { 609 chrome.fileBrowserPrivate.getGDataFileProperties(urls, function(props) {
610 for (var index = 0; index < urls.length; index++) { 610 for (var index = 0; index < urls.length; index++) {
611 callbacks[index](self.convert_(props[index])); 611 callbacks[index](self.convert_(props[index]));
612 } 612 }
613 }); 613 });
614 }; 614 };
615 615
616 /** 616 /**
617 * Pattern for Docs urls that are available in the offline mode.
618 */
619 GDataProvider.OFFLINE_DOCS_REGEXP = /\/(document|spreadsheet)\//;
620
621 /**
622 * @param {GDataFileProperties} data GData file properties.
623 * @return {boolean} True if the file is available offline.
624 */
625 GDataProvider.isAvailableOffline = function(data) {
626 return data.isPresent ||
627 (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
628 };
629
630 /**
617 * Converts API metadata to internal format. 631 * Converts API metadata to internal format.
618 * @param {Object} data Metadata from API call. 632 * @param {Object} data Metadata from API call.
619 * @return {Object} Metadata in internal format. 633 * @return {Object} Metadata in internal format.
620 * @private 634 * @private
621 */ 635 */
622 GDataProvider.prototype.convert_ = function(data) { 636 GDataProvider.prototype.convert_ = function(data) {
623 var result = {}; 637 var result = {};
624 result.gdata = { 638 result.gdata = {
625 present: data.isPresent, 639 present: data.isPresent,
626 pinned: data.isPinned, 640 pinned: data.isPinned,
627 hosted: data.isHosted, 641 hosted: data.isHosted,
628 dirty: data.isDirty, 642 dirty: data.isDirty,
629 availableOffline: data.isPresent && !data.isHosted, 643 availableOffline: GDataProvider.isAvailableOffline(data),
630 contentUrl: (data.contentUrl || '').replace(/\?.*$/gi, ''), 644 contentUrl: (data.contentUrl || '').replace(/\?.*$/gi, ''),
631 editUrl: data.editUrl || '' 645 editUrl: data.editUrl || ''
632 }; 646 };
633 if ('thumbnailUrl' in data) { 647 if ('thumbnailUrl' in data) {
634 result.thumbnail = { 648 result.thumbnail = {
635 url: data.thumbnailUrl, 649 url: data.thumbnailUrl,
636 transform: '' 650 transform: ''
637 }; 651 };
638 } 652 }
639 return result; 653 return result;
640 }; 654 };
OLDNEW
« 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