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
|
// 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_manager_api.cc!
callback({
BODY_FONT_FAMILY: 'sans-serif',
BODY_FONT_SIZE: '13px',
FILE_IS_DIRECTORY: 'Folder',
PARENT_DIRECTORY: 'Parent Directory',
ROOT_DIRECTORY_LABEL: 'Files',
DOWNLOADS_DIRECTORY_LABEL: 'File Shelf',
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',
NEW_FOLDER_PROMPT: 'Enter a name for the new folder',
NEW_FOLDER_BUTTON_LABEL: 'New folder',
FILENAME_LABEL: 'File Name',
EJECT_BUTTON: 'Eject',
IMAGE_DIMENSIONS: 'Image Dimensions',
VOLUME_LABEL: 'Volume Label',
READ_ONLY: 'Read Only',
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',
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',
MANY_FILES_SELECTED: '$1 files selected, $2',
CONFIRM_DELETE: 'Are you sure?',
});
}
};
chrome.extension = {
getURL: function() {
return document.location.href;
}
};
chrome.test = {
sendMessage: function(msg) {
console.log('chrome.test.sendMessage: ' + msg);
}
};
|