From 92d58e4fbc3892bdb4720a0d64b4bea6128454d9 Mon Sep 17 00:00:00 2001 From: Francois Marier Date: Wed, 23 Oct 2019 14:26:44 -0700 Subject: [PATCH 1/2] Improve licensing notice (fixes brave/brave-browser#6605) This add a link to the license, build instructions as well as the corresponding source code. --- app/brave_generated_resources.grd | 5 +++ browser/ui/BUILD.gn | 7 ++- .../ui/webui/settings/brave_about_handler.cc | 43 +++++++++++++++++++ .../ui/webui/settings/brave_about_handler.h | 27 ++++++++++++ .../browser/ui/webui/settings/settings_ui.cc | 11 +++++ 5 files changed, 92 insertions(+), 1 deletion(-) create mode 100644 browser/ui/webui/settings/brave_about_handler.cc create mode 100644 browser/ui/webui/settings/brave_about_handler.h create mode 100644 chromium_src/chrome/browser/ui/webui/settings/settings_ui.cc diff --git a/app/brave_generated_resources.grd b/app/brave_generated_resources.grd index acb0ae1230a7..f4028c2b0047 100644 --- a/app/brave_generated_resources.grd +++ b/app/brave_generated_resources.grd @@ -607,6 +607,11 @@ By installing this extension, you are agreeing to the Google Widevine Terms of U Avatar Bonbon Ninja + + + Brave is made available to you under the <a target="_blank" href="$1">Mozilla Public License 2.0</a> (MPL) and includes <a target="_blank" href="$2">open source software</a> under a variety of other licenses. + You can read <a target="_blank" href="$3">instructions on how to download and build for yourself</a> the specific <a target="_blank" href="$4">source code used to create this copy</a>. + diff --git a/browser/ui/BUILD.gn b/browser/ui/BUILD.gn index 7250dad9205a..5ba4eaf0e7c6 100644 --- a/browser/ui/BUILD.gn +++ b/browser/ui/BUILD.gn @@ -63,6 +63,8 @@ source_set("ui") { "webui/brave_settings_ui.h", "webui/navigation_bar_data_provider.cc", "webui/navigation_bar_data_provider.h", + "webui/settings/brave_about_handler.cc", + "webui/settings/brave_about_handler.h", "webui/settings/brave_privacy_handler.cc", "webui/settings/brave_privacy_handler.h", "webui/settings/default_brave_shields_handler.cc", @@ -179,7 +181,10 @@ source_set("ui") { } if (!is_android) { - deps += [ "//brave/app:brave_generated_resources_grit" ] + deps += [ + "//brave/app:brave_generated_resources_grit", + "//brave/browser:version_info", + ] } if (enable_extensions && toolkit_views) { diff --git a/browser/ui/webui/settings/brave_about_handler.cc b/browser/ui/webui/settings/brave_about_handler.cc new file mode 100644 index 000000000000..2d19f815aa38 --- /dev/null +++ b/browser/ui/webui/settings/brave_about_handler.cc @@ -0,0 +1,43 @@ +/* Copyright (c) 2019 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 https://mozilla.org/MPL/2.0/. */ + +#include "brave/browser/ui/webui/settings/brave_about_handler.h" + +#include "base/strings/string16.h" +#include "base/strings/utf_string_conversions.h" +#include "brave/browser/version_info.h" +#include "brave/grit/brave_generated_resources.h" +#include "chrome/browser/ui/webui/settings/about_handler.h" +#include "chrome/common/url_constants.h" +#include "content/public/browser/web_ui_data_source.h" +#include "ui/base/l10n/l10n_util.h" + +namespace { + +const char kBraveBuildInstructionsUrl[] = + "https://github.com/brave/brave-browser/wiki"; +const char kBraveLicenseUrl[] = "https://mozilla.org/MPL/2.0/"; +const char kBraveReleaseTagPrefix[] = + "https://github.com/brave/brave-browser/releases/tag/v"; + +} // namespace + +namespace settings { + +AboutHandler* BraveAboutHandler::Create(content::WebUIDataSource* html_source, + Profile* profile) { + AboutHandler* handler = AboutHandler::Create(html_source, profile); + base::string16 license = l10n_util::GetStringFUTF16( + IDS_BRAVE_VERSION_UI_LICENSE, base::ASCIIToUTF16(kBraveLicenseUrl), + base::ASCIIToUTF16(chrome::kChromeUICreditsURL), + base::ASCIIToUTF16(kBraveBuildInstructionsUrl), + base::ASCIIToUTF16(kBraveReleaseTagPrefix) + + base::UTF8ToUTF16( + version_info::GetBraveVersionWithoutChromiumMajorVersion())); + html_source->AddString("aboutProductLicense", license); + return handler; +} + +} // namespace settings diff --git a/browser/ui/webui/settings/brave_about_handler.h b/browser/ui/webui/settings/brave_about_handler.h new file mode 100644 index 000000000000..80fa45f3206d --- /dev/null +++ b/browser/ui/webui/settings/brave_about_handler.h @@ -0,0 +1,27 @@ +/* Copyright (c) 2019 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 https://mozilla.org/MPL/2.0/. */ + +#ifndef BRAVE_BROWSER_UI_WEBUI_SETTINGS_BRAVE_ABOUT_HANDLER_H_ +#define BRAVE_BROWSER_UI_WEBUI_SETTINGS_BRAVE_ABOUT_HANDLER_H_ + +class Profile; + +namespace content { +class WebUIDataSource; +} + +namespace settings { + +class AboutHandler; + +class BraveAboutHandler { + public: + static AboutHandler* Create(content::WebUIDataSource* html_source, + Profile* profile); +}; + +} // namespace settings + +#endif // BRAVE_BROWSER_UI_WEBUI_SETTINGS_BRAVE_ABOUT_HANDLER_H_ diff --git a/chromium_src/chrome/browser/ui/webui/settings/settings_ui.cc b/chromium_src/chrome/browser/ui/webui/settings/settings_ui.cc new file mode 100644 index 000000000000..bc6ec769e100 --- /dev/null +++ b/chromium_src/chrome/browser/ui/webui/settings/settings_ui.cc @@ -0,0 +1,11 @@ +/* Copyright (c) 2019 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 https://mozilla.org/MPL/2.0/. */ + +#include "brave/browser/ui/webui/settings/brave_about_handler.h" +#include "chrome/browser/ui/webui/settings/about_handler.h" + +#define AboutHandler BraveAboutHandler +#include "../../../../../../../chrome/browser/ui/webui/settings/settings_ui.cc" +#undef AboutHandler From 8873f2ed4f795550854fef418b5a5b837de27f67 Mon Sep 17 00:00:00 2001 From: Francois Marier Date: Wed, 30 Oct 2019 14:54:58 -0700 Subject: [PATCH 2/2] Link to release notes from brave://settings/help (fixes brave/brave-browser#6152) The version number on the about page should be a link to the page for the latest release notes. --- .../resources/settings/brave_settings_overrides.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/browser/resources/settings/brave_settings_overrides.js b/browser/resources/settings/brave_settings_overrides.js index dd7c5042c15e..c55966d300fa 100644 --- a/browser/resources/settings/brave_settings_overrides.js +++ b/browser/resources/settings/brave_settings_overrides.js @@ -356,7 +356,17 @@ BravePatching.RegisterPolymerTemplateModifications({ console.error('[Brave Settings Overrides] Could not find manage payments link') } manageLink.remove() - } + }, + 'settings-about-page': (templateContent) => { + const section = getSectionElement(templateContent, 'about') + if (!section.querySelector('a#release-notes')) { + const version = section.querySelector('#updateStatusMessage ~ .secondary') + if (!version) { + console.error('[Brave Settings Overrides] Could not find version div') + } + version.innerHTML = '' + version.innerHTML + '' + } + }, }) // Icons