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 // Custom binding for the chrome.app.runtime API. | 5 // Custom binding for the chrome.app.runtime API. |
6 | 6 |
7 var binding = require('binding').Binding.create('app.runtime'); | 7 var binding = require('binding').Binding.create('app.runtime'); |
8 | 8 |
9 var AppViewInternal = | 9 var AppViewInternal = |
10 require('binding').Binding.create('appViewInternal').generate(); | 10 require('binding').Binding.create('appViewInternal').generate(); |
(...skipping 29 matching lines...) Expand all Loading... | |
40 // An onLaunched corresponding to file_handlers in the app's manifest. | 40 // An onLaunched corresponding to file_handlers in the app's manifest. |
41 var items = []; | 41 var items = []; |
42 var numItems = launchData.items.length; | 42 var numItems = launchData.items.length; |
43 var itemLoaded = function(err, item) { | 43 var itemLoaded = function(err, item) { |
44 if (err) { | 44 if (err) { |
45 console.error('Error getting fileEntry, code: ' + err.code); | 45 console.error('Error getting fileEntry, code: ' + err.code); |
46 } else { | 46 } else { |
47 $Array.push(items, item); | 47 $Array.push(items, item); |
48 } | 48 } |
49 if (--numItems === 0) { | 49 if (--numItems === 0) { |
50 var data = { isKioskSession: launchData.isKioskSession }; | 50 if (items.length == 0) { |
51 if (items.length !== 0) { | 51 delete launchData.id; |
52 data.id = launchData.id; | 52 delete launchData.items; |
benwells
2014/10/28 21:22:48
Why is this changing?
cylee1
2014/10/29 16:40:00
The behavior is not changed - if "items" is empty,
benwells
2014/10/30 06:04:28
I think I see what you're trying to do. I'd prefer
| |
53 data.items = items; | 53 } else { |
54 launchData.items = items; | |
54 } | 55 } |
55 dispatch([data]); | 56 dispatch([launchData]); |
56 } | 57 } |
57 }; | 58 }; |
58 $Array.forEach(launchData.items, function(item) { | 59 $Array.forEach(launchData.items, function(item) { |
59 var fs = GetIsolatedFileSystem(item.fileSystemId); | 60 var rawEntry = item.rawEntry; |
60 fs.root.getFile(item.baseName, {}, function(fileEntry) { | 61 delete item.rawEntry; |
61 entryIdManager.registerEntry(item.entryId, fileEntry); | 62 var fs = GetIsolatedFileSystem(rawEntry.fileSystemId); |
62 itemLoaded(null, { entry: fileEntry, type: item.mimeType }); | 63 fs.root.getFile(rawEntry.baseName, {}, function(fileEntry) { |
64 entryIdManager.registerEntry(rawEntry.entryId, fileEntry); | |
65 item.entry = fileEntry; | |
benwells
2014/10/28 21:22:48
Again, why is this changing?
cylee1
2014/10/29 16:40:00
Explained above. It's only a re-implementation and
| |
66 itemLoaded(null, item); | |
63 }, function(fileError) { | 67 }, function(fileError) { |
64 itemLoaded(fileError); | 68 itemLoaded(fileError); |
65 }); | 69 }); |
66 }); | 70 }); |
67 } else { | 71 } else { |
68 // Default case. This currently covers an onLaunched corresponding to | 72 // Default case. This currently covers an onLaunched corresponding to |
69 // url_handlers in the app's manifest. | 73 // url_handlers in the app's manifest. |
70 dispatch([launchData]); | 74 dispatch([launchData]); |
71 } | 75 } |
72 }); | 76 }); |
73 | 77 |
74 exports.binding = binding.generate(); | 78 exports.binding = binding.generate(); |
OLD | NEW |