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

Side by Side Diff: chrome/test/data/extensions/api_test/filesystem_handler_lazy_background/background.js

Issue 10067021: Postpone setting up file handler's file permissions if handler is running lazy background page. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase 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
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 /*
6 This extension is a file intent handler with transient background page and does
7 the following during the test:
8
9 1. It first registers content hander.
10 2. When content handler callback is invoked, opens tab.html page and passes
11 file url via persistent localStorage var.
12 3. Tries to resolve target file url and reads its content.
13 4. Send file content to file browser extension.
14 */
15
16 function errorCallback(error) {
17 var msg = '';
18 if (!error.code) {
19 msg = error.message;
20 } else {
21 switch (error.code) {
22 case FileError.QUOTA_EXCEEDED_ERR:
23 msg = 'QUOTA_EXCEEDED_ERR';
24 break;
25 case FileError.NOT_FOUND_ERR:
26 msg = 'NOT_FOUND_ERR';
27 break;
28 case FileError.SECURITY_ERR:
29 msg = 'SECURITY_ERR';
30 break;
31 case FileError.INVALID_MODIFICATION_ERR:
32 msg = 'INVALID_MODIFICATION_ERR';
33 break;
34 case FileError.INVALID_STATE_ERR:
35 msg = 'INVALID_STATE_ERR';
36 break;
37 default:
38 msg = 'Unknown Error';
39 break;
40 };
41 }
42
43 // The ID of the extension we want to talk to.
44 var fileBrowserExtensionId = "ddammdhioacbehjngdmkjcjbnfginlla";
45
46 chrome.extension.sendRequest(fileBrowserExtensionId,
47 {fileContent: null,
48 error: {message: "File handler error: " + msg}},
49 function(response) {});
50 };
51
52 function runFileSystemHandlerTest(entries) {
53 if (!entries || entries.length != 1 || !entries[0]) {
54 errorCallback({message: "Invalid file entries"});
55 return;
56 }
57 localStorage.entryURL = entries[0].toURL();
58
59 chrome.tabs.create({url: 'tab.html'});
60 };
61
62 chrome.fileBrowserHandler.onExecute.addListener(function(id, details) {
63 if (id != "AbcAction" && id != "BaseAction" && id != "123Action") {
64 errorCallback({message: "Unexpected action id: " + id});
65 return;
66 }
67 var file_entries = details.entries;
68 if (!file_entries || file_entries.length != 1) {
69 errorCallback({message: "Unexpected file url list"});
70 return;
71 }
72 chrome.tabs.get(details.tab_id, function(tab) {
73 if (tab.title != "file browser component test") {
74 errorCallback({message: "Unexpected tab title: " + tab.title});
75 return;
76 }
77 runFileSystemHandlerTest(file_entries);
78 });
79 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698