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

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: move filter creation back, add notification status 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.$.cookiesCheckbox.checked && !this.$.cacheCheckbox.checked) {
170 return false;
171 }
172 return this.isClearBrowsingDataDialog_(this.dialogState_) &&
173 !this.importantSitesDialogDisabled_ &&
174 this.importantSites_.length;
175 // TODO(dullweber): Log Histogram?
dmurph 2017/03/07 21:20:14 You can log the same histograms as the Java code I
dullweber 2017/03/13 14:53:24 Done.
176 },
177
178 /**
117 * Handles the tap on the Clear Data button. 179 * Handles the tap on the Clear Data button.
118 * @private 180 * @private
119 */ 181 */
120 onClearBrowsingDataTap_: function() { 182 onClearBrowsingDataTap_: function() {
183 if (this.shouldShowImportantSites_()) {
184 this.dialogState_ = "importantSites";
185 return
186 }
187
121 this.clearingInProgress_ = true; 188 this.clearingInProgress_ = true;
122 189
123 this.browserProxy_.clearBrowsingData().then( 190 this.browserProxy_.clearBrowsingData(this.importantSites_).then(
124 /** 191 /**
125 * @param {boolean} shouldShowNotice Whether we should show the notice 192 * @param {boolean} shouldShowNotice Whether we should show the notice
126 * about other forms of browsing history before closing the dialog. 193 * about other forms of browsing history before closing the dialog.
127 */ 194 */
128 function(shouldShowNotice) { 195 function(shouldShowNotice) {
129 this.clearingInProgress_ = false; 196 this.clearingInProgress_ = false;
130 this.showHistoryDeletionDialog_ = shouldShowNotice; 197 this.showHistoryDeletionDialog_ = shouldShowNotice;
131 198
132 if (!shouldShowNotice) 199 if (!shouldShowNotice)
133 this.$.dialog.close(); 200 this.$.dialog.close();
134 }.bind(this)); 201 }.bind(this));
135 }, 202 },
136 203
137 /** @private */ 204 /** @private */
138 onCancelTap_: function() { 205 onCancelTap_: function() {
139 this.$.dialog.cancel(); 206 this.$.dialog.cancel();
140 }, 207 },
141 208
142 /** 209 /**
143 * Handles the closing of the notice about other forms of browsing history. 210 * Handles the closing of the notice about other forms of browsing history.
144 * @private 211 * @private
145 */ 212 */
146 onHistoryDeletionDialogClose_: function() { 213 onHistoryDeletionDialogClose_: function() {
147 this.showHistoryDeletionDialog_ = false; 214 this.showHistoryDeletionDialog_ = false;
148 this.$.dialog.close(); 215 this.$.dialog.close();
149 } 216 }
150 }); 217 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698