From 8ae2b7515458cd7bee9a18ba104f5b4f45bcd115 Mon Sep 17 00:00:00 2001 From: hirono Date: Wed, 16 Sep 2015 03:01:34 -0700 Subject: [PATCH] Files.app: Fix analytics for image loader. * Assign specific property ID for image loader extension. * Add CSP entry for analytics server. analytics.js needs to communicate with Analytics server to record tracking data. In chrome app, we need to add both permission and CSP to allow to communicate with external server. BUG=516250 TEST=ran on link, and checked on analytics console. Review URL: https://codereview.chromium.org/1340653005 Cr-Commit-Position: refs/heads/master@{#349089} --- ui/file_manager/file_manager/common/js/metrics.js | 8 ++++++-- ui/file_manager/file_manager/common/js/metrics_unittest.js | 2 +- ui/file_manager/image_loader/manifest.json | 2 +- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/ui/file_manager/file_manager/common/js/metrics.js b/ui/file_manager/file_manager/common/js/metrics.js index f2c6d56534c6..31f7713c206c 100644 --- a/ui/file_manager/file_manager/common/js/metrics.js +++ b/ui/file_manager/file_manager/common/js/metrics.js @@ -14,7 +14,10 @@ var metrics = metrics || metricsBase; * Analytics tracking ID for Files app. * @const {string} */ -metrics.TRACKING_ID = 'UA-38248358-9'; +metrics.TRACKING_IDS = { + hhaomjibdihmijegdhdafkllkbggdgoj: 'UA-38248358-9', // Files.app + pmfjbimdmchhbnneeidfognadeopoehp: 'UA-38248358-13' // Image Loader +}; /** * Convert a short metric name to the full format. @@ -59,7 +62,8 @@ metrics.createTracker_ = function() { // Create a tracker, add a filter that only enables analytics when UMA is // enabled. - metrics.tracker_ = metrics.analytics_.getTracker(metrics.TRACKING_ID); + metrics.tracker_ = metrics.analytics_.getTracker( + metrics.TRACKING_IDS[chrome.runtime.id]); metrics.tracker_.addFilter(metrics.umaEnabledFilter_); }; diff --git a/ui/file_manager/file_manager/common/js/metrics_unittest.js b/ui/file_manager/file_manager/common/js/metrics_unittest.js index 47a0b61c3fad..c664d2168746 100644 --- a/ui/file_manager/file_manager/common/js/metrics_unittest.js +++ b/ui/file_manager/file_manager/common/js/metrics_unittest.js @@ -15,7 +15,7 @@ function setUp() { setupFakeChromeAPIs(); // Set a fake tracking ID so the tests aren't actually sending analytics. - metrics.TRACKING_ID = 'UA-XXXXX-XX'; + metrics.TRACKING_IDS[chrome.runtime.id] = 'UA-XXXXX-XX'; tracker = metrics.getTracker(); // Make a filter that logs the last received hit. diff --git a/ui/file_manager/image_loader/manifest.json b/ui/file_manager/image_loader/manifest.json index 6753c47fc3c2..ab0fd836860a 100644 --- a/ui/file_manager/image_loader/manifest.json +++ b/ui/file_manager/image_loader/manifest.json @@ -17,7 +17,7 @@ "metricsPrivate", "storage" ], - "content_security_policy": "default-src 'none'; script-src 'self' blob: filesystem: chrome://resources chrome-extension://hhaomjibdihmijegdhdafkllkbggdgoj; style-src 'self' blob: filesystem:; frame-src 'self' blob: filesystem:; img-src 'self' blob: filesystem: data:; media-src 'self' blob: filesystem:; connect-src 'self' blob: filesystem: https://www.googledrive.com", + "content_security_policy": "default-src 'none'; script-src 'self' blob: filesystem: chrome://resources chrome-extension://hhaomjibdihmijegdhdafkllkbggdgoj; style-src 'self' blob: filesystem:; frame-src 'self' blob: filesystem:; img-src 'self' blob: filesystem: data:; media-src 'self' blob: filesystem:; connect-src 'self' blob: filesystem: https://www.googledrive.com https://www.google-analytics.com", "background": { "scripts": [ "chrome://resources/js/assert.js", -- 2.11.4.GIT