OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 'use strict'; | 5 'use strict'; |
6 | 6 |
7 /** | 7 /** |
8 * Media manager class. | 8 * Media manager class. |
9 * This class supports the information for the media file. | 9 * This class supports the information for the media file. |
10 * @param {FileEntry} entry Entry of media file. This must be a external entry. | 10 * @param {FileEntry} entry Entry of media file. This must be a external entry. |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
98 /** | 98 /** |
99 * Retrieves the mime of file. | 99 * Retrieves the mime of file. |
100 * | 100 * |
101 * @return {Promise} Promise which is resolved with the mime. Reject if failed. | 101 * @return {Promise} Promise which is resolved with the mime. Reject if failed. |
102 */ | 102 */ |
103 MediaManager.prototype.getMime = function() { | 103 MediaManager.prototype.getMime = function() { |
104 if (this.cachedDriveProp_) | 104 if (this.cachedDriveProp_) |
105 return Promise.resolve(this.cachedDriveProp_.thumbnailUrl); | 105 return Promise.resolve(this.cachedDriveProp_.thumbnailUrl); |
106 | 106 |
107 return new Promise(function(fulfill, reject) { | 107 return new Promise(function(fulfill, reject) { |
108 chrome.fileBrowserPrivate.getDriveEntryProperties( | 108 chrome.fileBrowserPrivate.getEntryProperties( |
109 [this.entry_.toURL()], fulfill); | 109 [this.entry_.toURL()], fulfill); |
110 }.bind(this)).then(function(props) { | 110 }.bind(this)).then(function(props) { |
111 if (!props || !props[0] || !props[0].contentMimeType) { | 111 if (!props || !props[0] || !props[0].contentMimeType) { |
112 // TODO(yoshiki): Adds a logic to guess the mime. | 112 // TODO(yoshiki): Adds a logic to guess the mime. |
113 return Promise.reject('Mime fetch failed.'); | 113 return Promise.reject('Mime fetch failed.'); |
114 } else { | 114 } else { |
115 this.cachedDriveProp_ = props[0]; | 115 this.cachedDriveProp_ = props[0]; |
116 return props[0].contentMimeType; | 116 return props[0].contentMimeType; |
117 } | 117 } |
118 }.bind(this)); | 118 }.bind(this)); |
119 }; | 119 }; |
120 | 120 |
121 /** | 121 /** |
122 * Retrieves the thumbnail url of file. | 122 * Retrieves the thumbnail url of file. |
123 * | 123 * |
124 * @return {Promise} Promise which is resolved with the url. Reject if failed. | 124 * @return {Promise} Promise which is resolved with the url. Reject if failed. |
125 */ | 125 */ |
126 MediaManager.prototype.getThumbnail = function() { | 126 MediaManager.prototype.getThumbnail = function() { |
127 if (this.cachedDriveProp_) | 127 if (this.cachedDriveProp_) |
128 return Promise.resolve(this.cachedDriveProp_.thumbnailUrl); | 128 return Promise.resolve(this.cachedDriveProp_.thumbnailUrl); |
129 | 129 |
130 return new Promise(function(fulfill, reject) { | 130 return new Promise(function(fulfill, reject) { |
131 chrome.fileBrowserPrivate.getDriveEntryProperties( | 131 chrome.fileBrowserPrivate.getEntryProperties( |
132 [this.entry_.toURL()], fulfill); | 132 [this.entry_.toURL()], fulfill); |
133 }.bind(this)).then(function(props) { | 133 }.bind(this)).then(function(props) { |
134 if (!props || !props[0] || !props[0].thumbnailUrl) { | 134 if (!props || !props[0] || !props[0].thumbnailUrl) { |
135 // TODO(yoshiki): Adds a logic to guess the mime. | 135 // TODO(yoshiki): Adds a logic to guess the mime. |
136 return Promise.reject('Thumbnail fetch failed.'); | 136 return Promise.reject('Thumbnail fetch failed.'); |
137 } else { | 137 } else { |
138 this.cachedDriveProp_ = props[0]; | 138 this.cachedDriveProp_ = props[0]; |
139 return props[0].thumbnailUrl; | 139 return props[0].thumbnailUrl; |
140 } | 140 } |
141 }.bind(this)); | 141 }.bind(this)); |
142 }; | 142 }; |
OLD | NEW |