Chromium Code Reviews| 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 /** | 5 /** |
| 6 * @fileoverview | 6 * @fileoverview |
| 7 * A module that contains basic utility components and methods for the | 7 * A module that contains basic utility components and methods for the |
| 8 * chromoting project | 8 * chromoting project |
| 9 * | 9 * |
| 10 */ | 10 */ |
| (...skipping 729 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 740 */ | 740 */ |
| 741 base.jsonParseSafe = function(jsonString) { | 741 base.jsonParseSafe = function(jsonString) { |
| 742 try { | 742 try { |
| 743 return /** @type {Object} */ (JSON.parse(jsonString)); | 743 return /** @type {Object} */ (JSON.parse(jsonString)); |
| 744 } catch (err) { | 744 } catch (err) { |
| 745 return undefined; | 745 return undefined; |
| 746 } | 746 } |
| 747 }; | 747 }; |
| 748 | 748 |
| 749 /** | 749 /** |
| 750 * Return the current time as a formatted string suitable for logging. | |
| 751 * | |
| 752 * @return {string} The current time, formatted as the standard ISO string. | |
| 753 * [yyyy-mm-ddDhh:mm:ss.xyz] | |
| 754 */ | |
| 755 base.timestamp = function() { | |
| 756 return '[' + new Date().toISOString() + ']'; | |
|
kelvinp
2015/04/16 18:13:01
Use standard formatting instead of custom formatti
| |
| 757 }; | |
| 758 | |
| 759 /** | |
| 750 * Size the current window to fit its content vertically. | 760 * Size the current window to fit its content vertically. |
| 751 */ | 761 */ |
| 752 base.resizeWindowToContent = function() { | 762 base.resizeWindowToContent = function() { |
| 753 var appWindow = chrome.app.window.current(); | 763 var appWindow = chrome.app.window.current(); |
| 754 var outerBounds = appWindow.outerBounds; | 764 var outerBounds = appWindow.outerBounds; |
| 755 var borderY = outerBounds.height - appWindow.innerBounds.height; | 765 var borderY = outerBounds.height - appWindow.innerBounds.height; |
| 756 appWindow.resizeTo(outerBounds.width, document.body.clientHeight + borderY); | 766 appWindow.resizeTo(outerBounds.width, document.body.clientHeight + borderY); |
| 757 // Sometimes, resizing the window causes its position to be reset to (0, 0), | 767 // Sometimes, resizing the window causes its position to be reset to (0, 0), |
| 758 // so restore it explicitly. | 768 // so restore it explicitly. |
| 759 appWindow.moveTo(outerBounds.left, outerBounds.top); | 769 appWindow.moveTo(outerBounds.left, outerBounds.top); |
| 760 }; | 770 }; |
| OLD | NEW |