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

Side by Side Diff: extensions/renderer/resources/guest_view/web_view_events.js

Issue 954543002: <webview>: Fix SrcAttribute and Cleanup (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 10 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
« no previous file with comments | « extensions/renderer/resources/guest_view/web_view_attributes.js ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 // Event management for WebView. 5 // Event management for WebView.
6 6
7 var DeclarativeWebRequestSchema = 7 var DeclarativeWebRequestSchema =
8 requireNative('schema_registry').GetSchema('declarativeWebRequest'); 8 requireNative('schema_registry').GetSchema('declarativeWebRequest');
9 var EventBindings = require('event_bindings'); 9 var EventBindings = require('event_bindings');
10 var IdGenerator = requireNative('id_generator'); 10 var IdGenerator = requireNative('id_generator');
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
175 175
176 DeclarativeWebRequestEvent.prototype = { 176 DeclarativeWebRequestEvent.prototype = {
177 __proto__: EventBindings.Event.prototype 177 __proto__: EventBindings.Event.prototype
178 }; 178 };
179 179
180 // Constructor. 180 // Constructor.
181 function WebViewEvents(webViewImpl, viewInstanceId) { 181 function WebViewEvents(webViewImpl, viewInstanceId) {
182 this.webViewImpl = webViewImpl; 182 this.webViewImpl = webViewImpl;
183 this.viewInstanceId = viewInstanceId; 183 this.viewInstanceId = viewInstanceId;
184 184
185 // on* Event handlers.
186 this.on = {};
187
185 // Set up the events. 188 // Set up the events.
186 this.setupFrameNameChangedEvent(); 189 this.setupFrameNameChangedEvent();
187 this.setupWebRequestEvents(); 190 this.setupWebRequestEvents();
188 this.webViewImpl.setupExperimentalContextMenus(); 191 this.webViewImpl.setupExperimentalContextMenus();
189 var events = this.getEvents(); 192 var events = this.getEvents();
190 for (var eventName in events) { 193 for (var eventName in events) {
191 this.setupEvent(eventName, events[eventName]); 194 this.setupEvent(eventName, events[eventName]);
192 } 195 }
193 } 196 }
194 197
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
283 webViewEvent[field] = e[field]; 286 webViewEvent[field] = e[field];
284 } 287 }
285 }.bind(this)); 288 }.bind(this));
286 if (info.customHandler) { 289 if (info.customHandler) {
287 info.customHandler(this, e, webViewEvent); 290 info.customHandler(this, e, webViewEvent);
288 return; 291 return;
289 } 292 }
290 this.webViewImpl.dispatchEvent(webViewEvent); 293 this.webViewImpl.dispatchEvent(webViewEvent);
291 }.bind(this), {instanceId: this.viewInstanceId}); 294 }.bind(this), {instanceId: this.viewInstanceId});
292 295
293 this.webViewImpl.setupEventProperty(name); 296 this.setupEventProperty(name);
297 };
298
299 WebViewEvents.prototype.setupEventProperty = function(eventName) {
300 var propertyName = 'on' + eventName.toLowerCase();
301 Object.defineProperty(this.webViewImpl.element, propertyName, {
302 get: function() {
303 return this.on[propertyName];
304 }.bind(this),
305 set: function(value) {
306 if (this.on[propertyName]) {
307 this.webViewImpl.element.removeEventListener(
308 eventName, this.on[propertyName]);
309 }
310 this.on[propertyName] = value;
311 if (value)
312 this.webViewImpl.element.addEventListener(eventName, value);
313 }.bind(this),
314 enumerable: true
315 });
294 }; 316 };
295 317
296 WebViewEvents.prototype.handleDialogEvent = function(event, webViewEvent) { 318 WebViewEvents.prototype.handleDialogEvent = function(event, webViewEvent) {
297 new WebViewActionRequests.Dialog(this.webViewImpl, event, webViewEvent); 319 new WebViewActionRequests.Dialog(this.webViewImpl, event, webViewEvent);
298 }; 320 };
299 321
300 WebViewEvents.prototype.handleLoadAbortEvent = function(event, webViewEvent) { 322 WebViewEvents.prototype.handleLoadAbortEvent = function(event, webViewEvent) {
301 var showWarningMessage = function(reason) { 323 var showWarningMessage = function(reason) {
302 var WARNING_MSG_LOAD_ABORTED = '<webview>: ' + 324 var WARNING_MSG_LOAD_ABORTED = '<webview>: ' +
303 'The load has aborted with reason "%1".'; 325 'The load has aborted with reason "%1".';
304 window.console.warn(WARNING_MSG_LOAD_ABORTED.replace('%1', reason)); 326 window.console.warn(WARNING_MSG_LOAD_ABORTED.replace('%1', reason));
305 }; 327 };
306 if (this.webViewImpl.dispatchEvent(webViewEvent)) { 328 if (this.webViewImpl.dispatchEvent(webViewEvent)) {
307 showWarningMessage(event.reason); 329 showWarningMessage(event.reason);
308 } 330 }
309 }; 331 };
310 332
311 WebViewEvents.prototype.handleLoadCommitEvent = function(event, webViewEvent) { 333 WebViewEvents.prototype.handleLoadCommitEvent = function(event, webViewEvent) {
312 this.webViewImpl.onLoadCommit(event.baseUrlForDataUrl, 334 this.webViewImpl.onLoadCommit(event.baseUrlForDataUrl,
313 event.currentEntryIndex, event.entryCount, 335 event.currentEntryIndex,
314 event.processId, event.url, 336 event.entryCount,
315 event.isTopLevel); 337 event.processId,
338 event.url,
339 event.isTopLevel);
316 this.webViewImpl.dispatchEvent(webViewEvent); 340 this.webViewImpl.dispatchEvent(webViewEvent);
317 }; 341 };
318 342
319 WebViewEvents.prototype.handleNewWindowEvent = function(event, webViewEvent) { 343 WebViewEvents.prototype.handleNewWindowEvent = function(event, webViewEvent) {
320 new WebViewActionRequests.NewWindow(this.webViewImpl, event, webViewEvent); 344 new WebViewActionRequests.NewWindow(this.webViewImpl, event, webViewEvent);
321 }; 345 };
322 346
323 WebViewEvents.prototype.handlePermissionEvent = function(event, webViewEvent) { 347 WebViewEvents.prototype.handlePermissionEvent = function(event, webViewEvent) {
324 new WebViewActionRequests.PermissionRequest( 348 new WebViewActionRequests.PermissionRequest(
325 this.webViewImpl, event, webViewEvent); 349 this.webViewImpl, event, webViewEvent);
326 }; 350 };
327 351
328 WebViewEvents.prototype.handleSizeChangedEvent = function( 352 WebViewEvents.prototype.handleSizeChangedEvent = function(
329 event, webViewEvent) { 353 event, webViewEvent) {
330 this.webViewImpl.onSizeChanged(webViewEvent); 354 this.webViewImpl.onSizeChanged(webViewEvent);
331 }; 355 };
332 356
333 exports.WebViewEvents = WebViewEvents; 357 exports.WebViewEvents = WebViewEvents;
334 exports.CreateEvent = CreateEvent; 358 exports.CreateEvent = CreateEvent;
OLDNEW
« no previous file with comments | « extensions/renderer/resources/guest_view/web_view_attributes.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698