Skip to content

Commit

Permalink
Merge pull request #2002 from brave/enable_crash_report_on_dev_uplift_63
Browse files Browse the repository at this point in the history
Enable crash report on dev/nightly channel by default (uplift to 0.63.x)
  • Loading branch information
bsclifton authored Mar 19, 2019
2 parents 97eeb4c + 8c340ed commit 175a27a
Show file tree
Hide file tree
Showing 6 changed files with 82 additions and 0 deletions.
2 changes: 2 additions & 0 deletions browser/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ source_set("browser_process") {
"mac/sparkle_glue.mm",
"mac/sparkle_glue.h",
"mac/su_updater.h",
"metrics/metrics_reporting_util.cc",
"metrics/metrics_reporting_util.h",
"search_engines/guest_window_search_engine_provider_service.cc",
"search_engines/guest_window_search_engine_provider_service.h",
"search_engines/private_window_search_engine_provider_service.cc",
Expand Down
6 changes: 6 additions & 0 deletions browser/brave_local_state_prefs.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@

#include "base/values.h"
#include "brave/browser/brave_stats_updater.h"
#include "brave/browser/metrics/metrics_reporting_util.h"
#include "brave/browser/tor/tor_profile_service.h"
#include "brave/components/brave_referrals/browser/brave_referrals_service.h"
#include "chrome/browser/first_run/first_run.h"
#include "chrome/common/pref_names.h"
#include "components/metrics/metrics_pref_names.h"
#include "components/prefs/pref_registry_simple.h"

namespace brave {
Expand All @@ -24,6 +26,10 @@ void RegisterLocalStatePrefs(PrefRegistrySimple* registry) {
#endif
tor::TorProfileService::RegisterLocalStatePrefs(registry);
RegisterPrefsForMuonMigration(registry);

registry->SetDefaultPrefValue(
metrics::prefs::kMetricsReportingEnabled,
base::Value(GetDefaultPrefValueForMetricsReporting()));
}

} // namespace brave
26 changes: 26 additions & 0 deletions browser/metrics/metrics_reporting_util.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/* Copyright (c) 2019 The Brave Authors. All rights reserved.
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */

#include "brave/browser/metrics/metrics_reporting_util.h"

#include "base/logging.h"
#include "chrome/common/channel_info.h"
#include "components/version_info/channel.h"

bool GetDefaultPrefValueForMetricsReporting() {
switch (chrome::GetChannel()) {
case version_info::Channel::STABLE: // fall through
case version_info::Channel::BETA:
return false;
case version_info::Channel::DEV: // fall through
case version_info::Channel::CANARY:
return true;
case version_info::Channel::UNKNOWN:
return false;
default:
NOTREACHED();
return false;
}
}
11 changes: 11 additions & 0 deletions browser/metrics/metrics_reporting_util.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/* Copyright (c) 2019 The Brave Authors. All rights reserved.
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */

#ifndef BRAVE_BROWSER_METRICS_METRICS_REPORTING_UTIL_H_
#define BRAVE_BROWSER_METRICS_METRICS_REPORTING_UTIL_H_

bool GetDefaultPrefValueForMetricsReporting();

#endif // BRAVE_BROWSER_METRICS_METRICS_REPORTING_UTIL_H_
36 changes: 36 additions & 0 deletions browser/metrics/metrics_reporting_util_unittest_linux.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/* Copyright (c) 2019 The Brave Authors. All rights reserved.
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */

#include "brave/browser/metrics/metrics_reporting_util.h"

#include "base/environment.h"
#include "chrome/common/channel_info.h"
#include "components/version_info/channel.h"
#include "testing/gtest/include/gtest/gtest.h"

TEST(MetricsUtilTest, DefaultValueTest) {
#if defined(OFFICIAL_BUILD)
auto env = base::Environment::Create();

env->SetVar("CHROME_VERSION_EXTRA", LINUX_CHANNEL_STABLE);
EXPECT_EQ(version_info::Channel::STABLE, chrome::GetChannel());
EXPECT_FALSE(GetDefaultPrefValueForMetricsReporting());

env->SetVar("CHROME_VERSION_EXTRA", LINUX_CHANNEL_BETA);
EXPECT_EQ(version_info::Channel::BETA, chrome::GetChannel());
EXPECT_FALSE(GetDefaultPrefValueForMetricsReporting());

env->SetVar("CHROME_VERSION_EXTRA", LINUX_CHANNEL_DEV);
EXPECT_EQ(version_info::Channel::DEV, chrome::GetChannel());
EXPECT_TRUE(GetDefaultPrefValueForMetricsReporting());

env->SetVar("CHROME_VERSION_EXTRA", BRAVE_LINUX_CHANNEL_NIGHTLY);
EXPECT_EQ(version_info::Channel::CANARY, chrome::GetChannel());
EXPECT_TRUE(GetDefaultPrefValueForMetricsReporting());
#else // OFFICIAL_BUILD
EXPECT_EQ(version_info::Channel::UNKNOWN, chrome::GetChannel());
EXPECT_FALSE(GetDefaultPrefValueForMetricsReporting());
#endif
}
1 change: 1 addition & 0 deletions test/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ test("brave_unit_tests") {
"//brave/browser/tor/mock_tor_profile_service_impl.h",
"//brave/browser/tor/mock_tor_profile_service_factory.cc",
"//brave/browser/tor/mock_tor_profile_service_factory.h",
"//brave/browser/metrics/metrics_reporting_util_unittest_linux.cc",
"//brave/browser/net/brave_ad_block_tp_network_delegate_helper_unittest.cc",
"//brave/browser/net/brave_common_static_redirect_network_delegate_helper_unittest.cc",
"//brave/browser/net/brave_httpse_network_delegate_helper_unittest.cc",
Expand Down

0 comments on commit 175a27a

Please sign in to comment.