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

Side by Side Diff: chrome/browser/resources/settings/clear_browsing_data_dialog/clear_browsing_data_dialog.js

Issue 2716333002: Implement important sites dialog for desktop. (Closed)
Patch Set: log histogram when important sites is shown Created 3 years, 9 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
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 /** 5 /**
6 * @fileoverview 'settings-clear-browsing-data-dialog' allows the user to delete 6 * @fileoverview 'settings-clear-browsing-data-dialog' allows the user to delete
7 * browsing data that has been cached by Chromium. 7 * browsing data that has been cached by Chromium.
8 */ 8 */
9 Polymer({ 9 Polymer({
10 is: 'settings-clear-browsing-data-dialog', 10 is: 'settings-clear-browsing-data-dialog',
11 11
12 behaviors: [WebUIListenerBehavior], 12 behaviors: [WebUIListenerBehavior],
13 13
14 properties: { 14 properties: {
15 /** 15 /**
16 * Preferences state. 16 * Preferences state.
17 */ 17 */
18 prefs: { 18 prefs: {
19 type: Object, 19 type: Object,
20 notify: true, 20 notify: true,
21 }, 21 },
22 22
23 /** 23 /**
24 * State of this dialog, either "clearBrowsingData" or "importantSites".
25 * @private
26 */
27 dialogState_: {
28 type: String,
29 value: "clearBrowsingData",
30 },
31
32 /**
24 * Results of browsing data counters, keyed by the suffix of 33 * Results of browsing data counters, keyed by the suffix of
25 * the corresponding data type deletion preference, as reported 34 * the corresponding data type deletion preference, as reported
26 * by the C++ side. 35 * by the C++ side.
27 * @private {!Object<string>} 36 * @private {!Object<string>}
28 */ 37 */
29 counters_: { 38 counters_: {
30 type: Object, 39 type: Object,
31 value: { 40 value: {
32 // Will be filled as results are reported. 41 // Will be filled as results are reported.
33 } 42 }
(...skipping 19 matching lines...) Expand all
53 clearingInProgress_: { 62 clearingInProgress_: {
54 type: Boolean, 63 type: Boolean,
55 value: false, 64 value: false,
56 }, 65 },
57 66
58 /** @private */ 67 /** @private */
59 showHistoryDeletionDialog_: { 68 showHistoryDeletionDialog_: {
60 type: Boolean, 69 type: Boolean,
61 value: false, 70 value: false,
62 }, 71 },
72
73 /** @private {!Array<ImportantSite>} */
74 importantSites_: {
75 type: Array,
76 value: [],
77 },
78
79 /** @private */
80 importantSitesDialogDisabled_: {
81 type: Boolean,
82 value: false,
83 },
84
63 }, 85 },
64 86
65 /** @private {settings.ClearBrowsingDataBrowserProxy} */ 87 /** @private {settings.ClearBrowsingDataBrowserProxy} */
66 browserProxy_: null, 88 browserProxy_: null,
67 89
68 /** @override */ 90 /** @override */
69 ready: function() { 91 ready: function() {
70 this.$.clearFrom.menuOptions = this.clearFromOptions_; 92 this.$.clearFrom.menuOptions = this.clearFromOptions_;
71 this.addWebUIListener( 93 this.addWebUIListener(
72 'update-footer', 94 'update-footer',
73 this.updateFooter_.bind(this)); 95 this.updateFooter_.bind(this));
74 this.addWebUIListener( 96 this.addWebUIListener(
75 'update-counter-text', 97 'update-counter-text',
76 this.updateCounterText_.bind(this)); 98 this.updateCounterText_.bind(this));
77 }, 99 },
78 100
79 /** @override */ 101 /** @override */
80 attached: function() { 102 attached: function() {
81 this.browserProxy_ = 103 this.browserProxy_ =
82 settings.ClearBrowsingDataBrowserProxyImpl.getInstance(); 104 settings.ClearBrowsingDataBrowserProxyImpl.getInstance();
83 this.browserProxy_.initialize().then(function() { 105 this.browserProxy_.initialize().then(function() {
84 this.$.dialog.showModal(); 106 this.$.dialog.showModal();
107 this.browserProxy_.fetchImportantSites().then(
108 this.receiveImportantSites.bind(this));
85 }.bind(this)); 109 }.bind(this));
86 }, 110 },
87 111
88 /** 112 /**
113 * @param {!ImportantSitesResponse} result
114 * @private
115 */
116 receiveImportantSites: function(result) {
117 this.importantSitesDialogDisabled_ = result.dialogDisabled;
118 this.set('importantSites_', result.importantSites);
119 },
120
121 /**
89 * Updates the footer to show only those sentences that are relevant to this 122 * Updates the footer to show only those sentences that are relevant to this
90 * user. 123 * user.
91 * @param {boolean} syncing Whether the user is syncing data. 124 * @param {boolean} syncing Whether the user is syncing data.
92 * @param {boolean} otherFormsOfBrowsingHistory Whether the user has other 125 * @param {boolean} otherFormsOfBrowsingHistory Whether the user has other
93 * forms of browsing history in their account. 126 * forms of browsing history in their account.
94 * @private 127 * @private
95 */ 128 */
96 updateFooter_: function(syncing, otherFormsOfBrowsingHistory) { 129 updateFooter_: function(syncing, otherFormsOfBrowsingHistory) {
97 this.$.googleFooter.hidden = !otherFormsOfBrowsingHistory; 130 this.$.googleFooter.hidden = !otherFormsOfBrowsingHistory;
98 this.$.syncedDataSentence.hidden = !syncing; 131 this.$.syncedDataSentence.hidden = !syncing;
99 this.$.dialog.classList.add('fully-rendered'); 132 this.$.dialog.classList.add('fully-rendered');
100 }, 133 },
101 134
102 /** 135 /**
103 * Updates the text of a browsing data counter corresponding to the given 136 * Updates the text of a browsing data counter corresponding to the given
104 * preference. 137 * preference.
105 * @param {string} prefName Browsing data type deletion preference. 138 * @param {string} prefName Browsing data type deletion preference.
106 * @param {string} text The text with which to update the counter 139 * @param {string} text The text with which to update the counter
107 * @private 140 * @private
108 */ 141 */
109 updateCounterText_: function(prefName, text) { 142 updateCounterText_: function(prefName, text) {
110 // Data type deletion preferences are named "browser.clear_data.<datatype>". 143 // Data type deletion preferences are named "browser.clear_data.<datatype>".
111 // Strip the common prefix, i.e. use only "<datatype>". 144 // Strip the common prefix, i.e. use only "<datatype>".
112 var matches = prefName.match(/^browser\.clear_data\.(\w+)$/); 145 var matches = prefName.match(/^browser\.clear_data\.(\w+)$/);
113 this.set('counters_.' + assert(matches[1]), text); 146 this.set('counters_.' + assert(matches[1]), text);
114 }, 147 },
115 148
116 /** 149 /**
150 * @param {string} currentDialogState The current dialog state.
151 * @return {boolean} Whether this is the clear browsing data dialog.
152 * @private
153 */
154 isClearBrowsingDataDialog_: function(currentDialogState) {
155 return currentDialogState == "clearBrowsingData";
156 },
157
158 /**
159 * @param {string} currentDialogState The current dialog state.
160 * @return {boolean} Whether this is the important sites dialog.
161 * @private
162 */
163 isImportantSitesDialog_: function(currentDialogState) {
164 return currentDialogState == "importantSites";
165 },
166
167 /** @private */
168 shouldShowImportantSites_: function() {
169 if (this.isImportantSitesDialog_(this.dialogState_)) return false;
170 if (this.importantSitesDialogDisabled_) return false;
171 if (!this.$.cookiesCheckbox.checked && !this.$.cacheCheckbox.checked) {
172 return false;
173 }
174 var haveImportantSites = this.importantSites_.length > 0;
dmurph 2017/03/13 22:26:38 Can you capture the dialog being disabled here? In
dullweber 2017/03/14 10:32:04 This function will return false in line 170 when t
175 chrome.send('metricsHandler:recordBooleanHistogram',
176 ["History.ClearBrowsingData.ImportantDialogShown", haveImportantSites]);
177 return haveImportantSites;
178 },
179
180 /**
117 * Handles the tap on the Clear Data button. 181 * Handles the tap on the Clear Data button.
118 * @private 182 * @private
119 */ 183 */
120 onClearBrowsingDataTap_: function() { 184 onClearBrowsingDataTap_: function() {
185 if (this.shouldShowImportantSites_()) {
186 this.dialogState_ = "importantSites";
187 return;
188 }
189
121 this.clearingInProgress_ = true; 190 this.clearingInProgress_ = true;
122 191
123 this.browserProxy_.clearBrowsingData().then( 192 var importantSites = this.importantSitesDialogDisabled_
193 ? [] : this.importantSites_;
194
195 this.browserProxy_.clearBrowsingData(importantSites).then(
124 /** 196 /**
125 * @param {boolean} shouldShowNotice Whether we should show the notice 197 * @param {boolean} shouldShowNotice Whether we should show the notice
126 * about other forms of browsing history before closing the dialog. 198 * about other forms of browsing history before closing the dialog.
127 */ 199 */
128 function(shouldShowNotice) { 200 function(shouldShowNotice) {
129 this.clearingInProgress_ = false; 201 this.clearingInProgress_ = false;
130 this.showHistoryDeletionDialog_ = shouldShowNotice; 202 this.showHistoryDeletionDialog_ = shouldShowNotice;
131 203
132 if (!shouldShowNotice) 204 if (!shouldShowNotice)
133 this.$.dialog.close(); 205 this.$.dialog.close();
134 }.bind(this)); 206 }.bind(this));
135 }, 207 },
136 208
137 /** @private */ 209 /** @private */
138 onCancelTap_: function() { 210 onCancelTap_: function() {
139 this.$.dialog.cancel(); 211 this.$.dialog.cancel();
140 }, 212 },
141 213
142 /** 214 /**
143 * Handles the closing of the notice about other forms of browsing history. 215 * Handles the closing of the notice about other forms of browsing history.
144 * @private 216 * @private
145 */ 217 */
146 onHistoryDeletionDialogClose_: function() { 218 onHistoryDeletionDialogClose_: function() {
147 this.showHistoryDeletionDialog_ = false; 219 this.showHistoryDeletionDialog_ = false;
148 this.$.dialog.close(); 220 this.$.dialog.close();
149 } 221 }
150 }); 222 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698