From 8a4577bf5f1bfdf68bce930acd582a9e9dce094f Mon Sep 17 00:00:00 2001 From: Emerick Rogul Date: Thu, 19 Dec 2019 12:18:01 -0500 Subject: [PATCH] Fix missing favicons in auto-contribute table on Android --- browser/ui/BUILD.gn | 24 +++++++++++++++++++ browser/ui/webui/brave_rewards_page_ui.cc | 9 ++++--- .../chrome/browser/ui/webui/favicon_source.cc | 15 ++++++++++++ 3 files changed, 43 insertions(+), 5 deletions(-) create mode 100644 chromium_src/chrome/browser/ui/webui/favicon_source.cc diff --git a/browser/ui/BUILD.gn b/browser/ui/BUILD.gn index 4ec1023ad012..4611fd20a704 100644 --- a/browser/ui/BUILD.gn +++ b/browser/ui/BUILD.gn @@ -8,6 +8,22 @@ import("//build/config/features.gni") import("//components/gcm_driver/config.gni") import("//chrome/common/features.gni") +source_set("favicon_source") { + sources = [ + "//chrome/browser/ui/webui/favicon_source.cc", + "//chrome/browser/ui/webui/favicon_source.h", + ] + + deps = [ + "//components/favicon/core", + "//components/favicon_base", + "//components/history/core/browser", + "//net", + "//ui/native_theme", + "//url", + ] +} + source_set("ui") { sources = [ "webui/basic_ui.cc", @@ -202,6 +218,14 @@ source_set("ui") { "//ui/resources", ] + # This is no longer compiled into Chromium on Android, but we still + # need it + if (is_android) { + deps += [ + ":favicon_source", + ] + } + if (enable_brave_sync) { deps += [ "//brave/components/brave_sync", diff --git a/browser/ui/webui/brave_rewards_page_ui.cc b/browser/ui/webui/brave_rewards_page_ui.cc index aa9a406d7d5e..25338920dbae 100644 --- a/browser/ui/webui/brave_rewards_page_ui.cc +++ b/browser/ui/webui/brave_rewards_page_ui.cc @@ -297,12 +297,11 @@ RewardsDOMHandler::~RewardsDOMHandler() { void RewardsDOMHandler::RegisterMessages() { #if defined(OS_ANDROID) - // TODO(sergz) figure out why we have link error here // Create our favicon data source. - // Profile* profile = Profile::FromWebUI(web_ui()); - // content::URLDataSource::Add(profile, - // std::make_unique(profile, - // chrome::FaviconUrlFormat::kFaviconLegacy)); + Profile* profile = Profile::FromWebUI(web_ui()); + content::URLDataSource::Add( + profile, std::make_unique( + profile, chrome::FaviconUrlFormat::kFaviconLegacy)); #endif web_ui()->RegisterMessageCallback("brave_rewards.createWalletRequested", diff --git a/chromium_src/chrome/browser/ui/webui/favicon_source.cc b/chromium_src/chrome/browser/ui/webui/favicon_source.cc new file mode 100644 index 000000000000..f6d27f73acfb --- /dev/null +++ b/chromium_src/chrome/browser/ui/webui/favicon_source.cc @@ -0,0 +1,15 @@ +// Copyright (c) 2019 The Brave Authors +// 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/. + +#include "build/build_config.h" + +#if defined(OS_ANDROID) +#define IDR_DEFAULT_FAVICON_32 IDR_DEFAULT_FAVICON +#define IDR_DEFAULT_FAVICON_64 IDR_DEFAULT_FAVICON +#define IDR_DEFAULT_FAVICON_DARK_32 IDR_DEFAULT_FAVICON_DARK +#define IDR_DEFAULT_FAVICON_DARK_64 IDR_DEFAULT_FAVICON_DARK +#endif + +#include "../../../../../chrome/browser/ui/webui/favicon_source.cc" // NOLINT