-
Notifications
You must be signed in to change notification settings - Fork 672
GUI Support for Enabling/Disabling Native Messaging Support Per Browser #1088
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
GUI Support for Enabling/Disabling Native Messaging Support Per Browser #1088
Conversation
@alireza-amirsamimi I've done my best to keep the code clean, modular. However, feel free to edit, simplify, or remove any parts of the code if you find something unnecessary or if it can be done better. |
@eajaykumar |
When testing this branch on Windows, I encountered the following errors:
It seems the issue is that Consequently, This suggests that relying on |
@guest75582332 ,its good way to use cross-platform library browsers ,thanks for testing and recommendation as i don't have windows or mac so i didn't test with those platforms ,i think its a one way shot to support all platforms now with this library i will try and implement it |
i checked the library its only detecting official browsers not custom browsers. can we fork browsers library to support well know custom browsers. i need final call from @alireza-amirsamimi to make it happen |
Hello, I have read your code. Thank you very much for your efforts. My concern is that the code should work across all operating systems and, of course, not be overly complex so that we can maintain it easily in the future. I believe it is a good strategy for Persepolis to create configuration files only for Chrome, Chromium, and Firefox. Other common browsers(Opera, Brave, Vivaldi, Libre Wolf) can be selected by the user in the settings window if needed. We must acknowledge that there are many browsers, and their number is increasing every day, but in reality, users do not use them as their primary browser and there aren't many users for them. I think there is no reason to complicate the code for these browsers. What I mean is that there is no need for a custom path section in the settings window. If users of these browsers are Persepolis users, they will likely either submit a pull request or open an issue, and we can add the required browser to the code in the future. |
OK its a good strategy so we remove custom manifest path and Only Firefox, Chrome, and Chromium are enabled by default. Users have Options can toggle additional browsers (LibreWolf, Brave, etc.) via the GUI. and we can add support to other browsers per request of users. so no forking of browsers library is required but should we add browsers library for cross platform support or do we hard-code those three default browsers for detecting browser installation. |
One of the original intentions behind proposing a custom path option was to support non-standard variants (e.g., Chrome Beta, Chrome Dev, Chrome Canary). In my opinion, you might not want to explicitly support these variants. That said, since all code maintenance ultimately falls on the maintainer, it's still workable without a custom path option—copying Chrome's manifest file to the appropriate location still works. As long as there's a way to clean up useless manifest files, I think that should be sufficient. |
@guest75582332 You're right copying Chrome's manifest manually for other variants works just fine. keeping the implementation simple, and focusing on core browsers like Firefox, Chrome, and Chromium, makes long-term maintenance easier. unused manifest files are properly cleaned up while user unchecks the browser, so users won't be left with unnecessary configurations. |
i just need a final go and advice from @alireza-amirsamimi to add browsers library to use as dependency and also its very light weight as i saw the code. i will remove custom manifest path and only Firefox, Chrome, and Chromium are enabled defaults. |
What do you mean by the browser library? |
for detecting installed browsers in Linux, macs, windows. browsers |
@eajaykumar |
I checked the status of the https://repology.org/project/pybrowsers/versions Given this, perhaps the best approach for now is to implement the browser detection logic internally. We could hard-code the necessary checks for the primary targets (Chrome, Chromium, and Firefox) across Windows, macOS, and Linux. |
@guest75582332 can you test it and update result please ,i added support for windows to detect installed browsers |
So we cannot use the browser library because it is not available in the repositories of Arch Linux, Fedora, openSUSE, FreeBSD, and so on. My ten years of experience in software development shows that package maintainers are reluctant to add a new package that is not in the official distribution repositories, as the process of adding and accepting a package in well-known distributions involves many steps. This means that if we use this library in the code, it is likely that Persepolis will not be updated in these well-known distributions. |
yea i too recognize it ,now i dropped it and hard coded it to streamline every step smoothly without using browsers library, you can check the code |
This does fix the browser detection issue. However,
|
@guest75582332 i will install virtual windows 10 and will try myself thanks. so its showing default browser check boxes and can you check in browsers folders if manifests generated properly |
def remove_manifests_for_browsers(browsers, custom_path=None):
for browser in browsers:
try:
if browser.strip() == "":
continue
path = get_manifest_path_for_browser(browser, custom_path)
if os.path.exists(path):
os.remove(path)
print(f"Removed manifest for {browser}: {path}")
except Exception as e:
print(f"Failed to remove manifest for {browser}: {e}") I think the reason for the error is that the current implementation of if os_type == OS.LINUX:
if browser == BROWSER. CHROMIUM:
return os.path.join(home_address, '.config/chromium/NativeMessagingHosts')
elif browser == BROWSER.CHROME:
return os.path.join(home_address, '.config/google-chrome/NativeMessagingHosts')
elif browser == BROWSER.FIREFOX:
return os.path. join(home_address, '.mozilla/native-messaging-hosts')
elif browser == BROWSER.VIVALDI:
return os.path.join(home_address, '.config/vivaldi/NativeMessagingHosts')
elif browser == BROWSER.OPERA:
return os.path.join(home_address, '. config/opera/NativeMessagingHosts')
elif browser == BROWSER.BRAVE:
return os.path.join(home_address, '.config/BraveSoftware/Brave-Browser/NativeMessagingHosts')
elif browser == "librewolf":
return os.path.join(home_address, '.librewolf/native-messaging-hosts') |
@guest75582332 yea i got it that's why am installing windows and checking all browsers paths to implement and make sure everything work properly |
i got it working in windows now ,am just refactoring code and will update it |
@alireza-amirsamimi @guest75582332 i encountered conflict on Windows, all Chromium-based browsers (Chrome, Brave, Chromium,etc.) shared the same native messaging host name and manifest. This caused a conflict where disabled browsers could still capture downloads, because Windows uses the same registry key for all as the extension connects to the same host name and extension id.
with this changes only the enabled browser’s manifest works and every browser has unique host name and we can add a fallback to for older version with this |
@eajaykumar |
Summary
This PR adds a new Browser Integration tab in the Persepolis settings, giving users control over which browsers are integrated via native messaging.
Features:
initialization.py
,setting_ui.py
,setting.py
,browser_integration.py
Tested on Linux (LibreWolf, Firefox). Requires clean config reset for testing.