diff options
author | asargent <asargent@chromium.org> | 2014-10-23 14:24:38 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2014-10-23 21:24:58 +0000 |
commit | 70b2e0ed6d5399b2f320629946d046a3b185b74f (patch) | |
tree | 64ebea113a5eca54ecc16613af1f84221f50595d /extensions/browser/updater | |
parent | 873246335d057971ef54fc7f45548bffa46b3da1 (diff) | |
download | chromium_src-70b2e0ed6d5399b2f320629946d046a3b185b74f.zip chromium_src-70b2e0ed6d5399b2f320629946d046a3b185b74f.tar.gz chromium_src-70b2e0ed6d5399b2f320629946d046a3b185b74f.tar.bz2 |
Add disable reasons to extension autoupdate checks
When extra ping data is turned on, we currently report both a bit for
indicating the enabled/disabled state of the item. This change adds
the set of disabled reasons, if any, for disabled items.
BUG=412437
Review URL: https://codereview.chromium.org/670273002
Cr-Commit-Position: refs/heads/master@{#300949}
Diffstat (limited to 'extensions/browser/updater')
-rw-r--r-- | extensions/browser/updater/manifest_fetch_data.cc | 25 | ||||
-rw-r--r-- | extensions/browser/updater/manifest_fetch_data.h | 20 |
2 files changed, 35 insertions, 10 deletions
diff --git a/extensions/browser/updater/manifest_fetch_data.cc b/extensions/browser/updater/manifest_fetch_data.cc index 1b813fe..2f73acb 100644 --- a/extensions/browser/updater/manifest_fetch_data.cc +++ b/extensions/browser/updater/manifest_fetch_data.cc @@ -11,17 +11,31 @@ #include "base/strings/string_number_conversions.h" #include "base/strings/string_util.h" #include "base/strings/stringprintf.h" +#include "extensions/common/extension.h" #include "net/base/escape.h" +namespace extensions { + namespace { // Maximum length of an extension manifest update check url, since it is a GET // request. We want to stay under 2K because of proxies, etc. const int kExtensionsManifestMaxURLSize = 2000; -} // namespace +void AddMetricsToPing(std::string* ping_value, + const ManifestFetchData::PingData* ping_data) { + *ping_value += "&e=" + std::string(ping_data->is_enabled ? "1" : "0"); + if (!ping_data->is_enabled) { + // Add a dr=<number> param for each bit set in disable reasons. + for (int enum_value = 1; enum_value < Extension::DISABLE_REASON_LAST; + enum_value <<= 1) { + if (ping_data->disable_reasons & enum_value) + *ping_value += "&dr=" + base::IntToString(enum_value); + } + } +} -namespace extensions { +} // namespace ManifestFetchData::ManifestFetchData(const GURL& update_url, int request_id, @@ -106,14 +120,13 @@ bool ManifestFetchData::AddExtension(const std::string& id, parts.push_back(base::StringPrintf("brand=%s", brand_code_.c_str())); std::string ping_value; - pings_[id] = PingData(0, 0, false); + pings_[id] = PingData(0, 0, false, 0); if (ping_data) { if (ping_data->rollcall_days == kNeverPinged || ping_data->rollcall_days > 0) { ping_value += "r=" + base::IntToString(ping_data->rollcall_days); - if (ping_mode_ == PING_WITH_METRICS) { - ping_value += "&e=" + std::string(ping_data->is_enabled ? "1" : "0"); - } + if (ping_mode_ == PING_WITH_METRICS) + AddMetricsToPing(&ping_value, ping_data); pings_[id].rollcall_days = ping_data->rollcall_days; pings_[id].is_enabled = ping_data->is_enabled; } diff --git a/extensions/browser/updater/manifest_fetch_data.h b/extensions/browser/updater/manifest_fetch_data.h index a9f3355..8f33ab3 100644 --- a/extensions/browser/updater/manifest_fetch_data.h +++ b/extensions/browser/updater/manifest_fetch_data.h @@ -50,12 +50,24 @@ class ManifestFetchData { // server's perspective. int rollcall_days; int active_days; - // Wether the extension is enabled or not. + + // Whether the extension is enabled or not. bool is_enabled; - PingData() : rollcall_days(0), active_days(0), is_enabled(true) {} - PingData(int rollcall, int active, bool enabled) - : rollcall_days(rollcall), active_days(active), is_enabled(enabled) {} + // A bitmask of Extension::DisableReason's, which may contain one or more + // reasons why an extension is disabled. + int disable_reasons; + + PingData() + : rollcall_days(0), + active_days(0), + is_enabled(true), + disable_reasons(0) {} + PingData(int rollcall, int active, bool enabled, int reasons) + : rollcall_days(rollcall), + active_days(active), + is_enabled(enabled), + disable_reasons(reasons) {} }; ManifestFetchData(const GURL& update_url, |