OLD | NEW |
(Empty) | |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "base/strings/string_number_conversions.h" |
| 6 #include "chrome/browser/extensions/updater/chrome_manifest_fetch_data_delegate.
h" |
| 7 #include "chrome/browser/google/google_brand.h" |
| 8 #include "chrome/browser/metrics/chrome_metrics_service_accessor.h" |
| 9 #include "components/omaha_query_params/omaha_query_params.h" |
| 10 |
| 11 using extensions::ManifestFetchData; |
| 12 |
| 13 ChromeManifestFetchDataDelegate::ChromeManifestFetchDataDelegate() { |
| 14 } |
| 15 |
| 16 ChromeManifestFetchDataDelegate::~ChromeManifestFetchDataDelegate() { |
| 17 } |
| 18 |
| 19 std::string ChromeManifestFetchDataDelegate::GetBaseQueryParams() { |
| 20 return omaha_query_params::OmahaQueryParams::Get( |
| 21 omaha_query_params::OmahaQueryParams::CRX); |
| 22 } |
| 23 |
| 24 bool ChromeManifestFetchDataDelegate::ShouldAlwaysCheckWebstore() { |
| 25 return ChromeMetricsServiceAccessor::IsMetricsReportingEnabled(); |
| 26 } |
| 27 |
| 28 std::string ChromeManifestFetchDataDelegate::GetBrandCode() { |
| 29 #if defined(GOOGLE_CHROME_BUILD) |
| 30 std::string brand; |
| 31 google_brand::GetBrand(&brand); |
| 32 if (!brand.empty() && !google_brand::IsOrganic(brand)) |
| 33 return brand; |
| 34 #endif |
| 35 return ""; |
| 36 } |
| 37 |
| 38 // Provide ping data with the parameter ping=PING_DATA where PING_DATA |
| 39 // looks like r=DAYS or a=DAYS for extensions in the Chrome extensions gallery. |
| 40 // ('r' refers to 'roll call' ie installation, and 'a' refers to 'active'). |
| 41 // These values will each be present at most once every 24 hours, and indicate |
| 42 // the number of days since the last time it was present in an update check. |
| 43 std::string ChromeManifestFetchDataDelegate::GetPingParamsAndData( |
| 44 const std::string& extension_id, |
| 45 const ManifestFetchData::PingData& old_ping_data, |
| 46 ManifestFetchData::PingData* new_ping_data) { |
| 47 std::string ping_value; |
| 48 if (old_ping_data.rollcall_days == ManifestFetchData::kNeverPinged || |
| 49 old_ping_data.rollcall_days > 0) { |
| 50 ping_value += "r=" + base::IntToString(old_ping_data.rollcall_days); |
| 51 if (ChromeMetricsServiceAccessor::IsMetricsReportingEnabled()) { |
| 52 ping_value += "&e=" + std::string(old_ping_data.is_enabled ? "1" : "0"); |
| 53 } |
| 54 new_ping_data->rollcall_days = old_ping_data.rollcall_days; |
| 55 new_ping_data->is_enabled = old_ping_data.is_enabled; |
| 56 } |
| 57 if (old_ping_data.active_days == ManifestFetchData::kNeverPinged || |
| 58 old_ping_data.active_days > 0) { |
| 59 if (!ping_value.empty()) |
| 60 ping_value += "&"; |
| 61 ping_value += "a=" + base::IntToString(old_ping_data.active_days); |
| 62 new_ping_data->active_days = old_ping_data.active_days; |
| 63 } |
| 64 return ping_value; |
| 65 } |
OLD | NEW |