| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 var DeviceLogUI = (function() { | 5 var DeviceLogUI = (function() { |
| 6 'use strict'; | 6 'use strict'; |
| 7 | 7 |
| 8 /** | 8 /** |
| 9 * Creates a tag for the log level. | 9 * Creates a tag for the log level. |
| 10 * | 10 * |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 88 container.appendChild(entry); | 88 container.appendChild(entry); |
| 89 } | 89 } |
| 90 }; | 90 }; |
| 91 | 91 |
| 92 /** | 92 /** |
| 93 * Callback function, triggered when the log is received. | 93 * Callback function, triggered when the log is received. |
| 94 * | 94 * |
| 95 * @param {Object} data A JSON structure of event log entries. | 95 * @param {Object} data A JSON structure of event log entries. |
| 96 */ | 96 */ |
| 97 var getLogCallback = function(data) { | 97 var getLogCallback = function(data) { |
| 98 createEventLog(JSON.parse(data)); | 98 try { |
| 99 createEventLog(JSON.parse(data)); |
| 100 } catch(e) { |
| 101 var container = $('log-container'); |
| 102 container.textContent = 'No log entries'; |
| 103 } |
| 99 }; | 104 }; |
| 100 | 105 |
| 101 /** | 106 /** |
| 102 * Requests a log update. | 107 * Requests a log update. |
| 103 */ | 108 */ |
| 104 var requestLog = function() { | 109 var requestLog = function() { |
| 105 chrome.send('DeviceLog.getLog'); | 110 chrome.send('DeviceLog.getLog'); |
| 106 }; | 111 }; |
| 107 | 112 |
| 108 /** | 113 /** |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 140 checkboxes[i].onclick = requestLog; | 145 checkboxes[i].onclick = requestLog; |
| 141 | 146 |
| 142 setRefresh(); | 147 setRefresh(); |
| 143 requestLog(); | 148 requestLog(); |
| 144 }); | 149 }); |
| 145 | 150 |
| 146 return { | 151 return { |
| 147 getLogCallback: getLogCallback | 152 getLogCallback: getLogCallback |
| 148 }; | 153 }; |
| 149 })(); | 154 })(); |
| OLD | NEW |