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

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

Issue 23847004: "Redirecting URLs to Packaged Apps" implementation: revised (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Addressed the comment in app_window_contents.cc 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 && typeof launchData.id !== 'undefined') { 22 if (!launchData) {
23 // new-style dispatch. 23 dispatch([]);
not at google - send to devlin 2013/09/03 18:28:04 for consistency with the other comments should you
sergeygs 2013/09/04 03:29:17 Done.
24 return;
25 }
26
27 if (launchData.items) {
28 // An onLaunched corresponding to file_handlers in the app's manifest.
29 // NOTE: Using the new-style dispatch.
not at google - send to devlin 2013/09/03 18:28:04 this NOTE doesn't add anything.
sergeygs 2013/09/04 03:29:17 I wasn't the one who added it initially, so I didn
24 var items = [] 30 var items = []
25 var numItems = launchData.items.length; 31 var numItems = launchData.items.length;
26 var itemLoaded = function(err, item) { 32 var itemLoaded = function(err, item) {
27 if (err) { 33 if (err) {
28 console.error('Error getting fileEntry, code: ' + err.code); 34 console.error('Error getting fileEntry, code: ' + err.code);
29 } else { 35 } else {
30 $Array.push(items, item); 36 $Array.push(items, item);
31 } 37 }
32 if (--numItems === 0) { 38 if (--numItems === 0) {
33 if (items.length === 0) { 39 if (items.length === 0) {
34 dispatch([]); 40 dispatch([]);
35 } else { 41 } else {
36 var data = { id: launchData.id, items: items }; 42 var data = { id: launchData.id, items: items };
37 dispatch([data]); 43 dispatch([data]);
38 } 44 }
39 } 45 }
40 }; 46 };
41 $Array.forEach(launchData.items, function(item) { 47 $Array.forEach(launchData.items, function(item) {
42 var fs = GetIsolatedFileSystem(item.fileSystemId); 48 var fs = GetIsolatedFileSystem(item.fileSystemId);
43 fs.root.getFile(item.baseName, {}, function(fileEntry) { 49 fs.root.getFile(item.baseName, {}, function(fileEntry) {
44 entryIdManager.registerEntry(item.entryId, fileEntry); 50 entryIdManager.registerEntry(item.entryId, fileEntry);
45 itemLoaded(null, { entry: fileEntry, type: item.mimeType }); 51 itemLoaded(null, { entry: fileEntry, type: item.mimeType });
46 }, function(fileError) { 52 }, function(fileError) {
47 itemLoaded(fileError); 53 itemLoaded(fileError);
48 }); 54 });
49 }); 55 });
50 } else if (launchData) { 56 } else {
57 // Default case. This currently covers an onLaunched corresponding to
58 // url_handlers in the app's manifest.
51 dispatch([launchData]); 59 dispatch([launchData]);
52 } else {
53 dispatch([]);
54 } 60 }
55 }); 61 });
56 62
57 exports.binding = binding.generate(); 63 exports.binding = binding.generate();
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698