OLD | NEW |
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 function MockEventSource() { | 5 function MockEventSource() { |
6 this.listeners_ = []; | 6 this.listeners_ = []; |
7 } | 7 } |
8 | 8 |
9 /** | 9 /** |
10 * Add a listener. | 10 * Add a listener. |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
120 removeFileWatch: function(path, callback) { callback(true) }, | 120 removeFileWatch: function(path, callback) { callback(true) }, |
121 | 121 |
122 /** | 122 /** |
123 * Returns common tasks for a given list of files. | 123 * Returns common tasks for a given list of files. |
124 * @return {Array.<Object>} Array of task descriptors. | 124 * @return {Array.<Object>} Array of task descriptors. |
125 */ | 125 */ |
126 getFileTasks: function(urlList, callback) { | 126 getFileTasks: function(urlList, callback) { |
127 if (urlList.length == 0) | 127 if (urlList.length == 0) |
128 return callback([]); | 128 return callback([]); |
129 | 129 |
130 // This is how File Manager gets the extension id. | 130 var extensionId = util.getExtensionId(); |
131 var extensionId = chrome.extension.getURL('').split('/')[2]; | |
132 | 131 |
133 if (!callback) | 132 if (!callback) |
134 throw new Error('Missing callback'); | 133 throw new Error('Missing callback'); |
135 | 134 |
136 var emptyIcon = 'data:image/gif;base64,' + | 135 var emptyIcon = 'data:image/gif;base64,' + |
137 'R0lGODlhAQABAPABAP///wAAACH5BAEKAAAALAAAAAABAAEAAAICRAEAOw%3D%3D'; | 136 'R0lGODlhAQABAPABAP///wAAACH5BAEKAAAALAAAAAABAAEAAAICRAEAOw%3D%3D'; |
138 | 137 |
139 var tasks = [ | 138 var tasks = [ |
140 { taskId: extensionId + '|play', | 139 { taskId: extensionId + '|play', |
141 title: 'Listen', | 140 title: 'Listen', |
142 regexp: /\.(flac|m4a|mp3|oga|ogg|wav)$/i, | 141 regexp: /\.(flac|m4a|mp3|oga|ogg|wav)$/i, |
143 iconUrl: emptyIcon | 142 iconUrl: emptyIcon |
144 }, | 143 }, |
145 { taskId: extensionId + '|mount-archive', | 144 { taskId: extensionId + '|mount-archive', |
146 title: 'Mount', | 145 title: 'Mount', |
147 regexp: /\.(rar|tar|tar.bz2|tar.gz|tbz|tbz2|tgz|zip)$/i, | 146 regexp: /\.(rar|tar|tar.bz2|tar.gz|tbz|tbz2|tgz|zip)$/i, |
148 iconUrl: emptyIcon | 147 iconUrl: emptyIcon |
149 }, | 148 }, |
150 { | 149 { |
151 taskId: extensionId + '|gallery', | 150 taskId: extensionId + '|gallery', |
152 title: 'View', | 151 title: 'View', |
153 regexp: /\.(bmp|gif|jpe?g|png|webp|3gp|avi|m4v|mov|mp4|mpeg4?|mpg4?|ogm|
ogv|ogx|webm)$/i, | 152 regexp: /\.(bmp|gif|jpe?g|png|webp|3gp|avi|m4v|mov|mp4|mpeg4?|mpg4?|ogm|
ogv|ogx|webm)$/i, |
154 iconUrl: emptyIcon | 153 iconUrl: emptyIcon |
155 }, | 154 }, |
156 { | 155 { |
157 taskId: 'fake-extension-id|fake-item', | 156 taskId: 'fake-extension-id|fake-item', |
158 title: 'External action', | 157 title: 'External action', |
159 regexp: /\.(bmp|gif|jpe?g|png|webp|3gp|avi|m4v|mov|mp4|mpeg4?|mpg4?|ogm|
ogv|ogx|webm)$/i, | 158 regexp: /\.(bmp|gif|jpe?g|png|webp|3gp|avi|m4v|mov|mp4|mpeg4?|mpg4?|ogm|
ogv|ogx|webm)$/i, |
160 iconUrl: 'images/icon16.png' | 159 iconUrl: 'images/files/file_types/generic.png' |
| 160 }, |
| 161 { |
| 162 taskId: 'fake-extension-id|upload', |
| 163 title: 'Upload video', |
| 164 regexp: /\.(3gp|avi|m4v|mov|mp4|mpeg4?|mpg4?|ogm|ogv|ogx|webm)$/i, |
| 165 iconUrl: 'images/files/file_types/video.png' |
161 }, | 166 }, |
162 { | 167 { |
163 taskId: extensionId + '|view-in-browser', | 168 taskId: extensionId + '|view-in-browser', |
164 title: 'View', | 169 title: 'View', |
165 regexp: /\.(html?|log|mht|mhtml|txt)$/i, | 170 regexp: /\.(html?|log|mht|mhtml|txt)$/i, |
166 iconUrl: emptyIcon | 171 iconUrl: emptyIcon |
167 }, | 172 }, |
168 { | 173 { |
169 taskId: extensionId + '|view-pdf', | 174 taskId: extensionId + '|view-pdf', |
170 title: 'View', | 175 title: 'View', |
(...skipping 646 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
817 | 822 |
818 setWindowHeight: function(height) { | 823 setWindowHeight: function(height) { |
819 this.popup_.style.height = height + 'px'; | 824 this.popup_.style.height = height + 'px'; |
820 }, | 825 }, |
821 | 826 |
822 closeWindow: function() { | 827 closeWindow: function() { |
823 this.popup_.parentNode.removeChild(this.popup_); | 828 this.popup_.parentNode.removeChild(this.popup_); |
824 this.popup_ = null; | 829 this.popup_ = null; |
825 } | 830 } |
826 }; | 831 }; |
OLD | NEW |