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

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: Created 7 years, 4 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 typeof launchData.id !== 'undefined' &&
57 typeof launchData.items !== 'undefined') {
58 // An onLaunched corresponding to file_handlers in the app's manifest.
59 // NOTE: Using the new-style dispatch.
57 var items = [] 60 var items = []
58 var numItems = launchData.items.length; 61 var numItems = launchData.items.length;
59 var itemLoaded = function(err, item) { 62 var itemLoaded = function(err, item) {
60 if (err) { 63 if (err) {
61 console.error('Error getting fileEntry, code: ' + err.code); 64 console.error('Error getting fileEntry, code: ' + err.code);
62 } else { 65 } else {
63 items.push(item); 66 items.push(item);
64 } 67 }
65 if (--numItems === 0) { 68 if (--numItems === 0) {
66 if (items.length === 0) { 69 if (items.length === 0) {
67 dispatch([]); 70 dispatch([]);
68 } else { 71 } else {
69 var data = { id: launchData.id, items: items }; 72 var data = { id: launchData.id, items: items };
70 dispatch([data]); 73 dispatch([data]);
71 } 74 }
72 } 75 }
73 }; 76 };
74 forEach(launchData.items, function(i, item) { 77 forEach(launchData.items, function(i, item) {
75 var fs = GetIsolatedFileSystem(item.fileSystemId); 78 var fs = GetIsolatedFileSystem(item.fileSystemId);
76 fs.root.getFile(item.baseName, {}, function(fileEntry) { 79 fs.root.getFile(item.baseName, {}, function(fileEntry) {
77 itemLoaded(null, { entry: fileEntry, type: item.mimeType }); 80 itemLoaded(null, { entry: fileEntry, type: item.mimeType });
78 }, function(fileError) { 81 }, function(fileError) {
79 itemLoaded(fileError); 82 itemLoaded(fileError);
80 }); 83 });
81 }); 84 });
85 } else if (launchData &&
86 typeof launchData.id !== 'undefined' &&
87 typeof launchData.url !== 'undefined' &&
88 typeof launchData.referringUrl !== 'undefined') {
89 // An onLaunched corresponding to url_handlers in the app's manifest.
90 // Handle explicitly even though handling coincides with the generic case.
91 dispatch([launchData]);
82 } else if (launchData) { 92 } else if (launchData) {
83 dispatch([launchData]); 93 dispatch([launchData]);
84 } else { 94 } else {
85 dispatch([]); 95 dispatch([]);
86 } 96 }
87 }); 97 });
88 98
89 exports.binding = binding.generate(); 99 exports.binding = binding.generate();
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698