Skip to content

Commit

Permalink
Move the menu, fix review issues
Browse files Browse the repository at this point in the history
  • Loading branch information
atuchin-m committed Sep 11, 2024
1 parent a12ca31 commit 00663c9
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -691,28 +691,37 @@ void BraveRenderViewContextMenu::AddAccessibilityLabelsServiceItem(
// Suppress adding "Get image descriptions from Brave"
}

#if BUILDFLAG(ENABLE_EXTENSIONS)
void BraveRenderViewContextMenu::AppendAllExtensionItems() {
void BraveRenderViewContextMenu::AppendDeveloperItems() {
RenderViewContextMenu_Chromium::AppendDeveloperItems();

auto* shields_tab_helper =
brave_shields::BraveShieldsTabHelper::FromWebContents(
source_web_contents_);
bool add_block_elements =
shields_tab_helper && shields_tab_helper->GetAdBlockMode() !=
brave_shields::mojom::AdBlockMode::ALLOW;
add_block_elements &= params_.selection_text.empty();
#if BUILDFLAG(IS_ANDROID)
// Content picker doesn't available for Android.
add_block_elements = false;
#endif // BUILDFLAG(IS_ANDROID)
add_block_elements &=
params_.link_url.is_empty() || params_.has_image_contents;
params_.selection_text.empty() || !params_.link_url.is_empty();

const auto page_url = source_web_contents_->GetLastCommittedURL();
add_block_elements &= page_url.SchemeIsHTTPOrHTTPS();
if (add_block_elements) {
menu_model_.AddItemWithStringId(IDC_ADBLOCK_CONTEXT_BLOCK_ELEMENTS,
IDS_ADBLOCK_CONTEXT_BLOCK_ELEMENTS);
std::optional<size_t> inspect_index =
menu_model_.GetIndexOfCommandId(IDC_CONTENT_CONTEXT_INSPECTELEMENT);
if (inspect_index) {
menu_model_.InsertItemWithStringIdAt(*inspect_index,
IDC_ADBLOCK_CONTEXT_BLOCK_ELEMENTS,
IDS_ADBLOCK_CONTEXT_BLOCK_ELEMENTS);
} else {
menu_model_.AddItemWithStringId(IDC_ADBLOCK_CONTEXT_BLOCK_ELEMENTS,
IDS_ADBLOCK_CONTEXT_BLOCK_ELEMENTS);
}
}

RenderViewContextMenu_Chromium::AppendAllExtensionItems();
}
#endif // BUILDFLAG(ENABLE_EXTENSIONS)

void BraveRenderViewContextMenu::InitMenu() {
RenderViewContextMenu_Chromium::InitMenu();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ class BraveRenderViewContextMenu;
base::OnceCallback<void(BraveRenderViewContextMenu*)> cb); \
static void RegisterMenuShownCallbackForTesting_unused
#define AppendReadingModeItem virtual AppendReadingModeItem
#define AppendAllExtensionItems virtual AppendAllExtensionItems
#define AppendDeveloperItems virtual AppendDeveloperItems
#include "src/chrome/browser/renderer_context_menu/render_view_context_menu.h" // IWYU pragma: export
#undef AppendAllExtensionItems
#undef AppendDeveloperItems
#undef AppendReadingModeItem
#undef RegisterMenuShownCallbackForTesting
#undef RenderViewContextMenu
Expand All @@ -52,9 +52,7 @@ class BraveRenderViewContextMenu : public RenderViewContextMenu_Chromium {
// Do nothing as we have our own speed reader
void AppendReadingModeItem() override {}

#if BUILDFLAG(ENABLE_EXTENSIONS)
void AppendAllExtensionItems() override;
#endif // BUILDFLAG(ENABLE_EXTENSIONS)
void AppendDeveloperItems() override;

private:
friend class BraveRenderViewContextMenuTest;
Expand Down
4 changes: 2 additions & 2 deletions components/cosmetic_filters/common/cosmetic_filters.mojom
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ interface CosmeticFiltersResources {
};

interface CosmeticFiltersHandler {
// Adds a user cosmetic rule for the current site.
// (currently from the content picker feature).
// Adds a user cosmetic rule for the current site.
// (currently from the content picker feature).
AddSiteCosmeticFilter(string filter);

// Opens the custom filter section in Shields settings .
Expand Down

0 comments on commit 00663c9

Please sign in to comment.