brave / brave-browser

Brave browser for Android, iOS, Linux, macOS, Windows.
https://brave.com
Mozilla Public License 2.0
17.91k stars 2.34k forks source link

[Desktop] Enable widget-specific menus on right click on New Tab page #8900

Open karenkliu opened 4 years ago

karenkliu commented 4 years ago

Description

Currently the widgets on the new tab page show the default browser right click menu actions on right click: Screen Shot 2020-03-27 at 1 19 27 PM

A lot of these actions are irrelevant and some such as "Inspect" are ones we don't want users to play around with (e.g. changing the Brave Stats labels).

Designs

Make the right click menu specific to each widget.

Show the same menu that you get in the widget dropdown for Brave Stats when the user right clicks anywhere inside the Brave Stats widget:

menu top sites right click

Show the same menu that you get in the widget dropdown for top sites when the user right clicks anywhere inside the top sites widget:

menu top sites right click 1

Right clicking on a top site tile shows relevant actions for the link:

menu top sites right click 2

Show the same menu that you get in the widget dropdown for Binance when the user right clicks anywhere inside the Binance widget:

menu binance right click

Show the same menu that you get in the widget dropdown for Brave Rewards when the user right clicks anywhere inside the Brave Rewards widget:

menu rewards right click

Open "Customize Dashboard" panel when user clicks anywhere outside of a widget area:

menu general right click

This interaction will look weird for now but will be fixed once we transition to the new expanded "Customize Dashboard" modal overlay.

cezaraugusto commented 4 years ago

cc @simonhong do you know how much effort would it be to have an anchor inside NTP's webUI, which opens up a private/tor window? This issue is on my plans, but I don't know how to do that part.

simonhong commented 4 years ago

@cezaraugusto ~~Do you mean adding open private/tor window entry into context menu on NTP page? If so, we already have code that for it. BraveRenderViewContextMenu::InitMenu adds our own entry to context menu. After checking current active tab page, then we can add that entry if current active tab is NTP.~~

Ah.. I think you want to add these entry to our new custom NTP context menu. If so, I think we should introduce new webui message for requesting this url in new private or tor window. and we can refer the c++ code for opening a link in new private/or window. Below code is what we use so far.

    case IDC_CONTENT_CONTEXT_OPENLINKOFFTHERECORD:
      OpenURLWithExtraHeaders(params_.link_url, GURL(),
                              WindowOpenDisposition::OFF_THE_RECORD,
                              ui::PAGE_TRANSITION_LINK, "" /* extra_headers */,
                              true /* started_from_context_menu */);
      break;
    case IDC_CONTENT_CONTEXT_OPENLINKTOR:
      profiles::SwitchToTorProfile(
          base::Bind(
              OnProfileCreated, params_.link_url,
              content::Referrer(
                GURL(), network::mojom::ReferrerPolicy::kStrictOrigin)));
      break;