Commit 9f243b44 authored by Owen Min's avatar Owen Min Committed by Commit Bot

Implement two cloud reporting policies

ReportExtensionsAndPluginsData policy blocks extensions and plugins report.
ReportSafeBrowsingData policy blocks Safe browsing data report.

Bug: 898673
Change-Id: Id2e2446ee342d13c07dcc79f150aa4baaedcb5c8
Reviewed-on: https://chromium-review.googlesource.com/c/1313329Reviewed-by: default avatarJulian Pastarmov <pastarmovj@chromium.org>
Commit-Queue: Owen Min <zmin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#604933}
parent f9cbcfa4
...@@ -189,25 +189,31 @@ GenerateChromeUserProfileReportRequest(const base::Value& profile_report, ...@@ -189,25 +189,31 @@ GenerateChromeUserProfileReportRequest(const base::Value& profile_report,
} }
} }
if (!UpdateJSONEncodedStringEntry(profile_report, kExtensionData, if (prefs->GetBoolean(
request->mutable_extension_data(), LIST) || enterprise_reporting::kReportExtensionsAndPluginsData)) {
!UpdateJSONEncodedStringEntry(profile_report, kPlugins, if (!UpdateJSONEncodedStringEntry(profile_report, kExtensionData,
request->mutable_plugins(), LIST)) { request->mutable_extension_data(),
return nullptr; LIST) ||
} !UpdateJSONEncodedStringEntry(profile_report, kPlugins,
request->mutable_plugins(), LIST)) {
if (const base::Value* count =
profile_report.FindKey(kSafeBrowsingWarnings)) {
if (!count->is_int())
return nullptr; return nullptr;
request->set_safe_browsing_warnings(count->GetInt()); }
} }
if (const base::Value* count = if (prefs->GetBoolean(enterprise_reporting::kReportSafeBrowsingData)) {
profile_report.FindKey(kSafeBrowsingWarningsClickThrough)) { if (const base::Value* count =
if (!count->is_int()) profile_report.FindKey(kSafeBrowsingWarnings)) {
return nullptr; if (!count->is_int())
request->set_safe_browsing_warnings_click_through(count->GetInt()); return nullptr;
request->set_safe_browsing_warnings(count->GetInt());
}
if (const base::Value* count =
profile_report.FindKey(kSafeBrowsingWarningsClickThrough)) {
if (!count->is_int())
return nullptr;
request->set_safe_browsing_warnings_click_through(count->GetInt());
}
} }
return request; return request;
......
...@@ -261,4 +261,49 @@ TEST_F(ChromeDesktopReportRequestGeneratorTest, DontReportUserIDData) { ...@@ -261,4 +261,49 @@ TEST_F(ChromeDesktopReportRequestGeneratorTest, DontReportUserIDData) {
EXPECT_FALSE(profile.has_chrome_signed_in_user()); EXPECT_FALSE(profile.has_chrome_signed_in_user());
} }
TEST_F(ChromeDesktopReportRequestGeneratorTest,
DontReportExtensionsOrPluginsData) {
PrefService* prefs = profile_.GetPrefs();
prefs->SetBoolean(enterprise_reporting::kReportExtensionsAndPluginsData,
false);
std::unique_ptr<base::DictionaryValue> report =
base::DictionaryValue::From(base::JSONReader::Read(R"({"browserReport":
{"chromeUserProfileReport":[
{"extensionData": [{"id":"1"}],
"plugins": [{"id":"2"}]
}]}})"));
ASSERT_TRUE(report);
std::unique_ptr<em::ChromeDesktopReportRequest> request =
GenerateChromeDesktopReportRequest(*report, &profile_);
ASSERT_TRUE(request);
EXPECT_FALSE(request->browser_report()
.chrome_user_profile_reports(0)
.has_extension_data());
EXPECT_FALSE(
request->browser_report().chrome_user_profile_reports(0).has_plugins());
}
TEST_F(ChromeDesktopReportRequestGeneratorTest, DontReportSafeBrowsingData) {
PrefService* prefs = profile_.GetPrefs();
prefs->SetBoolean(enterprise_reporting::kReportSafeBrowsingData, false);
std::unique_ptr<base::DictionaryValue> report =
base::DictionaryValue::From(base::JSONReader::Read(R"({"browserReport":
{"chromeUserProfileReport":[
{"safeBrowsingWarnings" : 1,
"safeBrowsingWarningsClickThrough": 2
}]}})"));
ASSERT_TRUE(report);
std::unique_ptr<em::ChromeDesktopReportRequest> request =
GenerateChromeDesktopReportRequest(*report, &profile_);
ASSERT_TRUE(request);
EXPECT_FALSE(request->browser_report()
.chrome_user_profile_reports(0)
.has_safe_browsing_warnings());
EXPECT_FALSE(request->browser_report()
.chrome_user_profile_reports(0)
.has_safe_browsing_warnings_click_through());
}
} // namespace extensions } // namespace extensions
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