diff --git a/common/BUILD.gn b/common/BUILD.gn index 724893bf0485..3810314432b5 100644 --- a/common/BUILD.gn +++ b/common/BUILD.gn @@ -92,13 +92,17 @@ source_set("common") { } deps = [ + "//base", ":network_constants", ":pref_names", ":shield_exceptions", ":switches", "//brave/chromium_src:common", + "//brave/components/resources", + "//components/resources", "//content/public/common", "//extensions/buildflags", + "//ui/base", ] if (is_mac) { diff --git a/common/brave_content_client.cc b/common/brave_content_client.cc index ddea34c74ee0..74fc87a7893b 100644 --- a/common/brave_content_client.cc +++ b/common/brave_content_client.cc @@ -5,12 +5,34 @@ #include "brave/common/brave_content_client.h" +#include + +#include "base/memory/ref_counted_memory.h" +#include "components/grit/brave_components_resources.h" +#include "components/grit/components_resources.h" #include "content/public/common/url_constants.h" +#include "ui/base/resource/resource_bundle.h" BraveContentClient::BraveContentClient() {} BraveContentClient::~BraveContentClient() {} +base::RefCountedMemory* BraveContentClient::GetDataResourceBytes( + int resource_id) { + if (resource_id == IDR_FLAGS_UI_FLAGS_JS) { + const ui::ResourceBundle& resource_bundle = + ui::ResourceBundle::GetSharedInstance(); + const std::string flags_js = + resource_bundle.LoadDataResourceString(resource_id) + + resource_bundle.LoadDataResourceString( + IDR_FLAGS_UI_BRAVE_FLAGS_OVERRIDES_JS); + base::RefCountedString* bytes = new base::RefCountedString(); + bytes->data().assign(flags_js.data(), flags_js.length()); + return bytes; + } + return ChromeContentClient::GetDataResourceBytes(resource_id); +} + void BraveContentClient::AddAdditionalSchemes(Schemes* schemes) { ChromeContentClient::AddAdditionalSchemes(schemes); schemes->standard_schemes.push_back(content::kBraveUIScheme); diff --git a/common/brave_content_client.h b/common/brave_content_client.h index 3b5c44c9be26..dd8a6282ccf2 100644 --- a/common/brave_content_client.h +++ b/common/brave_content_client.h @@ -13,6 +13,9 @@ class BraveContentClient : public ChromeContentClient { BraveContentClient(); ~BraveContentClient() override; + private: + // ChromeContentClinet overrides: + base::RefCountedMemory* GetDataResourceBytes(int resource_id) override; void AddAdditionalSchemes(Schemes* schemes) override; }; diff --git a/components/flags_ui/resources/brave_flags_overrides.js b/components/flags_ui/resources/brave_flags_overrides.js new file mode 100644 index 000000000000..f3e6c46d6d4a --- /dev/null +++ b/components/flags_ui/resources/brave_flags_overrides.js @@ -0,0 +1,15 @@ +/* Copyright (c) 2020 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/. */ + +document.addEventListener('DOMContentLoaded', function() { + $('channel-promo-beta').innerHTML = ` + Interested in cool new Brave features? Try our + beta channel. + ` + $('channel-promo-dev').innerHTML = ` + Interested in cool new Brave features? Try our + dev channel. + ` +}); diff --git a/components/resources/brave_components_resources.grd b/components/resources/brave_components_resources.grd index db11289b5fa0..64f4bf6f3e21 100644 --- a/components/resources/brave_components_resources.grd +++ b/components/resources/brave_components_resources.grd @@ -62,6 +62,7 @@ + diff --git a/components/resources/brave_flags_ui_resources.grdp b/components/resources/brave_flags_ui_resources.grdp new file mode 100644 index 000000000000..5258d20be499 --- /dev/null +++ b/components/resources/brave_flags_ui_resources.grdp @@ -0,0 +1,4 @@ + + + +