@@ -12,13 +12,11 @@ namespace Flow.Launcher.Plugin.BrowserBookmark.Services;
12
12
13
13
public class BookmarkLoaderService
14
14
{
15
- private readonly PluginInitContext _context ;
16
15
private readonly Settings _settings ;
17
16
private readonly string _tempPath ;
18
17
19
- public BookmarkLoaderService ( PluginInitContext context , Settings settings , string tempPath )
18
+ public BookmarkLoaderService ( Settings settings , string tempPath )
20
19
{
21
- _context = context ;
22
20
_settings = settings ;
23
21
_tempPath = tempPath ;
24
22
}
@@ -44,7 +42,7 @@ public BookmarkLoaderService(PluginInitContext context, Settings settings, strin
44
42
}
45
43
catch ( Exception e )
46
44
{
47
- _context . API . LogException ( nameof ( BookmarkLoaderService ) , $ "Failed to load bookmarks from { loader . Name } .", e ) ;
45
+ Main . Context . API . LogException ( nameof ( BookmarkLoaderService ) , $ "Failed to load bookmarks from { loader . Name } .", e ) ;
48
46
}
49
47
} ) ;
50
48
@@ -60,55 +58,52 @@ public IEnumerable<IBookmarkLoader> GetBookmarkLoaders(ConcurrentBag<string> dis
60
58
61
59
public IEnumerable < IBookmarkLoader > GetChromiumBookmarkLoaders ( ConcurrentBag < string > discoveredBookmarkFiles )
62
60
{
63
- var logAction = ( string tag , string msg , Exception ? ex ) => _context . API . LogException ( tag , msg , ex ) ;
64
61
var localAppData = Environment . GetFolderPath ( Environment . SpecialFolder . LocalApplicationData ) ;
65
62
66
63
if ( _settings . LoadChromeBookmark )
67
64
{
68
65
var path = Path . Combine ( localAppData , @"Google\Chrome\User Data" ) ;
69
66
if ( Directory . Exists ( path ) )
70
- yield return new ChromiumBookmarkLoader ( "Google Chrome" , path , logAction , discoveredBookmarkFiles ) ;
67
+ yield return new ChromiumBookmarkLoader ( "Google Chrome" , path , discoveredBookmarkFiles ) ;
71
68
72
69
var canaryPath = Path . Combine ( localAppData , @"Google\Chrome SxS\User Data" ) ;
73
70
if ( Directory . Exists ( canaryPath ) )
74
- yield return new ChromiumBookmarkLoader ( "Google Chrome Canary" , canaryPath , logAction , discoveredBookmarkFiles ) ;
71
+ yield return new ChromiumBookmarkLoader ( "Google Chrome Canary" , canaryPath , discoveredBookmarkFiles ) ;
75
72
}
76
73
77
74
if ( _settings . LoadEdgeBookmark )
78
75
{
79
76
var path = Path . Combine ( localAppData , @"Microsoft\Edge\User Data" ) ;
80
77
if ( Directory . Exists ( path ) )
81
- yield return new ChromiumBookmarkLoader ( "Microsoft Edge" , path , logAction , discoveredBookmarkFiles ) ;
78
+ yield return new ChromiumBookmarkLoader ( "Microsoft Edge" , path , discoveredBookmarkFiles ) ;
82
79
83
80
var devPath = Path . Combine ( localAppData , @"Microsoft\Edge Dev\User Data" ) ;
84
81
if ( Directory . Exists ( devPath ) )
85
- yield return new ChromiumBookmarkLoader ( "Microsoft Edge Dev" , devPath , logAction , discoveredBookmarkFiles ) ;
82
+ yield return new ChromiumBookmarkLoader ( "Microsoft Edge Dev" , devPath , discoveredBookmarkFiles ) ;
86
83
87
84
var canaryPath = Path . Combine ( localAppData , @"Microsoft\Edge SxS\User Data" ) ;
88
85
if ( Directory . Exists ( canaryPath ) )
89
- yield return new ChromiumBookmarkLoader ( "Microsoft Edge Canary" , canaryPath , logAction , discoveredBookmarkFiles ) ;
86
+ yield return new ChromiumBookmarkLoader ( "Microsoft Edge Canary" , canaryPath , discoveredBookmarkFiles ) ;
90
87
}
91
88
92
89
if ( _settings . LoadChromiumBookmark )
93
90
{
94
91
var path = Path . Combine ( localAppData , @"Chromium\User Data" ) ;
95
92
if ( Directory . Exists ( path ) )
96
- yield return new ChromiumBookmarkLoader ( "Chromium" , path , logAction , discoveredBookmarkFiles ) ;
93
+ yield return new ChromiumBookmarkLoader ( "Chromium" , path , discoveredBookmarkFiles ) ;
97
94
}
98
95
99
96
foreach ( var browser in _settings . CustomBrowsers . Where ( b => b . BrowserType == BrowserType . Chromium ) )
100
97
{
101
98
if ( string . IsNullOrEmpty ( browser . Name ) || string . IsNullOrEmpty ( browser . DataDirectoryPath ) || ! Directory . Exists ( browser . DataDirectoryPath ) )
102
99
continue ;
103
100
104
- yield return new ChromiumBookmarkLoader ( browser . Name , browser . DataDirectoryPath , logAction , discoveredBookmarkFiles ) ;
101
+ yield return new ChromiumBookmarkLoader ( browser . Name , browser . DataDirectoryPath , discoveredBookmarkFiles ) ;
105
102
}
106
103
}
107
104
108
105
public IEnumerable < IBookmarkLoader > GetFirefoxBookmarkLoaders ( )
109
106
{
110
- var logAction = ( string tag , string msg , Exception ? ex ) => _context . API . LogException ( tag , msg , ex ) ;
111
-
112
107
if ( _settings . LoadFirefoxBookmark )
113
108
{
114
109
string ? placesPath = null ;
@@ -118,11 +113,11 @@ public IEnumerable<IBookmarkLoader> GetFirefoxBookmarkLoaders()
118
113
}
119
114
catch ( Exception ex )
120
115
{
121
- _context . API . LogException ( nameof ( BookmarkLoaderService ) , "Failed to find Firefox profile" , ex ) ;
116
+ Main . Context . API . LogException ( nameof ( BookmarkLoaderService ) , "Failed to find Firefox profile" , ex ) ;
122
117
}
123
118
if ( ! string . IsNullOrEmpty ( placesPath ) )
124
119
{
125
- yield return new FirefoxBookmarkLoader ( "Firefox" , placesPath , _tempPath , logAction ) ;
120
+ yield return new FirefoxBookmarkLoader ( "Firefox" , placesPath , _tempPath ) ;
126
121
}
127
122
128
123
string ? msixPlacesPath = null ;
@@ -132,11 +127,11 @@ public IEnumerable<IBookmarkLoader> GetFirefoxBookmarkLoaders()
132
127
}
133
128
catch ( Exception ex )
134
129
{
135
- _context . API . LogException ( nameof ( BookmarkLoaderService ) , "Failed to find Firefox MSIX package" , ex ) ;
130
+ Main . Context . API . LogException ( nameof ( BookmarkLoaderService ) , "Failed to find Firefox MSIX package" , ex ) ;
136
131
}
137
132
if ( ! string . IsNullOrEmpty ( msixPlacesPath ) )
138
133
{
139
- yield return new FirefoxBookmarkLoader ( "Firefox (Store)" , msixPlacesPath , _tempPath , logAction ) ;
134
+ yield return new FirefoxBookmarkLoader ( "Firefox (Store)" , msixPlacesPath , _tempPath ) ;
140
135
}
141
136
}
142
137
@@ -151,7 +146,6 @@ public IEnumerable<IBookmarkLoader> GetFirefoxBookmarkLoaders()
151
146
152
147
private IBookmarkLoader CreateCustomFirefoxLoader ( string name , string dataDirectoryPath )
153
148
{
154
- var logAction = ( string tag , string msg , Exception ? ex ) => _context . API . LogException ( tag , msg , ex ) ;
155
149
// Custom Firefox paths might point to the root profile dir (e.g. ...\Mozilla\Firefox)
156
150
var placesPath = FirefoxProfileFinder . GetPlacesPathFromProfileDir ( dataDirectoryPath ) ;
157
151
if ( string . IsNullOrEmpty ( placesPath ) )
@@ -161,6 +155,6 @@ private IBookmarkLoader CreateCustomFirefoxLoader(string name, string dataDirect
161
155
}
162
156
163
157
// Do not add Firefox places.sqlite to the watcher as it's updated constantly for history.
164
- return new FirefoxBookmarkLoader ( name , placesPath , _tempPath , logAction ) ;
158
+ return new FirefoxBookmarkLoader ( name , placesPath , _tempPath ) ;
165
159
}
166
160
}
0 commit comments