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

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

Issue 21930006: <webview>: Allocate the view instance ID from the WebView shim (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Merge with ToT 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
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 // Shim that simulates a <webview> tag via Mutation Observers. 5 // Shim that simulates a <webview> tag via Mutation Observers.
6 // 6 //
7 // The actual tag is implemented via the browser plugin. The internals of this 7 // The actual tag is implemented via the browser plugin. The internals of this
8 // are hidden via Shadow DOM. 8 // are hidden via Shadow DOM.
9 9
10 var addTagWatcher = require('tagWatcher').addTagWatcher; 10 var addTagWatcher = require('tagWatcher').addTagWatcher;
11 var eventBindings = require('event_bindings'); 11 var eventBindings = require('event_bindings');
12 12
13 /** @type {Array.<string>} */ 13 /** @type {Array.<string>} */
14 var WEB_VIEW_ATTRIBUTES = ['name', 'src', 'partition', 'autosize', 'minheight', 14 var WEB_VIEW_ATTRIBUTES = ['name', 'src', 'partition', 'autosize', 'minheight',
15 'minwidth', 'maxheight', 'maxwidth']; 15 'minwidth', 'maxheight', 'maxwidth'];
16 16
17 var WEB_VIEW_EVENTS = { 17 var WEB_VIEW_EVENTS = {
18 'sizechanged': ['oldHeight', 'oldWidth', 'newHeight', 'newWidth'], 18 'sizechanged': ['oldHeight', 'oldWidth', 'newHeight', 'newWidth'],
19 }; 19 };
20 20
21 var webViewInstanceIdCounter = 0;
22
21 var createEvent = function(name) { 23 var createEvent = function(name) {
22 var eventOpts = {supportsListeners: true, supportsFilters: true}; 24 var eventOpts = {supportsListeners: true, supportsFilters: true};
23 return new eventBindings.Event(name, undefined, eventOpts); 25 return new eventBindings.Event(name, undefined, eventOpts);
24 }; 26 };
25 27
26 var WEB_VIEW_EXT_EVENTS = { 28 var WEB_VIEW_EXT_EVENTS = {
27 'close': { 29 'close': {
28 evt: createEvent('webview.onClose'), 30 evt: createEvent('webview.onClose'),
29 fields: [] 31 fields: []
30 }, 32 },
(...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after
336 this.webviewNode_.setAttribute(mutation.attributeName, newValue); 338 this.webviewNode_.setAttribute(mutation.attributeName, newValue);
337 } 339 }
338 } 340 }
339 }; 341 };
340 342
341 /** 343 /**
342 * @private 344 * @private
343 */ 345 */
344 WebView.prototype.setupWebviewNodeEvents_ = function() { 346 WebView.prototype.setupWebviewNodeEvents_ = function() {
345 var self = this; 347 var self = this;
348 this.viewInstanceId_ = ++webViewInstanceIdCounter;
346 var onInstanceIdAllocated = function(e) { 349 var onInstanceIdAllocated = function(e) {
347 var detail = e.detail ? JSON.parse(e.detail) : {}; 350 var detail = e.detail ? JSON.parse(e.detail) : {};
348 self.instanceId_ = detail.windowId; 351 self.instanceId_ = detail.windowId;
349 var params = { 352 var params = {
350 'api': 'webview' 353 'api': 'webview',
354 'instanceId': self.viewInstanceId_
351 }; 355 };
352 self.browserPluginNode_['-internal-attach'](params); 356 self.browserPluginNode_['-internal-attach'](params);
353 357
354 for (var eventName in WEB_VIEW_EXT_EVENTS) { 358 for (var eventName in WEB_VIEW_EXT_EVENTS) {
355 self.setupExtEvent_(eventName, WEB_VIEW_EXT_EVENTS[eventName]); 359 self.setupExtEvent_(eventName, WEB_VIEW_EXT_EVENTS[eventName]);
356 } 360 }
357 }; 361 };
358 this.browserPluginNode_.addEventListener('-internal-instanceid-allocated', 362 this.browserPluginNode_.addEventListener('-internal-instanceid-allocated',
359 onInstanceIdAllocated); 363 onInstanceIdAllocated);
360 364
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after
637 }); 641 });
638 }; 642 };
639 643
640 /** 644 /**
641 * Implemented when the experimental API is available. 645 * Implemented when the experimental API is available.
642 * @private 646 * @private
643 */ 647 */
644 WebView.prototype.maybeSetupExperimentalAPI_ = function() {}; 648 WebView.prototype.maybeSetupExperimentalAPI_ = function() {};
645 649
646 exports.WebView = WebView; 650 exports.WebView = WebView;
OLDNEW
« no previous file with comments | « chrome/browser/guestview/webview/webview_guest.cc ('k') | chrome/renderer/resources/extensions/web_view_experimental.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698