cr.define('options', function() {
/** @const */ var OptionsPage = options.OptionsPage;
+ /** @const */ var SettingsBannerBase = options.SettingsBannerBase;
/**
* ResetProfileSettingsBanner class
cr.addSingletonGetter(ResetProfileSettingsBanner);
ResetProfileSettingsBanner.prototype = {
- /**
- * Whether or not the banner has already been dismissed.
- *
- * This is needed because of the surprising ordering of asynchronous
- * JS<->native calls when the settings page is opened with specifying a
- * given sub-page, e.g. chrome://settings/resetProfileSettings.
- *
- * In such a case, ResetProfileSettingsOverlay's didShowPage(), which calls
- * our dismiss() method, would be called before the native Handlers'
- * InitalizePage() methods have an effect in the JS, which includes calling
- * our show() method. This would mean that the banner would be first
- * dismissed, then shown. We want to prevent this.
- *
- * @type {boolean}
- * @private
- */
- hadBeenDismissed_: false,
+ __proto__: SettingsBannerBase.prototype,
/**
* Initializes the banner's event handlers.
*/
initialize: function() {
+ this.showMetricName_ = 'AutomaticReset_WebUIBanner_BannerShown';
+
+ this.dismissNativeCallbackName_ =
+ 'onDismissedResetProfileSettingsBanner';
+
+ this.setVisibilibyDomElement_ = $('reset-profile-settings-banner');
+
$('reset-profile-settings-banner-close').onclick = function(event) {
chrome.send('metricsHandler:recordAction',
['AutomaticReset_WebUIBanner_ManuallyClosed']);
OptionsPage.navigateToPage('resetProfileSettings');
};
},
-
- /**
- * Called by the native code to show the banner if needed.
- * @private
- */
- show_: function() {
- if (!this.hadBeenDismissed_) {
- chrome.send('metricsHandler:recordAction',
- ['AutomaticReset_WebUIBanner_BannerShown']);
- this.setVisibility_(true);
- }
- },
-
- /**
- * Called when the banner should be closed as a result of something taking
- * place on the WebUI page, i.e. when its close button is pressed, or when
- * the confirmation dialog for the profile settings reset feature is opened.
- * @private
- */
- dismiss_: function() {
- chrome.send('onDismissedResetProfileSettingsBanner');
- this.hadBeenDismissed_ = true;
- this.setVisibility_(false);
- },
-
- /**
- * Sets whether or not the reset profile settings banner shall be visible.
- * @param {boolean} show Whether or not to show the banner.
- * @private
- */
- setVisibility_: function(show) {
- $('reset-profile-settings-banner').hidden = !show;
- }
};
// Forward public APIs to private implementations.