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

Unified Diff: chrome/browser/resources/google_now/utility.js

Issue 145353010: Gate console.log output in Google Now (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: CR Feedback Created 6 years, 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/resources/google_now/common_test_util.js ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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);
});
}
« no previous file with comments | « chrome/browser/resources/google_now/common_test_util.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698