Commit 584f26aa authored by Elly Fong-Jones's avatar Elly Fong-Jones Committed by Commit Bot

feedback: include cpu_arch key on Mac

This change also adds two unit tests for the feedback log-gathering
code: a cross-platform one that tests the basic mechanics using a
key that is always present, and a Mac one that tests that the
value of cpu_arch is exactly one of the three values approved by
privacy review.

TEST=Manual
  On a Mac, navigate to chrome://system and check for a "cpu_arch" key.

Bug: 1126503
Change-Id: Ibed7da188eff7902038815140375d9990e4211c6
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2419120
Commit-Queue: Elly Fong-Jones <ellyjones@chromium.org>
Reviewed-by: default avatarMiriam Zimmerman <mutexlox@chromium.org>
Cr-Commit-Position: refs/heads/master@{#808532}
parent a1c19026
......@@ -59,6 +59,10 @@
#include "ui/base/win/hidden_window.h"
#endif
#if defined(OS_MAC)
#include "base/mac/mac_util.h"
#endif
namespace system_logs {
namespace {
......@@ -68,9 +72,11 @@ constexpr char kExtensionsListKey[] = "extensions";
constexpr char kPowerApiListKey[] = "chrome.power extensions";
constexpr char kDataReductionProxyKey[] = "data_reduction_proxy";
constexpr char kChromeVersionTag[] = "CHROME VERSION";
#if BUILDFLAG(IS_LACROS)
constexpr char kLacrosChromeVersionPrefix[] = "Lacros ";
#endif
#if defined(OS_CHROMEOS)
constexpr char kArcPolicyComplianceReportKey[] =
"CHROMEOS_ARC_POLICY_COMPLIANCE_REPORT";
......@@ -87,7 +93,8 @@ constexpr char kDemoModeConfigKey[] = "demo_mode_config";
constexpr char kOnboardingTime[] = "ONBOARDING_TIME";
#else
constexpr char kOsVersionTag[] = "OS VERSION";
#endif
#endif // OS_CHROMEOS
#if defined(OS_WIN)
constexpr char kUsbKeyboardDetected[] = "usb_keyboard_detected";
constexpr char kIsEnrolledToDomain[] = "enrolled_to_domain";
......@@ -98,6 +105,10 @@ constexpr char kUpdateHresult[] = "update_hresult";
constexpr char kInstallResultCode[] = "install_result_code";
constexpr char kInstallLocation[] = "install_location";
#endif
#endif // OS_WIN
#if defined(OS_MAC)
constexpr char kCpuArch[] = "cpu_arch";
#endif
#if defined(OS_CHROMEOS)
......@@ -250,6 +261,19 @@ std::string DetermineInstallLocation() {
}
#endif // defined(OS_WIN) && BUILDFLAG(GOOGLE_CHROME_BRANDING)
#if defined(OS_MAC)
std::string MacCpuArchAsString() {
switch (base::mac::GetCPUType()) {
case base::mac::CPUType::kIntel:
return "x86-64";
case base::mac::CPUType::kTranslatedIntel:
return "x86-64/translated";
case base::mac::CPUType::kArm:
return "arm64";
}
}
#endif
} // namespace
ChromeInternalLogSource::ChromeInternalLogSource()
......@@ -298,6 +322,10 @@ void ChromeInternalLogSource::Fetch(SysLogsSourceCallback callback) {
PopulateLastUpdateState(response.get());
#endif
#if defined(OS_MAC)
response->emplace(kCpuArch, MacCpuArchAsString());
#endif
if (ProfileManager::GetLastUsedProfile()->IsChild())
response->emplace("account_type", "child");
......
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/feedback/system_logs/log_sources/chrome_internal_log_source.h"
#include "base/run_loop.h"
#include "base/test/bind_test_util.h"
#include "build/build_config.h"
#include "chrome/common/channel_info.h"
#include "chrome/test/base/browser_with_test_window_test.h"
#include "content/public/test/browser_task_environment.h"
#include "testing/gtest/include/gtest/gtest.h"
#if defined(OS_MAC)
#include "base/mac/mac_util.h"
#endif
namespace system_logs {
namespace {
std::unique_ptr<SystemLogsResponse> GetChromeInternalLogs() {
base::RunLoop run_loop;
ChromeInternalLogSource source;
std::unique_ptr<SystemLogsResponse> response;
source.Fetch(
base::BindLambdaForTesting([&](std::unique_ptr<SystemLogsResponse> r) {
response = std::move(r);
run_loop.Quit();
}));
run_loop.Run();
return response;
}
using ChromeInternalLogSourceTest = BrowserWithTestWindowTest;
TEST_F(ChromeInternalLogSourceTest, VersionTagContainsActualVersion) {
auto response = GetChromeInternalLogs();
EXPECT_PRED_FORMAT2(testing::IsSubstring, chrome::GetVersionString(),
response->at("CHROME VERSION"));
}
#if defined(OS_MAC)
TEST_F(ChromeInternalLogSourceTest, CpuTypePresentAndValid) {
auto response = GetChromeInternalLogs();
auto value = response->at("cpu_arch");
switch (base::mac::GetCPUType()) {
case base::mac::CPUType::kIntel:
EXPECT_EQ(value, "x86-64");
break;
case base::mac::CPUType::kTranslatedIntel:
EXPECT_EQ(value, "x86-64/translated");
break;
case base::mac::CPUType::kArm:
EXPECT_EQ(value, "arm64");
break;
}
}
#endif
} // namespace
} // namespace system_logs
......@@ -4528,6 +4528,7 @@ test("unit_tests") {
# Android uses different way of showing feedback page
"../browser/feedback/show_feedback_page_unittest.cc",
"../browser/feedback/system_logs/log_sources/chrome_internal_log_source_unittest.cc",
"../browser/feedback/system_logs/log_sources/crash_ids_source_unittest.cc",
# NTP is in native code on Android.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment