Commit ade8a5ce authored by Dominique Fauteux-Chapleau's avatar Dominique Fauteux-Chapleau Committed by Commit Bot

Allow --binary-upload-service-url on everything but Stable and Beta

This is to keep this flag consistent with other enterprise flags like
--device-management-url and --realtime-reporting-url (see
crbug.com/1119515).

Bug: 1128520
Change-Id: I36886843cb409e26ce24baa0f29c009e12b43988
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2441375Reviewed-by: default avatarOwen Min <zmin@chromium.org>
Reviewed-by: default avatarDaniel Rubery <drubery@chromium.org>
Commit-Queue: Dominique Fauteux-Chapleau <domfc@chromium.org>
Cr-Commit-Position: refs/heads/master@{#812916}
parent 2e1031ec
...@@ -22,6 +22,7 @@ ...@@ -22,6 +22,7 @@
#include "build/branding_buildflags.h" #include "build/branding_buildflags.h"
#include "chrome/browser/browser_process.h" #include "chrome/browser/browser_process.h"
#include "chrome/browser/enterprise/connectors/connectors_manager.h" #include "chrome/browser/enterprise/connectors/connectors_manager.h"
#include "chrome/browser/policy/chrome_browser_policy_connector.h"
#include "chrome/browser/policy/dm_token_utils.h" #include "chrome/browser/policy/dm_token_utils.h"
#include "chrome/browser/profiles/profile.h" #include "chrome/browser/profiles/profile.h"
#include "chrome/browser/safe_browsing/advanced_protection_status_manager.h" #include "chrome/browser/safe_browsing/advanced_protection_status_manager.h"
...@@ -82,20 +83,24 @@ std::string ResultToString(BinaryUploadService::Result result) { ...@@ -82,20 +83,24 @@ std::string ResultToString(BinaryUploadService::Result result) {
} }
} }
#if !BUILDFLAG(GOOGLE_CHROME_BRANDING)
constexpr char kBinaryUploadServiceUrlFlag[] = "binary-upload-service-url"; constexpr char kBinaryUploadServiceUrlFlag[] = "binary-upload-service-url";
#endif
base::Optional<GURL> GetUrlOverride() { base::Optional<GURL> GetUrlOverride() {
#if !BUILDFLAG(GOOGLE_CHROME_BRANDING) // Ignore this flag on Stable and Beta to avoid abuse.
if (!g_browser_process || !g_browser_process->browser_policy_connector()
->IsCommandLineSwitchSupported()) {
return base::nullopt;
}
base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
if (command_line->HasSwitch(kBinaryUploadServiceUrlFlag)) { if (command_line->HasSwitch(kBinaryUploadServiceUrlFlag)) {
GURL url = GURL url =
GURL(command_line->GetSwitchValueASCII(kBinaryUploadServiceUrlFlag)); GURL(command_line->GetSwitchValueASCII(kBinaryUploadServiceUrlFlag));
if (url.is_valid()) if (url.is_valid())
return url; return url;
else
LOG(ERROR) << "--binary-upload-service-url is set to an invalid URL";
} }
#endif
return base::nullopt; return base::nullopt;
} }
......
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
#include "base/command_line.h" #include "base/command_line.h"
#include "base/time/time.h" #include "base/time/time.h"
#include "build/branding_buildflags.h" #include "build/branding_buildflags.h"
#include "chrome/browser/policy/chrome_browser_policy_connector.h"
#include "chrome/browser/safe_browsing/advanced_protection_status_manager.h" #include "chrome/browser/safe_browsing/advanced_protection_status_manager.h"
#include "chrome/browser/safe_browsing/advanced_protection_status_manager_factory.h" #include "chrome/browser/safe_browsing/advanced_protection_status_manager_factory.h"
#include "chrome/browser/safe_browsing/cloud_content_scanning/binary_fcm_service.h" #include "chrome/browser/safe_browsing/cloud_content_scanning/binary_fcm_service.h"
...@@ -638,22 +639,15 @@ TEST_F(BinaryUploadServiceTest, UrlOverride) { ...@@ -638,22 +639,15 @@ TEST_F(BinaryUploadServiceTest, UrlOverride) {
base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
command_line->AppendSwitchASCII("binary-upload-service-url", command_line->AppendSwitchASCII("binary-upload-service-url",
"https://test.com/scan"); "https://test.com/scan");
policy::ChromeBrowserPolicyConnector::EnableCommandLineSupportForTesting();
// The flag should only work on Chromium builds.
#if BUILDFLAG(GOOGLE_CHROME_BRANDING)
ASSERT_EQ(GURL("https://safebrowsing.google.com/safebrowsing/uploads/"
"scan?device_token=fake_token&connector=OnFileAttached&tag="
"dlp&tag=malware"),
request.GetUrlWithParams());
#else
ASSERT_EQ(GURL("https://test.com/scan?device_token=fake_token&connector=" ASSERT_EQ(GURL("https://test.com/scan?device_token=fake_token&connector="
"OnFileAttached&tag=dlp&tag=malware"), "OnFileAttached&tag=dlp&tag=malware"),
request.GetUrlWithParams()); request.GetUrlWithParams());
#endif
command_line->RemoveSwitch("binary-upload-service-url"); command_line->RemoveSwitch("binary-upload-service-url");
// The flag being empty should not affect the URL at all, on either builds. // The flag being empty should not affect the URL at all.
ASSERT_EQ(GURL("https://safebrowsing.google.com/safebrowsing/uploads/" ASSERT_EQ(GURL("https://safebrowsing.google.com/safebrowsing/uploads/"
"scan?device_token=fake_token&connector=OnFileAttached&tag=" "scan?device_token=fake_token&connector=OnFileAttached&tag="
"dlp&tag=malware"), "dlp&tag=malware"),
......
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