Commit 0d2eddfc authored by Roger Tawa's avatar Roger Tawa Committed by Commit Bot

Enable reporting api feature by default.

Bug: 1002517
Change-Id: Ie68223675f5802619ae3c317e0e06fbd8bb4ac9e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1796043
Commit-Queue: Roger Tawa <rogerta@chromium.org>
Reviewed-by: default avatarOwen Min <zmin@chromium.org>
Reviewed-by: default avatarDaniel Rubery <drubery@chromium.org>
Cr-Commit-Position: refs/heads/master@{#695362}
parent f277b2b3
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
#include "chrome/browser/chrome_content_browser_client.h" #include "chrome/browser/chrome_content_browser_client.h"
#include "chrome/browser/policy/browser_dm_token_storage.h" #include "chrome/browser/policy/browser_dm_token_storage.h"
#include "chrome/browser/policy/chrome_browser_policy_connector.h" #include "chrome/browser/policy/chrome_browser_policy_connector.h"
#include "chrome/browser/policy/machine_level_user_cloud_policy_controller.h"
#include "chrome/browser/profiles/profile.h" #include "chrome/browser/profiles/profile.h"
#include "chrome/browser/profiles/profile_attributes_entry.h" #include "chrome/browser/profiles/profile_attributes_entry.h"
#include "chrome/browser/profiles/profile_attributes_storage.h" #include "chrome/browser/profiles/profile_attributes_storage.h"
...@@ -31,7 +32,7 @@ ...@@ -31,7 +32,7 @@
namespace extensions { namespace extensions {
const base::Feature SafeBrowsingPrivateEventRouter::kRealtimeReportingFeature{ const base::Feature SafeBrowsingPrivateEventRouter::kRealtimeReportingFeature{
"SafeBrowsingRealtimeReporting", base::FEATURE_DISABLED_BY_DEFAULT}; "SafeBrowsingRealtimeReporting", base::FEATURE_ENABLED_BY_DEFAULT};
// Key names used with when building the dictionary to pass to the real-time // Key names used with when building the dictionary to pass to the real-time
// reporting API. // reporting API.
...@@ -296,6 +297,17 @@ void SafeBrowsingPrivateEventRouter::SetCloudPolicyClientForTesting( ...@@ -296,6 +297,17 @@ void SafeBrowsingPrivateEventRouter::SetCloudPolicyClientForTesting(
} }
void SafeBrowsingPrivateEventRouter::InitRealtimeReportingClient() { void SafeBrowsingPrivateEventRouter::InitRealtimeReportingClient() {
#if !defined(OS_CHROMEOS)
// This method is not compiled on chromeos because
// MachineLevelUserCloudPolicyController does not exist. Also,
// policy::BrowserDMTokenStorage::Get()->RetrieveDMToken() does return a
// valid token either. Once these are fixed the #if !define can be removed.
if (!policy::MachineLevelUserCloudPolicyController::
IsMachineLevelUserCloudPolicyEnabled()) {
return;
}
if (!base::FeatureList::IsEnabled(kRealtimeReportingFeature)) if (!base::FeatureList::IsEnabled(kRealtimeReportingFeature))
return; return;
...@@ -349,6 +361,7 @@ void SafeBrowsingPrivateEventRouter::InitRealtimeReportingClient() { ...@@ -349,6 +361,7 @@ void SafeBrowsingPrivateEventRouter::InitRealtimeReportingClient() {
dm_token, client_id, dm_token, client_id,
/*user_affiliation_ids=*/std::vector<std::string>()); /*user_affiliation_ids=*/std::vector<std::string>());
} }
#endif
} }
void SafeBrowsingPrivateEventRouter::ReportRealtimeEvent(const char* name, void SafeBrowsingPrivateEventRouter::ReportRealtimeEvent(const char* name,
......
...@@ -6,7 +6,6 @@ ...@@ -6,7 +6,6 @@
#include "base/bind.h" #include "base/bind.h"
#include "base/strings/utf_string_conversions.h" #include "base/strings/utf_string_conversions.h"
#include "base/test/mock_callback.h" #include "base/test/mock_callback.h"
#include "base/test/scoped_feature_list.h"
#include "base/values.h" #include "base/values.h"
#include "chrome/browser/extensions/api/safe_browsing_private/safe_browsing_private_event_router_factory.h" #include "chrome/browser/extensions/api/safe_browsing_private/safe_browsing_private_event_router_factory.h"
#include "chrome/common/extensions/api/safe_browsing_private.h" #include "chrome/common/extensions/api/safe_browsing_private.h"
...@@ -114,10 +113,6 @@ class SafeBrowsingPrivateEventRouterTest : public testing::Test { ...@@ -114,10 +113,6 @@ class SafeBrowsingPrivateEventRouterTest : public testing::Test {
SafeBrowsingPrivateEventRouterFactory::GetInstance()->SetTestingFactory( SafeBrowsingPrivateEventRouterFactory::GetInstance()->SetTestingFactory(
profile_, base::BindRepeating(&BuildSafeBrowsingPrivateEventRouter)); profile_, base::BindRepeating(&BuildSafeBrowsingPrivateEventRouter));
// Make sure real-time feature is eanbled so that the tests will run.
scoped_feature_list_.InitAndEnableFeature(
SafeBrowsingPrivateEventRouter::kRealtimeReportingFeature);
// Set a mock cloud policy client in the router. The router will own the // Set a mock cloud policy client in the router. The router will own the
// client, but a pointer to the client is maintained in the test class to // client, but a pointer to the client is maintained in the test class to
// manage expectations. // manage expectations.
...@@ -129,7 +124,6 @@ class SafeBrowsingPrivateEventRouterTest : public testing::Test { ...@@ -129,7 +124,6 @@ class SafeBrowsingPrivateEventRouterTest : public testing::Test {
protected: protected:
content::BrowserTaskEnvironment task_environment_; content::BrowserTaskEnvironment task_environment_;
base::test::ScopedFeatureList scoped_feature_list_;
TestingProfileManager profile_manager_; TestingProfileManager profile_manager_;
TestingProfile* profile_; TestingProfile* profile_;
extensions::TestEventRouter* event_router_ = nullptr; extensions::TestEventRouter* event_router_ = nullptr;
......
...@@ -62,18 +62,6 @@ void RecordEnrollmentResult( ...@@ -62,18 +62,6 @@ void RecordEnrollmentResult(
"Enterprise.MachineLevelUserCloudPolicyEnrollment.Result", result); "Enterprise.MachineLevelUserCloudPolicyEnrollment.Result", result);
} }
// The MachineLevelUserCloudPolicy is only enabled on Chrome by default.
// However, it can be enabled on Chromium by command line switch for test and
// development purpose.
bool IsMachineLevelUserCloudPolicyEnabled() {
#if BUILDFLAG(GOOGLE_CHROME_BRANDING)
return true;
#else
return base::CommandLine::ForCurrentProcess()->HasSwitch(
switches::kEnableMachineLevelUserCloudPolicy);
#endif
}
// Read the kCloudPolicyOverridesPlatformPolicy from platform provider directly // Read the kCloudPolicyOverridesPlatformPolicy from platform provider directly
// because the local_state is not ready when the // because the local_state is not ready when the
// MachineLevelUserCloudPolicyManager is created. // MachineLevelUserCloudPolicyManager is created.
...@@ -98,6 +86,16 @@ const base::FilePath::CharType ...@@ -98,6 +86,16 @@ const base::FilePath::CharType
MachineLevelUserCloudPolicyController::kPolicyDir[] = MachineLevelUserCloudPolicyController::kPolicyDir[] =
FILE_PATH_LITERAL("Policy"); FILE_PATH_LITERAL("Policy");
bool MachineLevelUserCloudPolicyController::
IsMachineLevelUserCloudPolicyEnabled() {
#if BUILDFLAG(GOOGLE_CHROME_BRANDING)
return true;
#else
return base::CommandLine::ForCurrentProcess()->HasSwitch(
switches::kEnableMachineLevelUserCloudPolicy);
#endif
}
MachineLevelUserCloudPolicyController::MachineLevelUserCloudPolicyController() { MachineLevelUserCloudPolicyController::MachineLevelUserCloudPolicyController() {
} }
MachineLevelUserCloudPolicyController:: MachineLevelUserCloudPolicyController::
......
...@@ -66,6 +66,11 @@ class MachineLevelUserCloudPolicyController { ...@@ -66,6 +66,11 @@ class MachineLevelUserCloudPolicyController {
// Directory name under the user-data-dir where the policy data is stored. // Directory name under the user-data-dir where the policy data is stored.
static const base::FilePath::CharType kPolicyDir[]; static const base::FilePath::CharType kPolicyDir[];
// The MachineLevelUserCloudPolicy is only enabled on Chrome by default.
// However, it can be enabled on Chromium by command line switch for test and
// development purpose.
static bool IsMachineLevelUserCloudPolicyEnabled();
MachineLevelUserCloudPolicyController(); MachineLevelUserCloudPolicyController();
virtual ~MachineLevelUserCloudPolicyController(); virtual ~MachineLevelUserCloudPolicyController();
......
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