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

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

Issue 22944002: Implementation of the "Redirect URLs to Packaged Apps" feature. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fully reverted extension_service.cc to original form 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 chromeHidden = requireNative('chrome_hidden').GetChromeHidden(); 9 var chromeHidden = requireNative('chrome_hidden').GetChromeHidden();
10 var chrome = requireNative('chrome').GetChrome(); 10 var chrome = requireNative('chrome').GetChrome();
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 }); 45 });
46 })(fe, fs); 46 })(fe, fs);
47 } 47 }
48 dispatchIfNoPendingCallbacks(); 48 dispatchIfNoPendingCallbacks();
49 }); 49 });
50 50
51 chromeHidden.Event.registerArgumentMassager('app.runtime.onLaunched', 51 chromeHidden.Event.registerArgumentMassager('app.runtime.onLaunched',
52 function(args, dispatch) { 52 function(args, dispatch) {
53 var launchData = args[0]; 53 var launchData = args[0];
54 54
55 if (launchData && typeof launchData.id !== 'undefined') { 55 if (!launchData) {
56 // new-style dispatch. 56 dispatch([]);
57 return;
58 }
59
60 if (launchData.items) {
61 // An onLaunched corresponding to file_handlers in the app's manifest.
62 // Need to do some special processin for this case.
not at google - send to devlin 2013/08/29 17:35:56 processing but this is kind of vague and so eithe
sergeygs 2013/08/30 00:39:44 Done. Removed :) Also moved the default case into
63 // NOTE: Using the new-style dispatch.
57 var items = [] 64 var items = []
58 var numItems = launchData.items.length; 65 var numItems = launchData.items.length;
59 var itemLoaded = function(err, item) { 66 var itemLoaded = function(err, item) {
60 if (err) { 67 if (err) {
61 console.error('Error getting fileEntry, code: ' + err.code); 68 console.error('Error getting fileEntry, code: ' + err.code);
62 } else { 69 } else {
63 items.push(item); 70 items.push(item);
64 } 71 }
65 if (--numItems === 0) { 72 if (--numItems === 0) {
66 if (items.length === 0) { 73 if (items.length === 0) {
67 dispatch([]); 74 dispatch([]);
68 } else { 75 } else {
69 var data = { id: launchData.id, items: items }; 76 var data = { id: launchData.id, items: items };
70 dispatch([data]); 77 dispatch([data]);
71 } 78 }
72 } 79 }
73 }; 80 };
74 forEach(launchData.items, function(i, item) { 81 forEach(launchData.items, function(i, item) {
75 var fs = GetIsolatedFileSystem(item.fileSystemId); 82 var fs = GetIsolatedFileSystem(item.fileSystemId);
76 fs.root.getFile(item.baseName, {}, function(fileEntry) { 83 fs.root.getFile(item.baseName, {}, function(fileEntry) {
77 itemLoaded(null, { entry: fileEntry, type: item.mimeType }); 84 itemLoaded(null, { entry: fileEntry, type: item.mimeType });
78 }, function(fileError) { 85 }, function(fileError) {
79 itemLoaded(fileError); 86 itemLoaded(fileError);
80 }); 87 });
81 }); 88 });
82 } else if (launchData) { 89 return;
83 dispatch([launchData]);
84 } else {
85 dispatch([]);
86 } 90 }
91
92 // Default case. This currently covers an onLaunched corresponding to
93 // url_handlers in the app's manifest.
94 dispatch([launchData]);
87 }); 95 });
88 96
89 exports.binding = binding.generate(); 97 exports.binding = binding.generate();
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698