Skip to content

Commit

Permalink
Remove duplicated separator in page context menu
Browse files Browse the repository at this point in the history
fixes brave/brave-browser#15714

RemoveAdjacentSeparators::RenderViewContextMenuBase is used
  • Loading branch information
AlexeyBarabash committed Jun 15, 2021
1 parent 6fd2784 commit 5361275
Show file tree
Hide file tree
Showing 5 changed files with 72 additions and 0 deletions.
2 changes: 2 additions & 0 deletions browser/ui/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,8 @@ source_set("ui") {
"views/speedreader/speedreader_bubble_util.h",
"views/speedreader/speedreader_mode_bubble.cc",
"views/speedreader/speedreader_mode_bubble.h",
"views/tab_contents/brave_web_contents_view_delegate_views.cc",
"views/tab_contents/brave_web_contents_view_delegate_views.h",
"views/tabs/brave_browser_tab_strip_controller.cc",
"views/tabs/brave_browser_tab_strip_controller.h",
"views/tabs/brave_tab_context_menu_contents.cc",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/* Copyright (c) 2021 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/. */

#include "brave/browser/ui/views/tab_contents/brave_web_contents_view_delegate_views.h"

#include <memory>
#include <utility>

#include "chrome/browser/ui/views/tab_contents/chrome_web_contents_view_delegate_views.h"
#include "components/renderer_context_menu/render_view_context_menu_base.h"

BraveWebContentsViewDelegateViews::BraveWebContentsViewDelegateViews(
content::WebContents* web_contents)
: ChromeWebContentsViewDelegateViews(web_contents) {}

BraveWebContentsViewDelegateViews::~BraveWebContentsViewDelegateViews() =
default;

void BraveWebContentsViewDelegateViews::ShowMenu(
std::unique_ptr<RenderViewContextMenuBase> menu) {
menu->RemoveAdjacentSeparators();
ChromeWebContentsViewDelegateViews::ShowMenu(std::move(menu));
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/* Copyright (c) 2021 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/. */

#ifndef BRAVE_BROWSER_UI_VIEWS_TAB_CONTENTS_BRAVE_WEB_CONTENTS_VIEW_DELEGATE_VIEWS_H_
#define BRAVE_BROWSER_UI_VIEWS_TAB_CONTENTS_BRAVE_WEB_CONTENTS_VIEW_DELEGATE_VIEWS_H_

#include <memory>

#include "chrome/browser/ui/views/tab_contents/chrome_web_contents_view_delegate_views.h"

class RenderViewContextMenuBase;

namespace content {
class WebContents;
}

class BraveWebContentsViewDelegateViews
: public ChromeWebContentsViewDelegateViews {
public:
explicit BraveWebContentsViewDelegateViews(
content::WebContents* web_contents);
~BraveWebContentsViewDelegateViews() override;

void ShowMenu(std::unique_ptr<RenderViewContextMenuBase> menu) override;
};

#endif // BRAVE_BROWSER_UI_VIEWS_TAB_CONTENTS_BRAVE_WEB_CONTENTS_VIEW_DELEGATE_VIEWS_H_
1 change: 1 addition & 0 deletions chromium_src/chrome/browser/DEPS
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ include_rules = [
"+../../../../../../../chrome/browser/ui/views/location_bar",
"+../../../../../../../chrome/browser/ui/views/page_action",
"+../../../../../../../chrome/browser/ui/views/profiles",
"+../../../../../../../chrome/browser/ui/views/tab_contents",
"+../../../../../../../chrome/browser/ui/views/tabs",
"+../../../../../../../chrome/browser/ui/views/toolbar",
"+../../../../../../../chrome/browser/ui/views/translate",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/* Copyright (c) 2021 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/. */

#include "brave/browser/ui/views/tab_contents/brave_web_contents_view_delegate_views.h"

#define CreateWebContentsViewDelegate CreateWebContentsViewDelegate_ChromiumImpl
#include "../../../../../../../chrome/browser/ui/views/tab_contents/chrome_web_contents_view_delegate_views.cc"
#undef CreateWebContentsViewDelegate

content::WebContentsViewDelegate* CreateWebContentsViewDelegate(
content::WebContents* web_contents) {
return new BraveWebContentsViewDelegateViews(web_contents);
}

0 comments on commit 5361275

Please sign in to comment.