11#include " config.h"
2- #include " config.h"
3- #include " config.h"
42#include " ../globals.h"
53#include " win32/reg.h"
64#include " win32/ole32.h"
97#include < fmt/core.h>
108#include < filesystem>
119#include " fss.h"
10+ #include " hashing.h"
1211
1312using namespace std ;
1413namespace fs = std::filesystem;
@@ -28,11 +27,15 @@ namespace bt {
2827 #define ToastVisibleSecsKey " toast_visible_secs"
2928 #define ToastBorderWidthKey " toast_border_width"
3029 #define IconOverlayKey " icon_overlay"
30+ #define BrowserEngine " engine"
31+ #define IsAutodiscovered " auto"
32+ #define IsIncognito " incognito"
3133 #define LogRuleHitsKey " log_rule_hits"
3234 #define LogAppKey " log_app"
3335 #define PersistPopularityKey " persist_popularity"
3436 #define ShowHiddenBrowsersKey " browsers_show_hidden"
3537 #define DiscoverFirefoxContainersKey " firefox_containers"
38+ #define DiscoverClassicFirefoxProfilesKey " firefox_classic_profiles"
3639 #define UnshortEnabledKey " unshort_enabled"
3740 #define PickerSectionName " picker"
3841 #define PickerOnKeyCS " on_key_cs"
@@ -127,6 +130,47 @@ namespace bt {
127130 cfg.set_value (" rule" , rules, section);
128131 }
129132
133+ for (auto ssn : section_names) {
134+ if (ssn.starts_with (" browser:" )) {
135+ vector<string> parts = str::split (ssn, " :" );
136+
137+ if (parts.size () == 2 ) { // browser
138+
139+ string browser_id = parts[1 ];
140+
141+ // browser subtype (5.5.0)
142+ string subtype = cfg.get_value (" subtype" , ssn);
143+ if (!subtype.empty ()) {
144+ is_dirty = true ;
145+ cfg.delete_key (" subtype" , ssn);
146+ if (subtype == " firefox" ) {
147+ cfg.set_value (" engine" , " gecko" , ssn);
148+ cfg.set_value (" auto" , true , ssn);
149+ } else if (subtype == " chromium" ) {
150+ cfg.set_value (" engine" , " chromium" , ssn);
151+ cfg.set_value (" auto" , true , ssn);
152+ } else if (subtype == " user" ) {
153+ // no keys to add
154+ }
155+ }
156+
157+ } else if (parts.size () == 3 ) { // profile
158+
159+ string profile_id = parts[2 ];
160+
161+ // profile subtype and incognito (5.5.0)
162+ string subtype = cfg.get_value (" subtype" , ssn);
163+ if (!subtype.empty ()) {
164+ is_dirty = true ;
165+ cfg.delete_key (" subtype" , ssn);
166+ if (subtype == " incognito" ) {
167+ cfg.set_value (" incognito" , true , ssn);
168+ }
169+ }
170+ }
171+ }
172+ }
173+
130174 if (is_dirty) {
131175 cfg.commit ();
132176 }
@@ -136,6 +180,7 @@ namespace bt {
136180 string v;
137181
138182 show_hidden_browsers = cfg.get_bool_value (ShowHiddenBrowsersKey, true );
183+ discover_classic_firefox_profiles = cfg.get_bool_value (DiscoverClassicFirefoxProfilesKey, false );
139184 discover_firefox_containers = cfg.get_bool_value (DiscoverFirefoxContainersKey, false );
140185
141186 theme_id = cfg.get_value (" theme" );
@@ -182,6 +227,7 @@ namespace bt {
182227
183228 void config::commit () {
184229 cfg.set_value (ShowHiddenBrowsersKey, show_hidden_browsers);
230+ cfg.set_value (DiscoverClassicFirefoxProfilesKey, discover_classic_firefox_profiles);
185231 cfg.set_value (DiscoverFirefoxContainersKey, discover_firefox_containers);
186232 cfg.set_value (" theme" , theme_id == " follow_os" ? " " : theme_id);
187233 cfg.set_value (LogRuleHitsKey, log_rule_hits);
@@ -245,18 +291,11 @@ namespace bt {
245291 cfg.set_value (Icon, b->icon_path , section);
246292 cfg.set_value (ItemSortOrder, b->sort_order , section);
247293 cfg.set_value (DataPath, b->data_path , section);
248-
249- string subtype;
250- if (b->is_system ) {
251- if (b->is_firefox ) subtype = " firefox" ;
252- else if (b->is_chromium ) subtype = " chromium" ;
253- } else {
254- subtype = " user" ;
255- }
256- cfg.set_value (" subtype" , subtype, section);
294+ cfg.set_value (BrowserEngine, browser_engine_to_string (b->engine ), section);
295+ cfg.set_value (IsAutodiscovered, b->is_autodiscovered , section);
257296
258297 // singular user instance
259- if (!b->is_system && b->instances .size () == 1 ) {
298+ if (!b->is_autodiscovered && b->instances .size () == 1 ) {
260299 auto instance = b->instances [0 ];
261300 cfg.set_value (" arg" , instance->launch_arg , section);
262301 cfg.set_value (" rule" , instance->get_rules_as_text_clean (), section);
@@ -273,7 +312,7 @@ namespace bt {
273312 cfg.set_value (" user_arg" , bi->user_arg , section);
274313 cfg.set_value (" icon" , bi->icon_path , section);
275314 cfg.set_value (" user_icon" , bi->user_icon_path , section);
276- cfg.set_value (" subtype " , bi->is_incognito ? " incognito " : " " , section);
315+ cfg.set_value (IsIncognito , bi->is_incognito , section);
277316 cfg.set_value (IsHidden, bi->is_hidden , section);
278317 cfg.set_value (" rule" , bi->get_rules_as_text_clean (), section);
279318 cfg.set_value (ItemSortOrder, bi->sort_order , section);
@@ -291,24 +330,22 @@ namespace bt {
291330 vector<string> parts = str::split (bsn, " :" );
292331 if (parts[0 ] != BrowserPrefix || parts.size () != 2 ) continue ;
293332
294- string subtype = cfg.get_value (" subtype" , bsn);
295333 string b_id = parts[1 ];
296334
297335 auto b = make_shared<browser>(
298336 b_id,
299337 cfg.get_value (" name" , bsn),
300- cfg.get_value (" cmd" , bsn),
301- subtype != " user"
338+ cfg.get_value (" cmd" , bsn)
302339 );
303340
304- b->is_firefox = subtype == " firefox" ;
305- b->is_chromium = subtype == " chromium" ;
341+ b->engine = to_browser_engine (cfg.get_value (BrowserEngine, bsn));
306342 b->is_hidden = cfg.get_bool_value (IsHidden, false , bsn);
307343 b->icon_path = cfg.get_value (Icon, bsn);
308344 b->sort_order = cfg.get_int_value (ItemSortOrder, 0 , bsn);
309345 b->data_path = cfg.get_value (DataPath, bsn);
346+ b->is_autodiscovered = cfg.get_bool_value (IsAutodiscovered, false , bsn);
310347
311- if (b->is_system ) {
348+ if (b->is_autodiscovered ) {
312349
313350 // profiles, if any
314351 string profile_prefix = fmt::format (" {}:{}" , BrowserPrefix, b_id);
@@ -317,7 +354,6 @@ namespace bt {
317354 if (parts[0 ] != BrowserPrefix || parts.size () != 3 || parts[1 ] != b_id) continue ;
318355
319356 string p_sys_name = parts[2 ];
320- string p_subtype = cfg.get_value (" subtype" , ssn);
321357
322358 auto bi = make_shared<browser_instance>(
323359 b,
@@ -328,7 +364,7 @@ namespace bt {
328364
329365 bi->user_icon_path = cfg.get_value (" user_icon" , ssn);
330366 bi->user_arg = cfg.get_value (" user_arg" , ssn);
331- bi->is_incognito = p_subtype == " incognito " ;
367+ bi->is_incognito = cfg. get_bool_value (IsIncognito, false , ssn) ;
332368 bi->is_hidden = cfg.get_bool_value (IsHidden, false , ssn);
333369 bi->sort_order = cfg.get_int_value (ItemSortOrder, 0 , ssn);
334370
@@ -382,4 +418,18 @@ namespace bt {
382418 return icon_overlay_mode::profile_on_browser;
383419 }
384420
421+ std::string config::browser_engine_to_string (browser_engine engine) {
422+ switch (engine) {
423+ case browser_engine::chromium: return " chromium" ;
424+ case browser_engine::gecko: return " gecko" ;
425+ default : return " " ;
426+ }
427+ }
428+
429+ browser_engine config::to_browser_engine (const std::string& name) {
430+ if (name == " chromium" ) return browser_engine::chromium;
431+ if (name == " gecko" ) return browser_engine::gecko;
432+ return browser_engine::unknown;
433+ }
434+
385435}
0 commit comments