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

Side by Side Diff: chrome/renderer/resources/event_bindings.js

Issue 6749021: Added new fileBrowserPrivate and fileHandler extension APIs (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 8 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) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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 var chrome = chrome || {}; 5 var chrome = chrome || {};
6 (function () { 6 (function () {
7 native function GetChromeHidden(); 7 native function GetChromeHidden();
8 native function AttachEvent(eventName); 8 native function AttachEvent(eventName);
9 native function DetachEvent(eventName); 9 native function DetachEvent(eventName);
10 native function GetExternalFileEntry(fileDefinition);
10 11
11 var chromeHidden = GetChromeHidden(); 12 var chromeHidden = GetChromeHidden();
12 13
13 // Local implementation of JSON.parse & JSON.stringify that protect us 14 // Local implementation of JSON.parse & JSON.stringify that protect us
14 // from being clobbered by an extension. 15 // from being clobbered by an extension.
15 chromeHidden.JSON = new (function() { 16 chromeHidden.JSON = new (function() {
16 var $Object = Object; 17 var $Object = Object;
17 var $Array = Array; 18 var $Array = Array;
18 var $jsonStringify = JSON.stringify; 19 var $jsonStringify = JSON.stringify;
19 var $jsonParse = JSON.parse; 20 var $jsonParse = JSON.parse;
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 82
82 chromeHidden.Event = {}; 83 chromeHidden.Event = {};
83 84
84 // Dispatches a named event with the given JSON array, which is deserialized 85 // Dispatches a named event with the given JSON array, which is deserialized
85 // before dispatch. The JSON array is the list of arguments that will be 86 // before dispatch. The JSON array is the list of arguments that will be
86 // sent with the event callback. 87 // sent with the event callback.
87 chromeHidden.Event.dispatchJSON = function(name, args) { 88 chromeHidden.Event.dispatchJSON = function(name, args) {
88 if (attachedNamedEvents[name]) { 89 if (attachedNamedEvents[name]) {
89 if (args) { 90 if (args) {
90 args = chromeHidden.JSON.parse(args); 91 args = chromeHidden.JSON.parse(args);
92 // TODO(zelidrag|aa): Remove this hack from here once we enable event
93 // JSON payload unpacking on C++ side.
94 if (name == "fileBrowserHandler.onExecute") {
95 if (args.length != 2)
96 return;
97 var fileList = args[1];
98 // The second parameter for this event's payload is file definition
99 // dictionary that we used to reconstruct File API's Entry instance
100 // here.
101 for (var i = 0; i < fileList.length; i++)
102 args[1][i] = GetExternalFileEntry(fileList[i]);
103 }
91 } 104 }
92 return attachedNamedEvents[name].dispatch.apply( 105 return attachedNamedEvents[name].dispatch.apply(
93 attachedNamedEvents[name], args); 106 attachedNamedEvents[name], args);
94 } 107 }
95 }; 108 };
96 109
97 // Dispatches a named event with the given arguments, supplied as an array. 110 // Dispatches a named event with the given arguments, supplied as an array.
98 chromeHidden.Event.dispatch = function(name, args) { 111 chromeHidden.Event.dispatch = function(name, args) {
99 if (attachedNamedEvents[name]) { 112 if (attachedNamedEvents[name]) {
100 attachedNamedEvents[name].dispatch.apply( 113 attachedNamedEvents[name].dispatch.apply(
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
226 var event = allAttachedEvents[i]; 239 var event = allAttachedEvents[i];
227 if (event) 240 if (event)
228 event.detach_(); 241 event.detach_();
229 } 242 }
230 }; 243 };
231 244
232 chromeHidden.dispatchError = function(msg) { 245 chromeHidden.dispatchError = function(msg) {
233 console.error(msg); 246 console.error(msg);
234 }; 247 };
235 })(); 248 })();
OLDNEW
« no previous file with comments | « chrome/renderer/extensions/event_bindings.cc ('k') | chrome/renderer/resources/renderer_extension_bindings.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698