Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use override method for ChromeBrowserMainExtraPartsView #230

Merged
merged 2 commits into from
Jul 25, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 7 additions & 9 deletions browser/ui/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,13 @@ source_set("ui") {
"webui/brave_welcome_ui.h",
]

if (is_linux) {
sources += [
"views/brave_views_delegate_linux.cc",
"views/brave_views_delegate_linux.h",
]
}

if (is_mac && !mac_views_browser) {
sources += [
"cocoa/importer/brave_import_lock_dialog_cocoa.mm",
Expand All @@ -64,13 +71,4 @@ source_set("ui") {
]
deps += [ "//google_update" ]
}

if (is_linux) {
sources += [
"views/brave_browser_main_extra_parts_views_linux.cc",
"views/brave_browser_main_extra_parts_views_linux.h",
"views/brave_views_delegate_linux.cc",
"views/brave_views_delegate_linux.h",
]
}
}
21 changes: 0 additions & 21 deletions browser/ui/views/brave_browser_main_extra_parts_views_linux.cc

This file was deleted.

25 changes: 0 additions & 25 deletions browser/ui/views/brave_browser_main_extra_parts_views_linux.h

This file was deleted.

9 changes: 9 additions & 0 deletions browser/ui/views/brave_views_delegate_linux_browsertest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,14 @@
using BraveViewsDelegateViewLinuxBrowserTest = InProcessBrowserTest;

IN_PROC_BROWSER_TEST_F(BraveViewsDelegateViewLinuxBrowserTest, GetDefaultWindowIconTest) {
// In test, our BraveViewsDelegateLinux isn't set because ChromeViewsDelegate is set
// at the very early state by AccessibilityChecker(subclass of ChromeViewsDelegate)
// in ctor of InProcessBrowserTest. Introduced in v68.
// To have a test, explicitly set views delegate by initializing here.
// This is only effective in release mode because initializing views delegate twice isn't
// allowed by dcheck.
BraveViewsDelegateLinux brave_views_delegate;

auto env = base::Environment::Create();
views::ViewsDelegate* views_delegate = views::ViewsDelegate::GetInstance();
auto& rb = ui::ResourceBundle::GetSharedInstance();
Expand All @@ -32,6 +40,7 @@ IN_PROC_BROWSER_TEST_F(BraveViewsDelegateViewLinuxBrowserTest, GetDefaultWindowI
EXPECT_EQ(rb.GetImageSkiaNamed(IDR_PRODUCT_LOGO_128_NIGHTLY)->bitmap(),
views_delegate->GetDefaultWindowIcon()->bitmap());
#else // OFFICIAL_BUILD
// TODO(simonhong): Enable this test in debug mode.
EXPECT_EQ(rb.GetImageSkiaNamed(IDR_PRODUCT_LOGO_128_DEVELOPMENT)->bitmap(),
views_delegate->GetDefaultWindowIcon()->bitmap());
#endif
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/* 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" // For OS_LINUX

#if defined(OS_LINUX)
#include "brave/browser/ui/views/brave_views_delegate_linux.h"
#undef ChromeViewsDelegate
#define ChromeViewsDelegate BraveViewsDelegateLinux
#endif

#include "../../../../../../chrome/browser/ui/views/chrome_browser_main_extra_parts_views.cc"

27 changes: 2 additions & 25 deletions patches/chrome-browser-chrome_content_browser_client.cc.patch
Original file line number Diff line number Diff line change
@@ -1,19 +1,8 @@
diff --git a/chrome/browser/chrome_content_browser_client.cc b/chrome/browser/chrome_content_browser_client.cc
index ec54b365d46d8b3d095970cded217d090e3757e6..35851877d4b104d251d90b370def8a4b289c8967 100644
index ec54b365d46d8b3d095970cded217d090e3757e6..9c51e74d2fe2add3bbef80f38e8b358d0bba94cd 100644
--- a/chrome/browser/chrome_content_browser_client.cc
+++ b/chrome/browser/chrome_content_browser_client.cc
@@ -465,6 +465,10 @@
#include "chrome/services/file_util/public/mojom/constants.mojom.h"
#endif

+#if defined(BRAVE_CHROMIUM_BUILD) && defined(OS_LINUX)
+#include "brave/browser/ui/views/brave_browser_main_extra_parts_views_linux.h"
+#endif
+
using base::FileDescriptor;
using content::BrowserThread;
using content::BrowserURLHandler;
@@ -804,6 +808,16 @@ void GetGuestViewDefaultContentSettingRules(
@@ -804,6 +804,16 @@ void GetGuestViewDefaultContentSettingRules(
base::Value::FromUniquePtrValue(
content_settings::ContentSettingToValue(CONTENT_SETTING_BLOCK)),
std::string(), incognito));
Expand All @@ -30,15 +19,3 @@ index ec54b365d46d8b3d095970cded217d090e3757e6..35851877d4b104d251d90b370def8a4b
}

AppLoadedInTabSource ClassifyAppLoadedInTabSource(
@@ -1082,7 +1096,11 @@ content::BrowserMainParts* ChromeContentBrowserClient::CreateBrowserMainParts(
// which they are added.
#if defined(TOOLKIT_VIEWS)
#if defined(OS_LINUX) && !defined(OS_CHROMEOS) && !defined(USE_OZONE)
+#if defined(BRAVE_CHROMIUM_BUILD)
+ main_parts->AddParts(new BraveBrowserMainExtraPartsViewsLinux());
+#else
main_parts->AddParts(new ChromeBrowserMainExtraPartsViewsLinux());
+#endif
#else
main_parts->AddParts(new ChromeBrowserMainExtraPartsViews());
#endif
3 changes: 2 additions & 1 deletion test/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -160,8 +160,9 @@ test("brave_browser_tests") {
"//chrome/browser/extensions/updater/extension_cache_fake.cc",
"//chrome/browser/extensions/updater/extension_cache_fake.h",
]
if (is_linux) {
if (is_linux && is_official_build) {
sources += [
# BraveViewsDelegateLinuxBrowserTest only works in release(official) build.
"//brave/browser/ui/views/brave_views_delegate_linux_browsertest.cc",
]
configs += [
Expand Down