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

Side by Side Diff: chrome/browser/resources/extensions/extension_options_overlay.js

Issue 475543003: Display extension options in a WebUI overlay instead of in a new tab (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address comments 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
(Empty)
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
3 // found in the LICENSE file.
4
5 cr.define('extensions', function() {
6 'use strict';
7
8 /**
9 * The ExtensionOptionsOverlay will show an extension's options page using
10 * an <extensionoptions> element.
11 * @constructor
12 */
13 function ExtensionOptionsOverlay() {}
14
15 cr.addSingletonGetter(ExtensionOptionsOverlay);
16
17 ExtensionOptionsOverlay.prototype = {
18 /**
19 * The extension whose options are being displayed
20 * @type {string}
21 * @private
22 */
23 extensionId_: undefined,
24
25 /**
26 * Initialize the page.
27 * @param {function(HTMLDivElement)} showOverlay The function to show or
28 * hide the ExtensionOptionsOverlay; this should take a single parameter
29 * which is either the overlay Div if the overlay should be displayed,
30 * or null if the overlay should be hidden.
31 */
32 initializePage: function(showOverlay) {
33 var overlay = $('overlay');
34 cr.ui.overlay.setupOverlay(overlay);
35 cr.ui.overlay.globalInitialization();
36 overlay.addEventListener('cancelOverlay', this.handleDismiss_.bind(this));
37
38 /**
39 * The element of the full overlay.
40 * @type {HTMLDivElement}
41 * @private
42 */
43 this.overlayDiv_ = $('extension-options-overlay');
44
45 /**
46 * The function to show or hide the ExtensionOptionsOverlay.
47 * @type {function}
48 * @param {boolean} isVisible Whether the overlay should be visible.
49 */
50 this.setVisible = function(isVisible) {
51 showOverlay(isVisible ? this.overlayDiv_ : null);
52 };
53 },
54
55 /**
56 * Handles a click on the close button.
57 * @param {Event} e The click event.
58 * @private
59 */
60 handleDismiss_: function(event) {
61 this.setVisible(false);
62 if (!this.extensionId_)
not at google - send to devlin 2014/08/14 18:19:30 Actually: do you need |extensionId_| at all? It se
ericzeng 2014/08/14 18:41:17 Yeah it doesn't need to be there. I only need it t
63 return;
64 var extensionoptions = document.querySelector('extensionoptions');
65 this.overlayDiv_.removeChild(extensionoptions);
66 this.extensionId_ = undefined;
67 },
68
69 /**
70 * Associate an extension with the overlay and display it.
71 * @param {string} extensionId The id of the extension whose options page
72 * should be displayed in the overlay.
73 * @param {string} extensionName The name of the extension, which is used
74 * as the header of the overlay.
75 */
76 setExtensionAndShowOverlay: function(extensionId, extensionName) {
77 this.extensionId_ = extensionId;
78 var extensionoptions = new ExtensionOptions();
79 extensionoptions.extension = this.extensionId_;
80 extensionoptions.autosize = 'on';
81
82 // TODO(ericzeng): Resize in a non-jarring way.
83 extensionoptions.onsizechanged = function(evt) {
84 this.overlayDiv_.style.width = evt.width;
85 this.overlayDiv_.style.height = evt.height;
86 }.bind(this);
87
88 this.overlayDiv_.appendChild(extensionoptions);
89
90 document.querySelector(
91 '#extension-options-overlay .extension-options-overlay-title')
92 .textContent = extensionName;
93
94 this.setVisible(true);
95 }
96 };
97
98 // Export
99 return {
100 ExtensionOptionsOverlay: ExtensionOptionsOverlay
101 };
102 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698