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

Side by Side Diff: trunk/src/chrome/renderer/resources/extensions/app_runtime_custom_bindings.js

Issue 23600025: Revert 222235 ""Redirecting URLs to Packaged Apps" implementatio..." (Closed) Base URL: svn://svn.chromium.org/chrome/
Patch Set: Created 7 years, 3 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
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 // 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 eventBindings = require('event_bindings'); 9 var eventBindings = require('event_bindings');
10 var fileSystemHelpers = requireNative('file_system_natives'); 10 var fileSystemHelpers = requireNative('file_system_natives');
11 var GetIsolatedFileSystem = fileSystemHelpers.GetIsolatedFileSystem; 11 var GetIsolatedFileSystem = fileSystemHelpers.GetIsolatedFileSystem;
12 var appNatives = requireNative('app_runtime'); 12 var appNatives = requireNative('app_runtime');
13 var DeserializeString = appNatives.DeserializeString; 13 var DeserializeString = appNatives.DeserializeString;
14 var SerializeToString = appNatives.SerializeToString; 14 var SerializeToString = appNatives.SerializeToString;
15 var CreateBlob = appNatives.CreateBlob; 15 var CreateBlob = appNatives.CreateBlob;
16 var entryIdManager = require('entryIdManager'); 16 var entryIdManager = require('entryIdManager');
17 17
18 eventBindings.registerArgumentMassager('app.runtime.onLaunched', 18 eventBindings.registerArgumentMassager('app.runtime.onLaunched',
19 function(args, dispatch) { 19 function(args, dispatch) {
20 var launchData = args[0]; 20 var launchData = args[0];
21 21
22 if (!launchData) { 22 if (launchData && typeof launchData.id !== 'undefined') {
23 // An onLaunched corresponding to launching directly or from 23 // new-style dispatch.
24 // the app launcher or browser.
25 dispatch([]);
26 return;
27 }
28
29 if (launchData.items) {
30 // An onLaunched corresponding to file_handlers in the app's manifest.
31 var items = [] 24 var items = []
32 var numItems = launchData.items.length; 25 var numItems = launchData.items.length;
33 var itemLoaded = function(err, item) { 26 var itemLoaded = function(err, item) {
34 if (err) { 27 if (err) {
35 console.error('Error getting fileEntry, code: ' + err.code); 28 console.error('Error getting fileEntry, code: ' + err.code);
36 } else { 29 } else {
37 $Array.push(items, item); 30 $Array.push(items, item);
38 } 31 }
39 if (--numItems === 0) { 32 if (--numItems === 0) {
40 if (items.length === 0) { 33 if (items.length === 0) {
41 dispatch([]); 34 dispatch([]);
42 } else { 35 } else {
43 var data = { id: launchData.id, items: items }; 36 var data = { id: launchData.id, items: items };
44 dispatch([data]); 37 dispatch([data]);
45 } 38 }
46 } 39 }
47 }; 40 };
48 $Array.forEach(launchData.items, function(item) { 41 $Array.forEach(launchData.items, function(item) {
49 var fs = GetIsolatedFileSystem(item.fileSystemId); 42 var fs = GetIsolatedFileSystem(item.fileSystemId);
50 fs.root.getFile(item.baseName, {}, function(fileEntry) { 43 fs.root.getFile(item.baseName, {}, function(fileEntry) {
51 entryIdManager.registerEntry(item.entryId, fileEntry); 44 entryIdManager.registerEntry(item.entryId, fileEntry);
52 itemLoaded(null, { entry: fileEntry, type: item.mimeType }); 45 itemLoaded(null, { entry: fileEntry, type: item.mimeType });
53 }, function(fileError) { 46 }, function(fileError) {
54 itemLoaded(fileError); 47 itemLoaded(fileError);
55 }); 48 });
56 }); 49 });
50 } else if (launchData) {
51 dispatch([launchData]);
57 } else { 52 } else {
58 // Default case. This currently covers an onLaunched corresponding to 53 dispatch([]);
59 // url_handlers in the app's manifest.
60 dispatch([launchData]);
61 } 54 }
62 }); 55 });
63 56
64 exports.binding = binding.generate(); 57 exports.binding = binding.generate();
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698