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

Side by Side Diff: chrome/browser/resources/options/alert_overlay.js

Issue 6480039: chrome://settings - Provide method for pages to prevent themselves being shown. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: comment update Created 9 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 cr.define('options', function() { 5 cr.define('options', function() {
6 var OptionsPage = options.OptionsPage; 6 var OptionsPage = options.OptionsPage;
7 7
8 /** 8 /**
9 * AlertOverlay class 9 * AlertOverlay class
10 * Encapsulated handling of a generic alert. 10 * Encapsulated handling of a generic alert.
11 * @class 11 * @class
12 */ 12 */
13 function AlertOverlay() { 13 function AlertOverlay() {
14 OptionsPage.call(this, 'alertOverlay', '', 'alertOverlay'); 14 OptionsPage.call(this, 'alertOverlay', '', 'alertOverlay');
15 } 15 }
16 16
17 cr.addSingletonGetter(AlertOverlay); 17 cr.addSingletonGetter(AlertOverlay);
18 18
19 AlertOverlay.prototype = { 19 AlertOverlay.prototype = {
20 // Inherit AlertOverlay from OptionsPage. 20 // Inherit AlertOverlay from OptionsPage.
21 __proto__: OptionsPage.prototype, 21 __proto__: OptionsPage.prototype,
22 22
23 /** 23 /**
24 * Whether the page can be shown. Used to make sure the page is only
25 * shown via AlertOverlay.Show(), and not via the address bar.
26 * @private
27 */
28 canShow_: false,
29
30 /**
24 * Initialize the page. 31 * Initialize the page.
25 */ 32 */
26 initializePage: function() { 33 initializePage: function() {
27 // Call base class implementation to start preference initialization. 34 // Call base class implementation to start preference initialization.
28 OptionsPage.prototype.initializePage.call(this); 35 OptionsPage.prototype.initializePage.call(this);
29 36
30 var self = this; 37 var self = this;
31 $('alertOverlayOk').onclick = function(event) { 38 $('alertOverlayOk').onclick = function(event) {
32 self.handleOK_(); 39 self.handleOK_();
33 }; 40 };
(...skipping 18 matching lines...) Expand all
52 /** 59 /**
53 * Handle the 'cancel' button. Clear the overlay and call the cancel 60 * Handle the 'cancel' button. Clear the overlay and call the cancel
54 * callback if available. 61 * callback if available.
55 * @private 62 * @private
56 */ 63 */
57 handleCancel_: function() { 64 handleCancel_: function() {
58 OptionsPage.closeOverlay(); 65 OptionsPage.closeOverlay();
59 if (this.cancelCallback != undefined) { 66 if (this.cancelCallback != undefined) {
60 this.cancelCallback.call(); 67 this.cancelCallback.call();
61 } 68 }
62 } 69 },
70
71 /**
72 * The page is getting hidden. Don't let it be shown again.
73 */
74 willHidePage: function() {
75 canShow_ = false;
Vitaly Pavlenko 2014/10/01 23:29:53 This should be this.canShow_ = false; right?
Evan Stade 2014/10/13 16:21:55 yes
76 },
77
78 /** @inheritDoc */
79 canShowPage: function() {
80 return this.canShow_;
81 },
63 }; 82 };
64 83
65 /** 84 /**
66 * Show an alert overlay with the given message, button titles, and 85 * Show an alert overlay with the given message, button titles, and
67 * callbacks. 86 * callbacks.
68 * @param {string} title The alert title to display to the user. 87 * @param {string} title The alert title to display to the user.
69 * @param {string} message The alert message to display to the user. 88 * @param {string} message The alert message to display to the user.
70 * @param {string} okTitle The title of the OK button. If undefined or empty, 89 * @param {string} okTitle The title of the OK button. If undefined or empty,
71 * no button is shown. 90 * no button is shown.
72 * @param {string} cancelTitle The title of the cancel button. If undefined or 91 * @param {string} cancelTitle The title of the cancel button. If undefined or
(...skipping 28 matching lines...) Expand all
101 $('alertOverlayOk').style.display = 'none'; 120 $('alertOverlayOk').style.display = 'none';
102 } 121 }
103 122
104 if (cancelTitle != undefined && cancelTitle != '') { 123 if (cancelTitle != undefined && cancelTitle != '') {
105 $('alertOverlayCancel').textContent = cancelTitle; 124 $('alertOverlayCancel').textContent = cancelTitle;
106 $('alertOverlayCancel').style.display = 'inline'; 125 $('alertOverlayCancel').style.display = 'inline';
107 } else { 126 } else {
108 $('alertOverlayCancel').style.display = 'none'; 127 $('alertOverlayCancel').style.display = 'none';
109 } 128 }
110 129
111 AlertOverlay.getInstance().okCallback = okCallback; 130 var alertOverlay = AlertOverlay.getInstance();
112 AlertOverlay.getInstance().cancelCallback = cancelCallback; 131 alertOverlay.okCallback = okCallback;
132 alertOverlay.cancelCallback = cancelCallback;
133 alertOverlay.canShow_ = true;
113 134
135 // Intentionally don't show the URL in the location bar as we don't want
136 // people trying to navigate here by hand.
114 OptionsPage.showPageByName('alertOverlay', false); 137 OptionsPage.showPageByName('alertOverlay', false);
115 } 138 }
116 139
117 // Export 140 // Export
118 return { 141 return {
119 AlertOverlay: AlertOverlay 142 AlertOverlay: AlertOverlay
120 }; 143 };
121 }); 144 });
OLDNEW
« no previous file with comments | « chrome/browser/resources/options/add_startup_page_overlay.js ('k') | chrome/browser/resources/options/browser_options.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698