| 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 449 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 460 * @param {string} jsonString A JSON-encoded string. | 460 * @param {string} jsonString A JSON-encoded string. |
| 461 * @return {Object|undefined} The decoded object, or undefined if the string | 461 * @return {Object|undefined} The decoded object, or undefined if the string |
| 462 * cannot be parsed. | 462 * cannot be parsed. |
| 463 */ | 463 */ |
| 464 base.jsonParseSafe = function(jsonString) { | 464 base.jsonParseSafe = function(jsonString) { |
| 465 try { | 465 try { |
| 466 return /** @type {Object} */ (JSON.parse(jsonString)); | 466 return /** @type {Object} */ (JSON.parse(jsonString)); |
| 467 } catch (err) { | 467 } catch (err) { |
| 468 return undefined; | 468 return undefined; |
| 469 } | 469 } |
| 470 } | 470 }; |
| 471 |
| 472 /** |
| 473 * @return {boolean} whether the calling script is executing in the background |
| 474 * page or not. |
| 475 */ |
| 476 base.isBackgroundPage = function() { |
| 477 return base.isAppsV2() && !Boolean(chrome.app.window.current()); |
| 478 }; |
| OLD | NEW |