| Index: chrome/browser/resources/google_now/utility.js
|
| diff --git a/chrome/browser/resources/google_now/utility.js b/chrome/browser/resources/google_now/utility.js
|
| index 6674edf7754803d8a231179b383d8360daaed637..afa74775b1bd5a7019e45520408e73ce2403ed56 100644
|
| --- a/chrome/browser/resources/google_now/utility.js
|
| +++ b/chrome/browser/resources/google_now/utility.js
|
| @@ -29,13 +29,21 @@
|
| */
|
| var NOTIFICATION_CARDS_URL = 'https://www.googleapis.com/chromenow/v1';
|
|
|
| -var DEBUG_MODE = localStorage['debug_mode'];
|
| +/**
|
| + * Returns true if debug mode is enabled.
|
| + * localStorage returns items as strings, which means if we store a boolean,
|
| + * it returns a string. Use this function to compare against true.
|
| + * @return {boolean} Whether debug mode is enabled.
|
| + */
|
| +function isInDebugMode() {
|
| + return localStorage.debug_mode === 'true';
|
| +}
|
|
|
| /**
|
| * Initializes for debug or release modes of operation.
|
| */
|
| function initializeDebug() {
|
| - if (DEBUG_MODE) {
|
| + if (isInDebugMode()) {
|
| NOTIFICATION_CARDS_URL =
|
| localStorage['server_url'] || NOTIFICATION_CARDS_URL;
|
| }
|
| @@ -44,6 +52,18 @@ function initializeDebug() {
|
| initializeDebug();
|
|
|
| /**
|
| + * Conditionally allow console.log output based off of the debug mode.
|
| + */
|
| +console.log = function() {
|
| + var originalConsoleLog = console.log;
|
| + return function() {
|
| + if (isInDebugMode()) {
|
| + originalConsoleLog.apply(console, arguments);
|
| + }
|
| + };
|
| +}();
|
| +
|
| +/**
|
| * Location Card Storage.
|
| */
|
| if (localStorage['locationCardsShown'] === undefined)
|
| @@ -171,7 +191,7 @@ function reportError(error) {
|
| chrome.metricsPrivate.getIsCrashReportingEnabled(function(isEnabled) {
|
| if (isEnabled)
|
| sendErrorReport(error);
|
| - if (DEBUG_MODE)
|
| + if (isInDebugMode())
|
| alert(message);
|
| });
|
| }
|
|
|