Added Linux, MacOS, and Windows support for Tor Browser. (#2387)

Add path for native-messaging-hosts on Linux, Windows, and macOS for Tor Browser
This commit is contained in:
hidden by cloudflare 2018-10-30 08:07:59 -07:00 committed by Jonathan White
parent 5bf4f51389
commit 2ad8036823
7 changed files with 60 additions and 36 deletions

View File

@ -27,7 +27,7 @@ for all your websites, programs, etc.
* In **Browser Integration**, check **Enable KeePassXC browser integration** * In **Browser Integration**, check **Enable KeePassXC browser integration**
* Right below that, click the checkbox for the browser(s) you use * Right below that, click the checkbox for the browser(s) you use
Leave the other options at their defaults. Leave the other options at their defaults.
* *In your default web browser,* install the KeePassXC Browser extension/add-on. Instructions for [Firefox](https://addons.mozilla.org/en-US/firefox/addon/keepassxc-browser/) or [Chrome](https://chrome.google.com/webstore/detail/keepassxc-browser/oboonakemofpalcgghocfoadofidjkkk) * *In your default web browser,* install the KeePassXC Browser extension/add-on. Instructions for [Firefox or Tor Browser](https://addons.mozilla.org/en-US/firefox/addon/keepassxc-browser/) or [Chrome](https://chrome.google.com/webstore/detail/keepassxc-browser/oboonakemofpalcgghocfoadofidjkkk)
* Click the KeePassXC icon in the upper-right corner. You'll see the dialog below. * Click the KeePassXC icon in the upper-right corner. You'll see the dialog below.
* Click the blue Connect button to make the browser extension connect to the KeePassXC application. * Click the blue Connect button to make the browser extension connect to the KeePassXC application.
<img src="./KeePassXC-Connect.png" height="200" alt="KeePassXC Connect dialog"> <img src="./KeePassXC-Connect.png" height="200" alt="KeePassXC Connect dialog">

View File

@ -60,6 +60,9 @@ BrowserOptionDialog::BrowserOptionDialog(QWidget* parent)
// Vivaldi uses Chrome's registry settings // Vivaldi uses Chrome's registry settings
m_ui->vivaldiSupport->setHidden(true); m_ui->vivaldiSupport->setHidden(true);
m_ui->chromeSupport->setText("Chrome and Vivaldi"); m_ui->chromeSupport->setText("Chrome and Vivaldi");
// Tor Browser uses Firefox's registry settings
m_ui->torBrowserSupport->setHidden(true);
m_ui->firefoxSupport->setText("Firefox and Tor Browser");
#endif #endif
m_ui->browserGlobalWarningWidget->setVisible(false); m_ui->browserGlobalWarningWidget->setVisible(false);
} }
@ -99,7 +102,10 @@ void BrowserOptionDialog::loadSettings()
m_ui->chromeSupport->setChecked(settings->chromeSupport()); m_ui->chromeSupport->setChecked(settings->chromeSupport());
m_ui->chromiumSupport->setChecked(settings->chromiumSupport()); m_ui->chromiumSupport->setChecked(settings->chromiumSupport());
m_ui->firefoxSupport->setChecked(settings->firefoxSupport()); m_ui->firefoxSupport->setChecked(settings->firefoxSupport());
#ifndef Q_OS_WIN
m_ui->vivaldiSupport->setChecked(settings->vivaldiSupport()); m_ui->vivaldiSupport->setChecked(settings->vivaldiSupport());
m_ui->torBrowserSupport->setChecked(settings->torBrowserSupport());
#endif
#if defined(KEEPASSXC_DIST_APPIMAGE) #if defined(KEEPASSXC_DIST_APPIMAGE)
m_ui->supportBrowserProxy->setChecked(true); m_ui->supportBrowserProxy->setChecked(true);
@ -149,7 +155,10 @@ void BrowserOptionDialog::saveSettings()
settings->setChromeSupport(m_ui->chromeSupport->isChecked()); settings->setChromeSupport(m_ui->chromeSupport->isChecked());
settings->setChromiumSupport(m_ui->chromiumSupport->isChecked()); settings->setChromiumSupport(m_ui->chromiumSupport->isChecked());
settings->setFirefoxSupport(m_ui->firefoxSupport->isChecked()); settings->setFirefoxSupport(m_ui->firefoxSupport->isChecked());
#ifndef Q_OS_WIN
settings->setVivaldiSupport(m_ui->vivaldiSupport->isChecked()); settings->setVivaldiSupport(m_ui->vivaldiSupport->isChecked());
settings->setTorBrowserSupport(m_ui->torBrowserSupport->isChecked());
#endif
} }
void BrowserOptionDialog::showProxyLocationFileDialog() void BrowserOptionDialog::showProxyLocationFileDialog()

View File

@ -60,8 +60,7 @@
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QLabel" name="extensionLabel"> <widget class="QLabel" name="extensionLabel"/>
</widget>
</item> </item>
<item> <item>
<spacer name="verticalSpacer_1"> <spacer name="verticalSpacer_1">
@ -88,6 +87,19 @@
<property name="horizontalSpacing"> <property name="horizontalSpacing">
<number>40</number> <number>40</number>
</property> </property>
<item row="0" column="3">
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>179</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="0" column="0"> <item row="0" column="0">
<widget class="QCheckBox" name="chromeSupport"> <widget class="QCheckBox" name="chromeSupport">
<property name="text"> <property name="text">
@ -108,19 +120,6 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="0" column="2">
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>179</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="1" column="0"> <item row="1" column="0">
<widget class="QCheckBox" name="chromiumSupport"> <widget class="QCheckBox" name="chromiumSupport">
<property name="text"> <property name="text">
@ -141,6 +140,16 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="0" column="2">
<widget class="QCheckBox" name="torBrowserSupport">
<property name="text">
<string>&amp;Tor Browser</string>
</property>
<property name="checked">
<bool>false</bool>
</property>
</widget>
</item>
</layout> </layout>
</widget> </widget>
</item> </item>
@ -214,22 +223,6 @@
</property> </property>
</widget> </widget>
</item> </item>
<item>
<spacer name="verticalSpacer_2">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>10</height>
</size>
</property>
</spacer>
</item>
<item> <item>
<spacer name="verticalSpacer_2"> <spacer name="verticalSpacer_2">
<property name="orientation"> <property name="orientation">

View File

@ -228,6 +228,17 @@ void BrowserSettings::setVivaldiSupport(bool enabled)
HostInstaller::SupportedBrowsers::VIVALDI, enabled, supportBrowserProxy(), customProxyLocation()); HostInstaller::SupportedBrowsers::VIVALDI, enabled, supportBrowserProxy(), customProxyLocation());
} }
bool BrowserSettings::torBrowserSupport()
{
return m_hostInstaller.checkIfInstalled(HostInstaller::SupportedBrowsers::TOR_BROWSER);
}
void BrowserSettings::setTorBrowserSupport(bool enabled)
{
m_hostInstaller.installBrowser(
HostInstaller::SupportedBrowsers::TOR_BROWSER, enabled, supportBrowserProxy(), customProxyLocation());
}
bool BrowserSettings::passwordUseNumbers() bool BrowserSettings::passwordUseNumbers()
{ {
return config()->get("generator/Numbers", PasswordGenerator::DefaultNumbers).toBool(); return config()->get("generator/Numbers", PasswordGenerator::DefaultNumbers).toBool();

View File

@ -70,6 +70,8 @@ public:
void setFirefoxSupport(bool enabled); void setFirefoxSupport(bool enabled);
bool vivaldiSupport(); bool vivaldiSupport();
void setVivaldiSupport(bool enabled); void setVivaldiSupport(bool enabled);
bool torBrowserSupport();
void setTorBrowserSupport(bool enabled);
bool passwordUseNumbers(); bool passwordUseNumbers();
void setPasswordUseNumbers(bool useNumbers); void setPasswordUseNumbers(bool useNumbers);

View File

@ -38,16 +38,19 @@ HostInstaller::HostInstaller()
, TARGET_DIR_CHROMIUM("/Library/Application Support/Chromium/NativeMessagingHosts") , TARGET_DIR_CHROMIUM("/Library/Application Support/Chromium/NativeMessagingHosts")
, TARGET_DIR_FIREFOX("/Library/Application Support/Mozilla/NativeMessagingHosts") , TARGET_DIR_FIREFOX("/Library/Application Support/Mozilla/NativeMessagingHosts")
, TARGET_DIR_VIVALDI("/Library/Application Support/Vivaldi/NativeMessagingHosts") , TARGET_DIR_VIVALDI("/Library/Application Support/Vivaldi/NativeMessagingHosts")
, TARGET_DIR_TOR_BROWSER("/Library/Application Support/TorBrowser-Data/Browser/Mozilla/NativeMessagingHosts")
#elif defined(Q_OS_LINUX) #elif defined(Q_OS_LINUX)
, TARGET_DIR_CHROME("/.config/google-chrome/NativeMessagingHosts") , TARGET_DIR_CHROME("/.config/google-chrome/NativeMessagingHosts")
, TARGET_DIR_CHROMIUM("/.config/chromium/NativeMessagingHosts") , TARGET_DIR_CHROMIUM("/.config/chromium/NativeMessagingHosts")
, TARGET_DIR_FIREFOX("/.mozilla/native-messaging-hosts") , TARGET_DIR_FIREFOX("/.mozilla/native-messaging-hosts")
, TARGET_DIR_VIVALDI("/.config/vivaldi/NativeMessagingHosts") , TARGET_DIR_VIVALDI("/.config/vivaldi/NativeMessagingHosts")
, TARGET_DIR_TOR_BROWSER("/.tor-browser/app/Browser/TorBrowser/Data/Browser/.mozilla/native-messaging-hosts")
#elif defined(Q_OS_WIN) #elif defined(Q_OS_WIN)
, TARGET_DIR_CHROME("HKEY_CURRENT_USER\\Software\\Google\\Chrome\\NativeMessagingHosts\\org.keepassxc.keepassxc_browser") , TARGET_DIR_CHROME("HKEY_CURRENT_USER\\Software\\Google\\Chrome\\NativeMessagingHosts\\org.keepassxc.keepassxc_browser")
, TARGET_DIR_CHROMIUM("HKEY_CURRENT_USER\\Software\\Chromium\\NativeMessagingHosts\\org.keepassxc.keepassxc_browser") , TARGET_DIR_CHROMIUM("HKEY_CURRENT_USER\\Software\\Chromium\\NativeMessagingHosts\\org.keepassxc.keepassxc_browser")
, TARGET_DIR_FIREFOX("HKEY_CURRENT_USER\\Software\\Mozilla\\NativeMessagingHosts\\org.keepassxc.keepassxc_browser") , TARGET_DIR_FIREFOX("HKEY_CURRENT_USER\\Software\\Mozilla\\NativeMessagingHosts\\org.keepassxc.keepassxc_browser")
, TARGET_DIR_VIVALDI("HKEY_CURRENT_USER\\Software\\Vivaldi\\NativeMessagingHosts\\org.keepassxc.keepassxc_browser") , TARGET_DIR_VIVALDI(TARGET_DIR_CHROME)
, TARGET_DIR_TOR_BROWSER(TARGET_DIR_FIREFOX)
#endif #endif
{ {
} }
@ -159,6 +162,8 @@ QString HostInstaller::getTargetPath(SupportedBrowsers browser) const
return TARGET_DIR_FIREFOX; return TARGET_DIR_FIREFOX;
case SupportedBrowsers::VIVALDI: case SupportedBrowsers::VIVALDI:
return TARGET_DIR_VIVALDI; return TARGET_DIR_VIVALDI;
case SupportedBrowsers::TOR_BROWSER:
return TARGET_DIR_TOR_BROWSER;
default: default:
return QString(); return QString();
} }
@ -182,6 +187,8 @@ QString HostInstaller::getBrowserName(SupportedBrowsers browser) const
return "firefox"; return "firefox";
case SupportedBrowsers::VIVALDI: case SupportedBrowsers::VIVALDI:
return "vivaldi"; return "vivaldi";
case SupportedBrowsers::TOR_BROWSER:
return "tor-browser";
default: default:
return QString(); return QString();
} }
@ -287,7 +294,7 @@ QJsonObject HostInstaller::constructFile(SupportedBrowsers browser, const bool&
script["type"] = "stdio"; script["type"] = "stdio";
QJsonArray arr; QJsonArray arr;
if (browser == SupportedBrowsers::FIREFOX) { if (browser == SupportedBrowsers::FIREFOX || browser == SupportedBrowsers::TOR_BROWSER) {
for (const QString& extension : ALLOWED_EXTENSIONS) { for (const QString& extension : ALLOWED_EXTENSIONS) {
arr.append(extension); arr.append(extension);
} }

View File

@ -33,7 +33,8 @@ public:
CHROME = 0, CHROME = 0,
CHROMIUM = 1, CHROMIUM = 1,
FIREFOX = 2, FIREFOX = 2,
VIVALDI = 3 VIVALDI = 3,
TOR_BROWSER = 4
}; };
public: public:
@ -64,6 +65,7 @@ private:
const QString TARGET_DIR_CHROMIUM; const QString TARGET_DIR_CHROMIUM;
const QString TARGET_DIR_FIREFOX; const QString TARGET_DIR_FIREFOX;
const QString TARGET_DIR_VIVALDI; const QString TARGET_DIR_VIVALDI;
const QString TARGET_DIR_TOR_BROWSER;
}; };
#endif // HOSTINSTALLER_H #endif // HOSTINSTALLER_H