Chromium Code Reviews| Index: extensions/browser/updater/manifest_fetch_data.cc |
| diff --git a/chrome/browser/extensions/updater/manifest_fetch_data.cc b/extensions/browser/updater/manifest_fetch_data.cc |
| similarity index 67% |
| rename from chrome/browser/extensions/updater/manifest_fetch_data.cc |
| rename to extensions/browser/updater/manifest_fetch_data.cc |
| index 4190cbf2b867c8af7f0ecd5c8b094a31530e0c09..54d3204942c0b22660bc800f73451e90e8ac9160 100644 |
| --- a/chrome/browser/extensions/updater/manifest_fetch_data.cc |
| +++ b/extensions/browser/updater/manifest_fetch_data.cc |
| @@ -2,7 +2,7 @@ |
| // Use of this source code is governed by a BSD-style license that can be |
| // found in the LICENSE file. |
| -#include "chrome/browser/extensions/updater/manifest_fetch_data.h" |
| +#include "extensions/browser/updater/manifest_fetch_data.h" |
| #include <vector> |
| @@ -10,9 +10,8 @@ |
| #include "base/metrics/histogram.h" |
| #include "base/strings/string_number_conversions.h" |
| #include "base/strings/string_util.h" |
| -#include "chrome/browser/google/google_brand.h" |
| -#include "chrome/browser/metrics/chrome_metrics_service_accessor.h" |
| -#include "components/omaha_query_params/omaha_query_params.h" |
| +#include "base/strings/stringprintf.h" |
| +#include "extensions/browser/updater/manifest_fetch_data_delegate.h" |
| #include "net/base/escape.h" |
| namespace { |
| @@ -25,13 +24,13 @@ const int kExtensionsManifestMaxURLSize = 2000; |
| namespace extensions { |
| -ManifestFetchData::ManifestFetchData(const GURL& update_url, int request_id) |
| - : base_url_(update_url), |
| - full_url_(update_url) { |
| - std::string query = full_url_.has_query() ? |
| - full_url_.query() + "&" : std::string(); |
| - query += omaha_query_params::OmahaQueryParams::Get( |
| - omaha_query_params::OmahaQueryParams::CRX); |
| +ManifestFetchData::ManifestFetchData(const GURL& update_url, |
| + int request_id, |
| + ManifestFetchDataDelegate* delegate) |
| + : base_url_(update_url), full_url_(update_url), delegate_(delegate) { |
| + std::string query = |
| + full_url_.has_query() ? full_url_.query() + "&" : std::string(); |
| + query += delegate_->GetBaseQueryParams(); |
| GURL::Replacements replacements; |
| replacements.SetQueryStr(query); |
| full_url_ = full_url_.ReplaceComponents(replacements); |
| @@ -39,7 +38,8 @@ ManifestFetchData::ManifestFetchData(const GURL& update_url, int request_id) |
| request_ids_.insert(request_id); |
| } |
| -ManifestFetchData::~ManifestFetchData() {} |
| +ManifestFetchData::~ManifestFetchData() { |
| +} |
| // The format for request parameters in update checks is: |
| // |
| @@ -49,11 +49,7 @@ ManifestFetchData::~ManifestFetchData() {} |
| // |
| // id=EXTENSION_ID&v=VERSION&uc |
| // |
| -// Additionally, we may include the parameter ping=PING_DATA where PING_DATA |
| -// looks like r=DAYS or a=DAYS for extensions in the Chrome extensions gallery. |
| -// ('r' refers to 'roll call' ie installation, and 'a' refers to 'active'). |
| -// These values will each be present at most once every 24 hours, and indicate |
| -// the number of days since the last time it was present in an update check. |
| +// Additionally, we may include brand code and ping data from the delegate. |
| // |
| // So for two extensions like: |
| // Extension 1- id:aaaa version:1.1 |
| @@ -90,33 +86,14 @@ bool ManifestFetchData::AddExtension(const std::string& id, |
| // Append brand code, rollcall and active ping parameters. |
| if (base_url_.DomainIs("google.com")) { |
| -#if defined(GOOGLE_CHROME_BUILD) |
| - std::string brand; |
| - google_brand::GetBrand(&brand); |
| - if (!brand.empty() && !google_brand::IsOrganic(brand)) |
| - parts.push_back("brand=" + brand); |
| -#endif |
| + std::string brand_code = delegate_->GetBrandCode(); |
| + if (!brand_code.empty()) |
| + parts.push_back(base::StringPrintf("brand=%s", brand_code.c_str())); |
| std::string ping_value; |
| pings_[id] = PingData(0, 0, false); |
| - |
| if (ping_data) { |
| - if (ping_data->rollcall_days == kNeverPinged || |
| - ping_data->rollcall_days > 0) { |
| - ping_value += "r=" + base::IntToString(ping_data->rollcall_days); |
| - if (ChromeMetricsServiceAccessor::IsMetricsReportingEnabled()) { |
| - ping_value += "&e=" + std::string(ping_data->is_enabled ? "1" : "0"); |
| - } |
| - pings_[id].rollcall_days = ping_data->rollcall_days; |
| - pings_[id].is_enabled = ping_data->is_enabled; |
| - } |
| - if (ping_data->active_days == kNeverPinged || |
| - ping_data->active_days > 0) { |
| - if (!ping_value.empty()) |
| - ping_value += "&"; |
| - ping_value += "a=" + base::IntToString(ping_data->active_days); |
| - pings_[id].active_days = ping_data->active_days; |
| - } |
| + ping_value = delegate_->GetPingParamsAndData(id, *ping_data, &pings_[id]); |
|
not at google - send to devlin
2014/08/12 16:33:02
Why did you need to delegate-ify this? What's wron
|
| } |
| if (!ping_value.empty()) |
| parts.push_back("ping=" + net::EscapeQueryParamValue(ping_value, true)); |