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

Unified Diff: chrome/browser/resources/options/reset_profile_settings_banner.js

Issue 151003004: Add an automatic settings reset banner. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Gab's nits. Created 6 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/resources/options/reset_profile_settings_banner.js
diff --git a/chrome/browser/resources/options/reset_profile_settings_banner.js b/chrome/browser/resources/options/reset_profile_settings_banner.js
index 4517e9151c7fed0d4ba41775df3337f2c710d506..849d4e8bb3f8d6edede2d02429165b13c5a39b56 100644
--- a/chrome/browser/resources/options/reset_profile_settings_banner.js
+++ b/chrome/browser/resources/options/reset_profile_settings_banner.js
@@ -6,6 +6,7 @@
cr.define('options', function() {
/** @const */ var OptionsPage = options.OptionsPage;
+ /** @const */ var SettingsBannerBase = options.SettingsBannerBase;
/**
* ResetProfileSettingsBanner class
@@ -17,28 +18,19 @@ cr.define('options', function() {
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.setVisibilibyDomElementSelector_ = 'reset-profile-settings-banner';
+
$('reset-profile-settings-banner-close').onclick = function(event) {
chrome.send('metricsHandler:recordAction',
['AutomaticReset_WebUIBanner_ManuallyClosed']);
@@ -50,39 +42,6 @@ cr.define('options', function() {
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.

Powered by Google App Engine
This is Rietveld 408576698