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

Side by Side Diff: components/net_log/resources/net_export.js

Issue 2757473002: Cosmetic changes to chrome://net-export, primarily for desktop mode. (Closed)
Patch Set: address Helen's comments 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
« no previous file with comments | « components/net_log/resources/net_export.html ('k') | 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) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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 * Main entry point called once the page has loaded. 6 * Main entry point called once the page has loaded.
7 */ 7 */
8 function onLoad() { 8 function onLoad() {
9 NetExportView.getInstance(); 9 NetExportView.getInstance();
10 } 10 }
11 11
12 document.addEventListener('DOMContentLoaded', onLoad); 12 document.addEventListener('DOMContentLoaded', onLoad);
13 13
14 /** 14 /**
15 * This class handles the presentation of our profiler view. Used as a 15 * This class handles the presentation of our profiler view. Used as a
16 * singleton. 16 * singleton.
17 */ 17 */
18 var NetExportView = (function() { 18 var NetExportView = (function() {
19 'use strict'; 19 'use strict';
20 20
21 // -------------------------------------------------------------------------- 21 // --------------------------------------------------------------------------
22 22
23 /** 23 /**
24 * @constructor 24 * @constructor
25 */ 25 */
26 function NetExportView() { 26 function NetExportView() {
27 $('export-view-start-data').onclick = this.onStartData_.bind(this); 27 $('export-view-start-data').onclick = this.onStartData_.bind(this);
28 $('export-view-stop-data').onclick = this.onStopData_.bind(this); 28 $('export-view-stop-data').onclick = this.onStopData_.bind(this);
29 $('export-view-send-data').onclick = this.onSendData_.bind(this); 29 if (this.useMobileUI_())
30 $('export-view-mobile-send-data').onclick = this.onSendData_.bind(this);
30 31
31 // Tell NetExportMessageHandler to notify the UI of future state changes 32 // Tell NetExportMessageHandler to notify the UI of future state changes
32 // from this point on (through onExportNetLogInfoChanged()). 33 // from this point on (through onExportNetLogInfoChanged()).
33 chrome.send('enableNotifyUIWithState'); 34 chrome.send('enableNotifyUIWithState');
34 } 35 }
35 36
36 cr.addSingletonGetter(NetExportView); 37 cr.addSingletonGetter(NetExportView);
37 38
38 NetExportView.prototype = { 39 NetExportView.prototype = {
39 /** 40 /**
(...skipping 17 matching lines...) Expand all
57 */ 58 */
58 onSendData_: function() { 59 onSendData_: function() {
59 chrome.send('sendNetLog'); 60 chrome.send('sendNetLog');
60 }, 61 },
61 62
62 /** 63 /**
63 * Updates the UI to reflect the current state. Displays the path name of 64 * Updates the UI to reflect the current state. Displays the path name of
64 * the file where NetLog data is collected. 65 * the file where NetLog data is collected.
65 */ 66 */
66 onExportNetLogInfoChanged: function(exportNetLogInfo) { 67 onExportNetLogInfoChanged: function(exportNetLogInfo) {
67 if (!exportNetLogInfo.useMobileUI) {
68 document.getElementById('export-view-send-data').style.display =
69 "none";
70 document.getElementById('export-view-deletes-log-text').style.display =
71 "none";
72 }
73
74 if (exportNetLogInfo.file) { 68 if (exportNetLogInfo.file) {
75 var message = ''; 69 var message = '';
76 if (exportNetLogInfo.state == 'LOGGING') 70 if (exportNetLogInfo.state == 'LOGGING')
77 message = 'NetLog data is collected in: '; 71 message = 'NetLog data is collected in: ';
78 else if (exportNetLogInfo.logType != 'NONE') 72 else if (exportNetLogInfo.logType != 'NONE')
79 message = 'NetLog data to send is in: '; 73 message = 'NetLog data to send is in: ';
80 $('export-view-file-path-text').textContent = 74 $('export-view-file-path-text').textContent =
81 message + exportNetLogInfo.file; 75 message + exportNetLogInfo.file;
82 } else { 76 } else {
83 $('export-view-file-path-text').textContent = ''; 77 $('export-view-file-path-text').textContent = '';
84 } 78 }
85 79
86 // Disable all controls. Useable controls are enabled below. 80 // Disable all controls. Useable controls are enabled below.
87 var controls = document.querySelectorAll('button, input'); 81 var controls = document.querySelectorAll('button, input');
88 for (var i = 0; i < controls.length; ++i) { 82 for (var i = 0; i < controls.length; ++i) {
89 controls[i].disabled = true; 83 controls[i].disabled = true;
90 } 84 }
91 85
92 $('export-view-deletes-log-text').hidden = true; 86 if (this.useMobileUI_()) {
93 $('export-view-private-data-text').hidden = true; 87 $('export-view-mobile-deletes-log-text').hidden = true;
94 $('export-view-send-old-log-text').hidden = true; 88 $('export-view-mobile-private-data-text').hidden = true;
89 $('export-view-mobile-send-old-log-text').hidden = true;
90 }
91
95 if (exportNetLogInfo.state == 'NOT_LOGGING') { 92 if (exportNetLogInfo.state == 'NOT_LOGGING') {
96 // Allow making a new log. 93 // Allow making a new log.
97 $('export-view-strip-private-data-button').disabled = false; 94 $('export-view-strip-private-data-button').disabled = false;
98 $('export-view-include-private-data-button').disabled = false; 95 $('export-view-include-private-data-button').disabled = false;
99 $('export-view-log-bytes-button').disabled = false; 96 $('export-view-log-bytes-button').disabled = false;
100 $('export-view-start-data').disabled = false; 97 $('export-view-start-data').disabled = false;
101 98
102 // If there's an existing log, allow sending it. 99 // If there's a pre-existing log, allow sending it (this only
103 if (!!exportNetLogInfo.logExists) { 100 // applies to the mobile UI).
104 $('export-view-deletes-log-text').hidden = false; 101 if (this.useMobileUI_() && exportNetLogInfo.logExists) {
105 $('export-view-send-data').disabled = false; 102 $('export-view-mobile-deletes-log-text').hidden = false;
103 $('export-view-mobile-send-data').disabled = false;
106 if (!exportNetLogInfo.logCaptureModeKnown) { 104 if (!exportNetLogInfo.logCaptureModeKnown) {
107 $('export-view-send-old-log-text').hidden = false; 105 $('export-view-mobile-send-old-log-text').hidden = false;
108 } else if (exportNetLogInfo.captureMode != 'STRIP_PRIVATE_DATA') { 106 } else if (exportNetLogInfo.captureMode != 'STRIP_PRIVATE_DATA') {
109 $('export-view-private-data-text').hidden = false; 107 $('export-view-mobile-private-data-text').hidden = false;
110 } 108 }
111 } 109 }
112 } else if (exportNetLogInfo.state == 'LOGGING') { 110 } else if (exportNetLogInfo.state == 'LOGGING') {
113 // Only possible to stop logging. Radio buttons reflects current state. 111 // Only possible to stop logging. Radio buttons reflects current state.
114 document 112 document
115 .querySelector( 113 .querySelector(
116 'input[name="log-mode"][value="' + 114 'input[name="log-mode"][value="' +
117 exportNetLogInfo.captureMode + '"]') 115 exportNetLogInfo.captureMode + '"]')
118 .checked = true; 116 .checked = true;
119 $('export-view-stop-data').disabled = false; 117 $('export-view-stop-data').disabled = false;
120 } else if (exportNetLogInfo.state == 'UNINITIALIZED') { 118 } else if (exportNetLogInfo.state == 'UNINITIALIZED') {
121 $('export-view-file-path-text').textContent = 119 $('export-view-file-path-text').textContent =
122 'Unable to initialize NetLog data file.'; 120 'Unable to initialize NetLog data file.';
123 } 121 }
122 },
123
124 /*
125 * Returns true if the UI is being displayed for mobile, otherwise false
126 * for desktop. This is controlled by the HTML template.
127 */
128 useMobileUI_: function() {
129 return !!document.getElementById('export-view-mobile-send-data');
124 } 130 }
125 }; 131 };
126 132
127 return NetExportView; 133 return NetExportView;
128 })(); 134 })();
OLDNEW
« no previous file with comments | « components/net_log/resources/net_export.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698