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

Side by Side Diff: chrome/browser/resources/net_internals/export_view.js

Issue 2562633003: Update save file button based on states (Closed)
Patch Set: Created 4 years 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 * This view displays options for exporting the captured data. 6 * This view displays options for exporting the captured data.
7 */ 7 */
8 var ExportView = (function() { 8 var ExportView = (function() {
9 'use strict'; 9 'use strict';
10 10
11 // We inherit from DivView. 11 // We inherit from DivView.
12 var superClass = DivView; 12 var superClass = DivView;
13 13
14 /** 14 /**
15 * @constructor 15 * @constructor
16 */ 16 */
17 function ExportView() { 17 function ExportView() {
18 assertFirstConstructorCall(ExportView); 18 assertFirstConstructorCall(ExportView);
19 19
20 // Call superclass's constructor. 20 // Call superclass's constructor.
21 superClass.call(this, ExportView.MAIN_BOX_ID); 21 superClass.call(this, ExportView.MAIN_BOX_ID);
22 22
23 var privacyStrippingCheckbox = $(ExportView.PRIVACY_STRIPPING_CHECKBOX_ID); 23 var privacyStrippingCheckbox = $(ExportView.PRIVACY_STRIPPING_CHECKBOX_ID);
24 privacyStrippingCheckbox.onclick = 24 privacyStrippingCheckbox.onclick =
25 this.onSetPrivacyStripping_.bind(this, privacyStrippingCheckbox); 25 this.onSetPrivacyStripping_.bind(this, privacyStrippingCheckbox);
26 26
27 this.saveFileButton_ = $(ExportView.SAVE_FILE_BUTTON_ID); 27 this.saveFileButton_ = $(ExportView.SAVE_FILE_BUTTON_ID);
28 this.saveFileButton_.onclick = this.onSaveFile_.bind(this); 28 this.saveFileButton_.onclick = this.onSaveFile_.bind(this);
29 this.saveStatusText_ = $(ExportView.SAVE_STATUS_TEXT_ID); 29 this.saveStatusText_ = $(ExportView.SAVE_STATUS_TEXT_ID);
30 this.isSaving_ = false;
30 31
31 this.userCommentsTextArea_ = $(ExportView.USER_COMMENTS_TEXT_AREA_ID); 32 this.userCommentsTextArea_ = $(ExportView.USER_COMMENTS_TEXT_AREA_ID);
32 this.enableSaveFileButton_(false); 33 this.updateSaveFileButton_();
33 this.userCommentsTextArea_.onkeyup = this.onUserCommentsUpdated_.bind(this); 34 this.userCommentsTextArea_.onkeyup = this.onUserCommentsUpdated_.bind(this);
34 35
35 // Track blob for previous log dump so it can be revoked when a new dump is 36 // Track blob for previous log dump so it can be revoked when a new dump is
36 // saved. 37 // saved.
37 this.lastBlobURL_ = null; 38 this.lastBlobURL_ = null;
38 39
39 // Cached copy of the last loaded log dump, for use when exporting. 40 // Cached copy of the last loaded log dump, for use when exporting.
40 this.loadedLogDump_ = null; 41 this.loadedLogDump_ = null;
41 } 42 }
42 43
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 }, 81 },
81 82
82 /** 83 /**
83 * Sets the save to file status text, displayed below the save to file 84 * Sets the save to file status text, displayed below the save to file
84 * button, to |text|. Also enables or disables the save button based on the 85 * button, to |text|. Also enables or disables the save button based on the
85 * value of |isSaving|, which must be true if the save process is still 86 * value of |isSaving|, which must be true if the save process is still
86 * ongoing, and false when the operation has stopped, regardless of success 87 * ongoing, and false when the operation has stopped, regardless of success
87 * of failure. 88 * of failure.
88 */ 89 */
89 setSaveFileStatus: function(text, isSaving) { 90 setSaveFileStatus: function(text, isSaving) {
90 this.enableSaveFileButton_(!isSaving); 91 this.isSaving_ = isSaving;
92 this.updateSaveFileButton_();
91 this.saveStatusText_.textContent = text; 93 this.saveStatusText_.textContent = text;
92 }, 94 },
93 95
94 enableSaveFileButton_: function(enabled) { 96 updateSaveFileButton_: function() {
95 this.saveFileButton_.disabled = !enabled; 97 this.saveFileButton_.disabled =
98 this.userCommentsTextArea_.value == '' || this.isSaving_;
96 }, 99 },
97 100
98 showPrivacyWarning: function() { 101 showPrivacyWarning: function() {
99 setNodeDisplay($(ExportView.PRIVACY_WARNING_ID), true); 102 setNodeDisplay($(ExportView.PRIVACY_WARNING_ID), true);
100 $(ExportView.PRIVACY_STRIPPING_CHECKBOX_ID).checked = false; 103 $(ExportView.PRIVACY_STRIPPING_CHECKBOX_ID).checked = false;
101 $(ExportView.PRIVACY_STRIPPING_CHECKBOX_ID).disabled = true; 104 $(ExportView.PRIVACY_STRIPPING_CHECKBOX_ID).disabled = true;
102 105
103 // Updating the checkbox doesn't actually disable privacy stripping, since 106 // Updating the checkbox doesn't actually disable privacy stripping, since
104 // the onclick function will not be called. 107 // the onclick function will not be called.
105 this.onSetPrivacyStripping_($(ExportView.PRIVACY_STRIPPING_CHECKBOX_ID)); 108 this.onSetPrivacyStripping_($(ExportView.PRIVACY_STRIPPING_CHECKBOX_ID));
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 */ 156 */
154 setUserComments_: function(userComments) { 157 setUserComments_: function(userComments) {
155 this.userCommentsTextArea_.value = userComments; 158 this.userCommentsTextArea_.value = userComments;
156 this.onUserCommentsUpdated_(); 159 this.onUserCommentsUpdated_();
157 }, 160 },
158 161
159 /** 162 /**
160 * User comments are updated. 163 * User comments are updated.
161 */ 164 */
162 onUserCommentsUpdated_: function() { 165 onUserCommentsUpdated_: function() {
163 this.enableSaveFileButton_(this.userCommentsTextArea_.value != ''); 166 this.updateSaveFileButton_();
164 }, 167 },
165 168
166 /** 169 /**
167 * Creates a blob url and starts downloading it. 170 * Creates a blob url and starts downloading it.
168 */ 171 */
169 onLogDumpCreated_: function(dumpText) { 172 onLogDumpCreated_: function(dumpText) {
170 var textBlob = new Blob([dumpText], {type: 'octet/stream'}); 173 var textBlob = new Blob([dumpText], {type: 'octet/stream'});
171 this.lastBlobURL_ = window.URL.createObjectURL(textBlob); 174 this.lastBlobURL_ = window.URL.createObjectURL(textBlob);
172 175
173 // Update the anchor tag and simulate a click on it to start the 176 // Update the anchor tag and simulate a click on it to start the
174 // download. 177 // download.
175 var downloadAnchor = $(ExportView.DOWNLOAD_ANCHOR_ID); 178 var downloadAnchor = $(ExportView.DOWNLOAD_ANCHOR_ID);
176 downloadAnchor.href = this.lastBlobURL_; 179 downloadAnchor.href = this.lastBlobURL_;
177 downloadAnchor.click(); 180 downloadAnchor.click();
178 181
179 this.setSaveFileStatus('Dump successful', false); 182 this.setSaveFileStatus('Dump successful', false);
180 } 183 }
181 }; 184 };
182 185
183 return ExportView; 186 return ExportView;
184 })(); 187 })();
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698