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

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: remove favicon Created 3 years, 8 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',
(...skipping 10 matching lines...) Expand all
21 }, 21 },
22 22
23 /** 23 /**
24 * Results of browsing data counters, keyed by the suffix of 24 * Results of browsing data counters, keyed by the suffix of
25 * the corresponding data type deletion preference, as reported 25 * the corresponding data type deletion preference, as reported
26 * by the C++ side. 26 * by the C++ side.
27 * @private {!Object<string>} 27 * @private {!Object<string>}
28 */ 28 */
29 counters_: { 29 counters_: {
30 type: Object, 30 type: Object,
31 value: { 31 // Will be filled as results are reported.
32 // Will be filled as results are reported. 32 value: function() {
33 return {};
33 } 34 }
34 }, 35 },
35 36
36 /** 37 /**
37 * List of options for the dropdown menu. 38 * List of options for the dropdown menu.
38 * @private {!DropdownMenuOptionList} 39 * @private {!DropdownMenuOptionList}
39 */ 40 */
40 clearFromOptions_: { 41 clearFromOptions_: {
41 readOnly: true, 42 readOnly: true,
42 type: Array, 43 type: Array,
(...skipping 10 matching lines...) Expand all
53 clearingInProgress_: { 54 clearingInProgress_: {
54 type: Boolean, 55 type: Boolean,
55 value: false, 56 value: false,
56 }, 57 },
57 58
58 /** @private */ 59 /** @private */
59 showHistoryDeletionDialog_: { 60 showHistoryDeletionDialog_: {
60 type: Boolean, 61 type: Boolean,
61 value: false, 62 value: false,
62 }, 63 },
64
65 /** @private */
66 showImportantSitesDialog_: {
67 type: Boolean,
68 value: false,
69 },
70
71 /** @private {!Array<ImportantSite>} */
72 importantSites_: {
73 type: Array,
74 value: function() {
75 return [];
76 }
77 },
78
79 /** @private */
80 importantSitesFlagEnabled_: {
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()
84 this.$.dialog.showModal(); 106 .then(function() {
85 }.bind(this)); 107 this.$.clearBrowsingDataDialog.showModal();
108 return this.browserProxy_.fetchImportantSites();
109 }.bind(this))
110 .then(this.receiveImportantSites.bind(this));
86 }, 111 },
87 112
88 /** 113 /**
114 * @param {!ImportantSitesResponse} result
115 * @private
116 */
117 receiveImportantSites: function(result) {
118 this.importantSitesFlagEnabled_ = result.flagEnabled;
119 this.set('importantSites_', result.importantSites);
120 },
121
122 /**
89 * Updates the footer to show only those sentences that are relevant to this 123 * Updates the footer to show only those sentences that are relevant to this
90 * user. 124 * user.
91 * @param {boolean} syncing Whether the user is syncing data. 125 * @param {boolean} syncing Whether the user is syncing data.
92 * @param {boolean} otherFormsOfBrowsingHistory Whether the user has other 126 * @param {boolean} otherFormsOfBrowsingHistory Whether the user has other
93 * forms of browsing history in their account. 127 * forms of browsing history in their account.
94 * @private 128 * @private
95 */ 129 */
96 updateFooter_: function(syncing, otherFormsOfBrowsingHistory) { 130 updateFooter_: function(syncing, otherFormsOfBrowsingHistory) {
97 this.$.googleFooter.hidden = !otherFormsOfBrowsingHistory; 131 this.$.googleFooter.hidden = !otherFormsOfBrowsingHistory;
98 this.$.syncedDataSentence.hidden = !syncing; 132 this.$.syncedDataSentence.hidden = !syncing;
99 this.$.dialog.classList.add('fully-rendered'); 133 this.$.clearBrowsingDataDialog.classList.add('fully-rendered');
100 }, 134 },
101 135
102 /** 136 /**
103 * Updates the text of a browsing data counter corresponding to the given 137 * Updates the text of a browsing data counter corresponding to the given
104 * preference. 138 * preference.
105 * @param {string} prefName Browsing data type deletion preference. 139 * @param {string} prefName Browsing data type deletion preference.
106 * @param {string} text The text with which to update the counter 140 * @param {string} text The text with which to update the counter
107 * @private 141 * @private
108 */ 142 */
109 updateCounterText_: function(prefName, text) { 143 updateCounterText_: function(prefName, text) {
110 // Data type deletion preferences are named "browser.clear_data.<datatype>". 144 // Data type deletion preferences are named "browser.clear_data.<datatype>".
111 // Strip the common prefix, i.e. use only "<datatype>". 145 // Strip the common prefix, i.e. use only "<datatype>".
112 var matches = prefName.match(/^browser\.clear_data\.(\w+)$/); 146 var matches = prefName.match(/^browser\.clear_data\.(\w+)$/);
113 this.set('counters_.' + assert(matches[1]), text); 147 this.set('counters_.' + assert(matches[1]), text);
114 }, 148 },
115 149
150 /** @private */
151 shouldShowImportantSites_: function() {
152 if (!this.importantSitesFlagEnabled_)
153 return false;
154 if (!this.$.cookiesCheckbox.checked && !this.$.cacheCheckbox.checked) {
155 return false;
156 }
157 var haveImportantSites = this.importantSites_.length > 0;
158 chrome.send(
159 'metricsHandler:recordBooleanHistogram',
160 ['History.ClearBrowsingData.ImportantDialogShown', haveImportantSites]);
161 return haveImportantSites;
162 },
163
116 /** 164 /**
117 * Handles the tap on the Clear Data button. 165 * Handles the tap on the Clear Data button.
118 * @private 166 * @private
119 */ 167 */
120 onClearBrowsingDataTap_: function() { 168 onClearBrowsingDataTap_: function() {
169 if (this.shouldShowImportantSites_()) {
170 // Closing one dialog closes everything, can this be prevented?
dschuyler 2017/04/27 23:10:25 Please see email with advice from dpapad@.
dullweber 2017/04/28 12:34:03 Thanks for asking him. event.stopPropagation() sol
171 // this.$.clearBrowsingDataDialog.close();
172 this.showImportantSitesDialog_ = true;
173 this.$.importantSitesDialog.showModal();
174 } else {
175 this.clearBrowsingData_()
176 }
177 },
178
179 clearBrowsingData_: function() {
121 this.clearingInProgress_ = true; 180 this.clearingInProgress_ = true;
122 181
123 this.browserProxy_.clearBrowsingData().then( 182 this.browserProxy_.clearBrowsingData(this.importantSites_)
124 /** 183 .then(
125 * @param {boolean} shouldShowNotice Whether we should show the notice 184 /**
126 * about other forms of browsing history before closing the dialog. 185 * @param {boolean} shouldShowNotice Whether we should show the
127 */ 186 * notice about other forms of browsing history before closing the
128 function(shouldShowNotice) { 187 * dialog.
129 this.clearingInProgress_ = false; 188 */
130 this.showHistoryDeletionDialog_ = shouldShowNotice; 189 function(shouldShowNotice) {
190 this.clearingInProgress_ = false;
191 this.showHistoryDeletionDialog_ = shouldShowNotice;
131 192
132 if (!shouldShowNotice) 193 if (!shouldShowNotice) {
133 this.$.dialog.close(); 194 if (this.$.clearBrowsingDataDialog.open)
134 }.bind(this)); 195 this.$.clearBrowsingDataDialog.close();
196 if (this.$.importantSitesDialog.open)
197 this.$.importantSitesDialog.close();
198 }
199 }.bind(this));
135 }, 200 },
136 201
137 /** @private */ 202 /** @private */
138 onCancelTap_: function() { 203 onCancelTap_: function() {
139 this.$.dialog.cancel(); 204 this.$.clearBrowsingDataDialog.cancel();
140 }, 205 },
141 206
142 /** 207 /**
208 * Handles the tap confirm button in important sites.
209 * @private
210 */
211 onImportantSitesConfirmTap_: function() {
212 this.clearBrowsingData_();
213 },
214
215 /** @private */
216 onImportantSitesCancelTap_: function() {
217 this.$.importantSitesDialog.cancel();
218 },
219
220 /**
143 * Handles the closing of the notice about other forms of browsing history. 221 * Handles the closing of the notice about other forms of browsing history.
144 * @private 222 * @private
145 */ 223 */
146 onHistoryDeletionDialogClose_: function() { 224 onHistoryDeletionDialogClose_: function() {
147 this.showHistoryDeletionDialog_ = false; 225 this.showHistoryDeletionDialog_ = false;
148 this.$.dialog.close(); 226 if (this.$.clearBrowsingDataDialog.open)
149 } 227 this.$.clearBrowsingDataDialog.close();
228 if (this.$.importantSitesDialog.open)
229 this.$.importantSitesDialog.close();
230 },
231
150 }); 232 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698