Skip to content

Commit

Permalink
Revert "Revert "Use brave download link and Brave brand in brave://fl…
Browse files Browse the repository at this point in the history
…ags for download""

This reverts commit 3e277d1.
  • Loading branch information
simonhong committed May 13, 2020
1 parent aff449c commit a60358f
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 0 deletions.
3 changes: 3 additions & 0 deletions common/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -92,11 +92,14 @@ 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",
]
Expand Down
22 changes: 22 additions & 0 deletions common/brave_content_client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,34 @@

#include "brave/common/brave_content_client.h"

#include <string>

#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"

BraveContentClient::BraveContentClient() {}

BraveContentClient::~BraveContentClient() {}

base::RefCountedMemory* BraveContentClient::GetDataResourceBytes(
int resource_id) {
if (resource_id == IDR_FLAGS_UI_FLAGS_JS) {
auto* chromium_flags_ui_data =
ChromeContentClient::GetDataResourceBytes(resource_id);
auto* brave_flags_ui_data = ChromeContentClient::GetDataResourceBytes(
IDR_FLAGS_UI_BRAVE_FLAGS_OVERRIDES_JS);
std::string new_flags_js(chromium_flags_ui_data->front_as<const char>(),
chromium_flags_ui_data->size());
new_flags_js.append(brave_flags_ui_data->front_as<const char>(),
brave_flags_ui_data->size());
return new base::RefCountedStaticMemory(new_flags_js.c_str(),
new_flags_js.length());
}
return ChromeContentClient::GetDataResourceBytes(resource_id);
}

void BraveContentClient::AddAdditionalSchemes(Schemes* schemes) {
ChromeContentClient::AddAdditionalSchemes(schemes);
schemes->standard_schemes.push_back(content::kBraveUIScheme);
Expand Down
3 changes: 3 additions & 0 deletions common/brave_content_client.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};

Expand Down
15 changes: 15 additions & 0 deletions components/flags_ui/resources/brave_flags_overrides.js
Original file line number Diff line number Diff line change
@@ -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
<a href="https://brave.com/download-beta/">beta channel</a>.
`
$('channel-promo-dev').innerHTML = `
Interested in cool new Brave features? Try our
<a href="https://brave.com/download-beta/">dev channel</a>.
`
});
1 change: 1 addition & 0 deletions components/resources/brave_components_resources.grd
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@
</if>

<part file="speedreader_resources.grdp" />
<part file="brave_flags_ui_resources.grdp" />
</includes>
</release>
</grit>
4 changes: 4 additions & 0 deletions components/resources/brave_flags_ui_resources.grdp
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<grit-part>
<include name="IDR_FLAGS_UI_BRAVE_FLAGS_OVERRIDES_JS" file="../flags_ui/resources/brave_flags_overrides.js" type="BINDATA" compress="gzip" />
</grit-part>

0 comments on commit a60358f

Please sign in to comment.