1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
|
// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
/**
* Mock out the chrome.fileBrowserPrivate API for use in the harness.
*/
chrome.fileBrowserPrivate = {
/**
* Return a normal HTML5 filesystem api, rather than the real local
* filesystem.
*
* You must start chrome with --allow-file-access-from-files and
* --unlimited-quota-for-files in order for this to work.
*/
requestLocalFileSystem: function(callback) {
window.webkitRequestFileSystem(window.PERSISTENT, 16 * 1024 * 1024,
callback,
util.ferr('Error requesting filesystem'));
},
/**
* View multiple files.
*/
viewFiles: function(selectedFiles) {
console.log('viewFiles called: ' + selectedFiles.length +
' files selected');
},
/**
* Select multiple files.
*/
selectFiles: function(selectedFiles) {
console.log('selectFiles called: ' + selectedFiles.length +
' files selected');
},
/**
* Select a single file.
*/
selectFile: function(selectedFile, index) {
console.log('selectFile called: ' + selectedFile + ', ' + index);
},
/**
* Cancel the dialog without selecting anything.
*/
cancelDialog: function() {
console.log('cancelDialog called');
},
/**
* Disk mount/unmount notification.
*/
onDiskChanged: {
callbacks: [],
addListener: function(cb) { this.callbacks.push(cb) }
},
getFileTasks: function(urlList, callback) {
if (urlList.length == 0)
return callback([]);
if (!callback)
throw new Error('Missing callback');
var tasks =
[ { taskId: 'upload-picasr',
title: 'Upload to Picasr',
regexp: /\.(jpe?g|gif|png|cr2?|tiff)$/i,
iconUrl: 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAOCAYAAAAmL5yKAAAAAXNSR0IArs4c6QAAAAZiS0dEAP8A/wD/oL2nkwAAAAlwSFlzAAALEwAACxMBAJqcGAAAAAd0SU1FB9sEEBcJA0AW6BUAAACdSURBVCjPzZExC4MwEIW/1L2U/gwHf1/3WrqIkz/PWVAoXdolRNLBJNhwiS6FPjguuZf3csnBL2HBLikNtSFmS3yIROUMWhKrHR2XNZiLa9tGkaqtDa4TjBX0yIf8+osLnT3BnKDIvddm/uCRE+fgDc7r4iBPJWAWDADQLh8Tt3neSAYKdAu8gc69L4rAN8v+Fk/3DrxcluD5mr/CB34jRiE3x1kcAAAAAElFTkSuQmCC',
},
{ taskId: 'upload-orcbook',
title: 'Upload to OrcBook',
regexp: /\.(jpe?g|png|cr2?|tiff)$/i,
iconUrl: 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAOCAYAAAAmL5yKAAAAAXNSR0IArs4c6QAAAAZiS0dEAP8A/wD/oL2nkwAAAAlwSFlzAAALEwAACxMBAJqcGAAAAAd0SU1FB9sEEBcOAw9XftIAAADFSURBVCjPrZKxCsIwEIa/FHFwsvYxROjSQXAoqLiIL+xgBtvZ91A6uOnQc2hT0zRqkR4c3P25+/PfJTCwLU6wEpgBWkDXuInDPSwF5r7mJIeNQFTnIiCeONpVdYlLoK9wEUhNg8+B9FDVaZcgCKAovjTXfvPJFwGZtKW60pt8bOGBzfLouemnFY/MAs8wDeEI4NzaybewBu4AysKVgrK0gfe5iB9vjdAUqQ/S1Y/R3IX9Zc1zxc7zxe2/0Iskt7AsG0hhx14W8XV43FgV4gAAAABJRU5ErkJggg==',
},
];
// Copy all tasks, then remove the ones that don't match.
var candidateTasks = [].concat(tasks);
for (var i = 0; i < urlList.length; i++) {
if (candidateTasks.length == 0)
return callback([]);
for (var taskIndex = candidateTasks.length - 1; taskIndex >= 0;
taskIndex--) {
if (candidateTasks[taskIndex].regexp.test(urlList[i]))
continue;
// This task doesn't match this url, remove the task.
candidateTasks.splice(taskIndex, 1);
}
}
callback(candidateTasks);
},
executeTask: function(taskId, urlList) {
console.log('executing task: ' + taskId + ': ' + urlList.length + ' urls');
},
/**
* Return localized strings.
*/
getStrings: function(callback) {
// Keep this list in sync with the strings in generated_resources.grd and
// extension_file_browser_private_api.cc!
callback({
// These two are from locale_settings*.grd
WEB_FONT_FAMILY: 'Chrome Droid Sans,Droid Sans Fallback,sans-serif',
WEB_FONT_SIZE: '84%',
FILE_IS_DIRECTORY: 'Folder',
PARENT_DIRECTORY: 'Parent Directory',
ROOT_DIRECTORY_LABEL: 'Files',
DOWNLOADS_DIRECTORY_LABEL: 'File Shelf',
DOWNLOADS_DIRECTORY_WARNING: "<strong>Caution:</strong> These files are temporary and may be automatically deleted to free up disk space. <a href='$1'>Learn More</a>",
MEDIA_DIRECTORY_LABEL: 'External Storage',
NAME_COLUMN_LABEL: 'Name',
SIZE_COLUMN_LABEL: 'Size',
DATE_COLUMN_LABEL: 'Date',
PREVIEW_COLUMN_LABEL: 'Preview',
ERROR_CREATING_FOLDER: 'Unable to create folder "$1": $2',
ERROR_INVALID_FOLDER_CHARACTER: 'Invalid character in folder name: $1',
ERROR_INVALID_FILE_CHARACTER: 'Invalid character in file name: $1',
ERROR_RESERVED_NAME: 'This name may not be used as a file of folder name',
ERROR_WHITESPACE_NAME: 'Invalid name',
NEW_FOLDER_PROMPT: 'Enter a name for the new folder',
ERROR_NEW_FOLDER_EMPTY_NAME: 'Please specify a folder name',
NEW_FOLDER_BUTTON_LABEL: 'New folder',
FILENAME_LABEL: 'File Name',
DIMENSIONS_LABEL: 'Dimensions',
DIMENSIONS_FORMAT: '$1 x $2',
EJECT_BUTTON: 'Eject',
IMAGE_DIMENSIONS: 'Image Dimensions',
VOLUME_LABEL: 'Volume Label',
READ_ONLY: 'Read Only',
CONFIRM_OVERWRITE_FILE: 'A file named "$1" already exists. Do you want to replace it?',
FILE_ALREADY_EXISTS: 'The file named "$1" already exists. Please choose a different name.',
DIRECTORY_ALREADY_EXISTS: 'The directory named "$1" already exists. Please choose a different name.',
ERROR_RENAMING: 'Unable to rename "$1": $2',
RENAME_PROMPT: 'Enter a new name',
RENAME_BUTTON_LABEL: 'Rename',
ERROR_DELETING: 'Unable to delete "$1": $2',
DELETE_BUTTON_LABEL: 'Delete',
ERROR_MOVING: 'Unable to move "$1": $2',
MOVE_BUTTON_LABEL: 'Move',
ERROR_PASTING: 'Unable to paste "$1": $2',
PASTE_BUTTON_LABEL: 'Paste',
COPY_BUTTON_LABEL: 'Copy',
CUT_BUTTON_LABEL: 'Cut',
SELECTION_COPIED: 'Selection copied to clipboard.',
SELECTION_CUT: 'Selection cut to clipboard.',
PASTE_STARTED: 'Pasting...',
PASTE_SOME_PROGRESS: 'Pasting $1 of $2 items...',
PASTE_COMPLETE: 'Paste complete.',
PASTE_CANCELLED: 'Paste cancelled.',
PASTE_TARGET_EXISTS_ERROR: 'Paste failed, item exists: $1',
PASTE_FILESYSTEM_ERROR: 'Paste failed, filesystem error: $1',
PASTE_UNEXPECTED_ERROR: 'Paste failed, unexpected error: $1',
DEVICE_TYPE_FLASH: 'Flash Device',
DEVICE_TYPE_HDD: 'Hard Disk Device',
DEVICE_TYPE_OPTICAL: 'Optical Device',
DEVICE_TYPE_UNDEFINED: 'Unknown Device',
CANCEL_LABEL: 'Cancel',
OPEN_LABEL: 'Open',
SAVE_LABEL: 'Save',
SELECT_FOLDER_TITLE: 'Select a folder to open',
SELECT_OPEN_FILE_TITLE: 'Select a file to open',
SELECT_OPEN_MULTI_FILE_TITLE: 'Select one or more files',
SELECT_SAVEAS_FILE_TITLE: 'Save file as',
COMPUTING_SELECTION: 'Computing selection...',
NOTHING_SELECTED: 'No files selected',
ONE_FILE_SELECTED: 'One file selected, $1',
ONE_DIRECTORY_SELECTED: 'One directory selected',
MANY_FILES_SELECTED: '$1 files selected, $2',
MANY_DIRECTORIES_SELECTED: '$1 directories selected',
MANY_ENTRIES_SELECTED: '$1 items selected, $2',
CONFIRM_DELETE: 'Are you sure?',
});
}
};
chrome.fileBrowserHandler = {
onExecute: {
callbacks: [],
addListener: function(cb) { this.callbacks.push(cb) }
}
};
chrome.extension = {
getURL: function() {
return document.location.href;
}
};
chrome.test = {
verbose: false,
sendMessage: function(msg) {
if (chrome.test.verbose)
console.log('chrome.test.sendMessage: ' + msg);
}
};
|