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

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: Diff from getCurrent CL 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 * Initialize the page.
20 * @param {function(HTMLDivElement)} showOverlay The function to show or
21 * hide the ExtensionOptionsOverlay; this should take a single parameter
22 * which is either the overlay Div if the overlay should be displayed,
23 * or null if the overlay should be hidden.
24 */
25 initializePage: function(showOverlay) {
26 var overlay = $('overlay');
27 cr.ui.overlay.setupOverlay(overlay);
28 cr.ui.overlay.globalInitialization();
29 overlay.addEventListener('cancelOverlay', this.handleDismiss_.bind(this));
30
31 /**
32 * The element of the full overlay.
33 * @type {HTMLDivElement}
34 * @private
35 */
36 this.overlayDiv_ = $('extension-options-overlay');
37
38 /**
39 * The function to show or hide the ExtensionOptionsOverlay.
40 * @type {function}
41 * @param {boolean} isVisible Whether the overlay should be visible.
42 */
43 this.setVisible = function(isVisible) {
44 showOverlay(isVisible ? this.overlayDiv_ : null);
45 };
46 },
47
48 /**
49 * Handles a click on the close button.
50 * @param {Event} e The click event.
51 * @private
52 */
53 handleDismiss_: function(event) {
54 this.setVisible(false);
55 var extensionoptions = document.querySelector('extensionoptions');
56 if (extensionoptions)
57 this.overlayDiv_.removeChild(extensionoptions);
58 },
59
60 /**
61 * Associate an extension with the overlay and display it.
62 * @param {string} extensionId The id of the extension whose options page
63 * should be displayed in the overlay.
64 * @param {string} extensionName The name of the extension, which is used
65 * as the header of the overlay.
66 */
67 setExtensionAndShowOverlay: function(extensionId, extensionName) {
68 var extensionoptions = new ExtensionOptions();
69 extensionoptions.extension = extensionId;
70 extensionoptions.autosize = 'on';
71
72 // TODO(ericzeng): Resize in a non-jarring way.
73 extensionoptions.onsizechanged = function(evt) {
74 this.overlayDiv_.style.width = evt.width;
75 this.overlayDiv_.style.height = evt.height;
76 }.bind(this);
77
78 this.overlayDiv_.appendChild(extensionoptions);
79
80 document.querySelector(
81 '#extension-options-overlay .extension-options-overlay-title')
82 .textContent = extensionName;
83
84 this.setVisible(true);
85 }
86 };
87
88 // Export
89 return {
90 ExtensionOptionsOverlay: ExtensionOptionsOverlay
91 };
92 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698