Skip to content

Commit

Permalink
add feature flag controlling Sec-GPC header
Browse files Browse the repository at this point in the history
  • Loading branch information
antonok-edm committed Oct 5, 2020
1 parent ec4ccbb commit 4a655e0
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 1 deletion.
7 changes: 7 additions & 0 deletions app/brave_main_delegate.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,14 @@
#include "brave/app/brave_command_line_helper.h"
#include "brave/browser/brave_content_browser_client.h"
#include "brave/common/brave_switches.h"
#include "brave/common/brave_features.h"
#include "brave/common/resource_bundle_helper.h"
#include "brave/components/brave_ads/browser/buildflags/buildflags.h"
#include "brave/renderer/brave_content_renderer_client.h"
#include "brave/utility/brave_content_utility_client.h"
#include "build/build_config.h"
#include "chrome/browser/ui/ui_features.h"
#include "chrome/common/channel_info.h"
#include "chrome/common/chrome_features.h"
#include "chrome/common/chrome_paths.h"
#include "chrome/common/chrome_paths_internal.h"
Expand All @@ -39,6 +41,7 @@
#include "components/security_state/core/features.h"
#include "components/sync/base/sync_base_switches.h"
#include "components/translate/core/browser/translate_prefs.h"
#include "components/version_info/channel.h"
#include "content/public/common/content_features.h"
#include "content/public/common/content_switches.h"
#include "google_apis/gaia/gaia_switches.h"
Expand Down Expand Up @@ -225,6 +228,10 @@ bool BraveMainDelegate::BasicStartupComplete(int* exit_code) {
enabled_features.insert(features::kDnsOverHttps.name);
}

if (chrome::GetChannel() == version_info::Channel::CANARY) {
enabled_features.insert(features::kGlobalPrivacyControl.name);
}

// Disabled features.
const std::unordered_set<const char*> disabled_features = {
autofill::features::kAutofillEnableAccountWalletStorage.name,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@

#include <memory>

#include "base/feature_list.h"
#include "brave/common/brave_features.h"
#include "brave/common/network_constants.h"
#include "net/base/net_errors.h"
#include "net/http/http_request_headers.h"
Expand All @@ -17,7 +19,9 @@ int OnBeforeStartTransaction_GlobalPrivacyControlWork(
net::HttpRequestHeaders* headers,
const ResponseCallback& next_callback,
std::shared_ptr<BraveRequestInfo> ctx) {
headers->SetHeader(kSecGpcHeader, "1");
if (base::FeatureList::IsEnabled(features::kGlobalPrivacyControl)) {
headers->SetHeader(kSecGpcHeader, "1");
}
return net::OK;
}

Expand Down
2 changes: 2 additions & 0 deletions chromium_src/chrome/browser/flag_descriptions.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ extern const char kBraveNTPBrandedWallpaperDemoName[];
extern const char kBraveNTPBrandedWallpaperDemoDescription[];
extern const char kBraveAdblockCosmeticFilteringName[];
extern const char kBraveAdblockCosmeticFilteringDescription[];
extern const char kGlobalPrivacyControlName[];
extern const char kGlobalPrivacyControlDescription[];
extern const char kBraveSpeedreaderName[];
extern const char kBraveSpeedreaderDescription[];
extern const char kBraveSyncName[];
Expand Down
6 changes: 6 additions & 0 deletions common/brave_features.cc
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,10 @@ const base::Feature kBraveRewards{"BraveRewards",
#endif
#endif // defined(OS_ANDROID)

// Toggles Global Privacy Control, which conveys a user's request to websites
// and services to not sell or share their personal information with third
// parties.
const base::Feature kGlobalPrivacyControl{"GlobalPrivacyControl",
base::FEATURE_DISABLED_BY_DEFAULT};

} // namespace features
2 changes: 2 additions & 0 deletions common/brave_features.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ COMPONENT_EXPORT(CHROME_FEATURES)
extern const base::Feature kBraveRewards;
#endif // defined(OS_ANDROID)

extern const base::Feature kGlobalPrivacyControl;

} // namespace features

#endif // BRAVE_COMMON_BRAVE_FEATURES_H_

0 comments on commit 4a655e0

Please sign in to comment.