diff options
author | Mark Walker <mark.damon.walker@tutanota.com> | 2024-04-28 10:33:49 +0800 |
---|---|---|
committer | rodarima <rodarima@gmail.com> | 2024-04-29 19:39:21 +0200 |
commit | 20a10f03d4b14d68a77db88feea95cfcdbef8d34 (patch) | |
tree | 8cc0d32153dfedc7805b743245e01ebf0078c4dd /src/menu.cc | |
parent | b18496029c93a601646245adeb19372d705e0aab (diff) |
Add force https mode
Implement an option to force all http urls to be upgraded to HTTPS,
similar to HTTPS-Only Mode in Firefox.
A http_force_https preference variable is provided as well as a menu
bar item to toggle this mode.
See: https://support.mozilla.org/en-US/kb/https-only-prefs
Diffstat (limited to 'src/menu.cc')
-rw-r--r-- | src/menu.cc | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/src/menu.cc b/src/menu.cc index a1252989..865b843b 100644 --- a/src/menu.cc +++ b/src/menu.cc @@ -671,6 +671,19 @@ static void Menu_embedded_css_cb(Fl_Widget *wid, void*) a_UIcmd_repush(popup_bw); } + +/** + * Toggle use of force https mode + */ +static void Menu_force_https_cb(Fl_Widget *wid, void*) +{ + Fl_Menu_Item *item = (Fl_Menu_Item*) wid; + + item->flags ^= FL_MENU_VALUE; + prefs.http_force_https = item->flags & FL_MENU_VALUE ? 1 : 0; + a_UIcmd_repush(popup_bw); +} + static void Menu_panel_change_cb(Fl_Widget*, void *user_data) { UI *ui = (UI*)popup_bw->ui; @@ -728,6 +741,8 @@ void a_Menu_tools_popup(BrowserWindow *bw, int x, int y) FL_MENU_TOGGLE,0,0,0,0}, {"Load background images", 0, Menu_bgimg_load_toggle_cb, 0, FL_MENU_TOGGLE|FL_MENU_DIVIDER,0,0,0,0}, + {"Force HTTPS", 0, Menu_force_https_cb, 0, + FL_MENU_TOGGLE|FL_MENU_DIVIDER,0,0,0,0}, {"Panel size", 0, Menu_nop_cb, (void*)"Submenu1", FL_SUBMENU,0,0,0,0}, {"tiny", 0,Menu_panel_change_cb,(void*)0,FL_MENU_RADIO,0,0,0,0}, {"small", 0,Menu_panel_change_cb,(void*)1,FL_MENU_RADIO,0,0,0,0}, @@ -751,8 +766,10 @@ void a_Menu_tools_popup(BrowserWindow *bw, int x, int y) pm[2].set(); if (prefs.load_background_images) pm[3].set(); - pm[5+cur_panelsize].setonly(); - cur_smallicons ? pm[8].set() : pm[8].clear(); + if (prefs.http_force_https) + pm[4].set(); + pm[6+cur_panelsize].setonly(); + cur_smallicons ? pm[9].set() : pm[9].clear(); item = pm->popup(x, y); if (item) { |