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

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

Issue 431503002: Implement autosizing for <extensionoptions> (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add tests and ensure that size constraints make sense Created 6 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 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 var EventBindings = require('event_bindings'); 5 var EventBindings = require('event_bindings');
6 6
7 var CreateEvent = function(name) { 7 var CreateEvent = function(name) {
8 var eventOpts = {supportsListeners: true, supportsFilters: true}; 8 var eventOpts = {supportsListeners: true, supportsFilters: true};
9 return new EventBindings.Event(name, undefined, eventOpts); 9 return new EventBindings.Event(name, undefined, eventOpts);
10 }; 10 };
11 11
12 var EXTENSION_OPTIONS_EVENTS = { 12 var EXTENSION_OPTIONS_EVENTS = {
13 'load': { 13 'load': {
14 evt: CreateEvent('extensionOptionsInternal.onLoad'), 14 evt: CreateEvent('extensionOptionsInternal.onLoad'),
15 fields: [] 15 fields: []
16 }, 16 },
17 'sizechanged': {
18 evt: CreateEvent('extensionOptionsInternal.onSizeChanged'),
19 customHandler: function(handler, event, webViewEvent) {
20 handler.handleSizeChangedEvent(event, webViewEvent);
21 },
22 fields:['width', 'height']
23 }
17 } 24 }
18 25
19 /** 26 /**
20 * @constructor 27 * @constructor
21 */ 28 */
22 function ExtensionOptionsEvents(extensionOptionsInternal, viewInstanceId) { 29 function ExtensionOptionsEvents(extensionOptionsInternal, viewInstanceId) {
23 this.extensionOptionsInternal = extensionOptionsInternal; 30 this.extensionOptionsInternal = extensionOptionsInternal;
24 this.viewInstanceId = viewInstanceId; 31 this.viewInstanceId = viewInstanceId;
25 this.setup(); 32 this.setup();
26 } 33 }
(...skipping 20 matching lines...) Expand all
47 if (info.customHandler) { 54 if (info.customHandler) {
48 info.customHandler(self, e, extensionOptionsEvent); 55 info.customHandler(self, e, extensionOptionsEvent);
49 return; 56 return;
50 } 57 }
51 self.extensionOptionsInternal.dispatchEvent(extensionOptionsEvent); 58 self.extensionOptionsInternal.dispatchEvent(extensionOptionsEvent);
52 }, {instanceId: self.viewInstanceId}); 59 }, {instanceId: self.viewInstanceId});
53 60
54 this.extensionOptionsInternal.setupEventProperty(name); 61 this.extensionOptionsInternal.setupEventProperty(name);
55 }; 62 };
56 63
64 ExtensionOptionsEvents.prototype.handleSizeChangedEvent = function(
65 event, extensionOptionsEvent) {
66 this.extensionOptionsInternal.onSizeChanged(extensionOptionsEvent.width,
67 extensionOptionsEvent.height);
68 this.extensionOptionsInternal.dispatchEvent(extensionOptionsEvent);
69 }
70
57 exports.ExtensionOptionsEvents = ExtensionOptionsEvents; 71 exports.ExtensionOptionsEvents = ExtensionOptionsEvents;
58 exports.CreateEvent = CreateEvent; 72 exports.CreateEvent = CreateEvent;
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698