Skip to content

Commit

Permalink
Add integration with Brave browser
Browse files Browse the repository at this point in the history
  • Loading branch information
droidmonkey committed Apr 8, 2019
1 parent 4b1258f commit 1493943
Show file tree
Hide file tree
Showing 8 changed files with 55 additions and 12 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ so please check out your distribution's package list to see if KeePassXC is avai
- Using website favicons as entry icons
- Merging of databases
- Automatic reload when the database changed on disk
- Browser integration with KeePassXC-Browser using [native messaging](https://developer.chrome.com/extensions/nativeMessaging) for [Mozilla Firefox](https://addons.mozilla.org/en-US/firefox/addon/keepassxc-browser/) and [Google Chrome or Chromium](https://chrome.google.com/webstore/detail/keepassxc-browser/oboonakemofpalcgghocfoadofidjkkk)
- Browser integration with KeePassXC-Browser using [native messaging](https://developer.chrome.com/extensions/nativeMessaging) for [Mozilla Firefox](https://addons.mozilla.org/en-US/firefox/addon/keepassxc-browser/) and [Google Chrome, Chromium, Vivaldi, or Brave](https://chrome.google.com/webstore/detail/keepassxc-browser/oboonakemofpalcgghocfoadofidjkkk)
- Synchronize passwords using KeeShare. See [Using Sharing](./docs/QUICKSTART.md#using-sharing) for more details.
- Many bug fixes

Expand Down
8 changes: 6 additions & 2 deletions src/browser/BrowserOptionDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ BrowserOptionDialog::BrowserOptionDialog(QWidget* parent)
tr("KeePassXC-Browser is needed for the browser integration to work. <br />Download it for %1 and %2. %3")
.arg("<a href=\"https://addons.mozilla.org/en-US/firefox/addon/keepassxc-browser/\">Firefox</a>",
"<a href=\"https://chrome.google.com/webstore/detail/keepassxc-browser/oboonakemofpalcgghocfoadofidjkkk\">"
"Google Chrome / Chromium / Vivaldi</a>",
"Google Chrome / Chromium / Vivaldi / Brave</a>",
snapInstructions));
// clang-format on

Expand Down Expand Up @@ -75,9 +75,11 @@ BrowserOptionDialog::BrowserOptionDialog(QWidget* parent)
connect(m_ui->customProxyLocationBrowseButton, SIGNAL(clicked()), this, SLOT(showProxyLocationFileDialog()));

#ifdef Q_OS_WIN
// Brave uses Chrome's registry settings
m_ui->braveSupport->setHidden(true);
// Vivaldi uses Chrome's registry settings
m_ui->vivaldiSupport->setHidden(true);
m_ui->chromeSupport->setText("Chrome and Vivaldi");
m_ui->chromeSupport->setText("Chrome, Vivaldi, and Brave");
// Tor Browser uses Firefox's registry settings
m_ui->torBrowserSupport->setHidden(true);
m_ui->firefoxSupport->setText("Firefox and Tor Browser");
Expand Down Expand Up @@ -122,6 +124,7 @@ void BrowserOptionDialog::loadSettings()
m_ui->chromiumSupport->setChecked(settings->chromiumSupport());
m_ui->firefoxSupport->setChecked(settings->firefoxSupport());
#ifndef Q_OS_WIN
m_ui->braveSupport->setChecked(settings->braveSupport());
m_ui->vivaldiSupport->setChecked(settings->vivaldiSupport());
m_ui->torBrowserSupport->setChecked(settings->torBrowserSupport());
#endif
Expand Down Expand Up @@ -183,6 +186,7 @@ void BrowserOptionDialog::saveSettings()
settings->setChromiumSupport(m_ui->chromiumSupport->isChecked());
settings->setFirefoxSupport(m_ui->firefoxSupport->isChecked());
#ifndef Q_OS_WIN
settings->setBraveSupport(m_ui->braveSupport->isChecked());
settings->setVivaldiSupport(m_ui->vivaldiSupport->isChecked());
settings->setTorBrowserSupport(m_ui->torBrowserSupport->isChecked());
#endif
Expand Down
10 changes: 10 additions & 0 deletions src/browser/BrowserOptionDialog.ui
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,16 @@
</property>
</widget>
</item>
<item row="1" column="2">
<widget class="QCheckBox" name="braveSupport">
<property name="text">
<string>&amp;Brave</string>
</property>
<property name="checked">
<bool>false</bool>
</property>
</widget>
</item>
</layout>
</widget>
</item>
Expand Down
11 changes: 11 additions & 0 deletions src/browser/BrowserSettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,17 @@ void BrowserSettings::setVivaldiSupport(bool enabled)
HostInstaller::SupportedBrowsers::VIVALDI, enabled, supportBrowserProxy(), customProxyLocation());
}

bool BrowserSettings::braveSupport()
{
return m_hostInstaller.checkIfInstalled(HostInstaller::SupportedBrowsers::BRAVE);
}

void BrowserSettings::setBraveSupport(bool enabled)
{
m_hostInstaller.installBrowser(
HostInstaller::SupportedBrowsers::BRAVE, enabled, supportBrowserProxy(), customProxyLocation());
}

bool BrowserSettings::torBrowserSupport()
{
return m_hostInstaller.checkIfInstalled(HostInstaller::SupportedBrowsers::TOR_BROWSER);
Expand Down
2 changes: 2 additions & 0 deletions src/browser/BrowserSettings.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ class BrowserSettings
void setFirefoxSupport(bool enabled);
bool vivaldiSupport();
void setVivaldiSupport(bool enabled);
bool braveSupport();
void setBraveSupport(bool enabled);
bool torBrowserSupport();
void setTorBrowserSupport(bool enabled);

Expand Down
12 changes: 10 additions & 2 deletions src/browser/HostInstaller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,14 @@ HostInstaller::HostInstaller()
, TARGET_DIR_FIREFOX("/Library/Application Support/Mozilla/NativeMessagingHosts")
, TARGET_DIR_VIVALDI("/Library/Application Support/Vivaldi/NativeMessagingHosts")
, TARGET_DIR_TOR_BROWSER("/Library/Application Support/TorBrowser-Data/Browser/Mozilla/NativeMessagingHosts")
, TARGET_DIR_BRAVE("/Library/Application Support/BraveSoftware/Brave-Browser/NativeMessagingHosts")
#elif defined(Q_OS_LINUX)
, TARGET_DIR_CHROME("/.config/google-chrome/NativeMessagingHosts")
, TARGET_DIR_CHROMIUM("/.config/chromium/NativeMessagingHosts")
, TARGET_DIR_FIREFOX("/.mozilla/native-messaging-hosts")
, TARGET_DIR_VIVALDI("/.config/vivaldi/NativeMessagingHosts")
, TARGET_DIR_TOR_BROWSER("/.tor-browser/app/Browser/TorBrowser/Data/Browser/.mozilla/native-messaging-hosts")
, TARGET_DIR_BRAVE("/.config/BraveSoftware/Brave-Browser/NativeMessagingHosts")
#elif defined(Q_OS_WIN)
// clang-format off
, TARGET_DIR_CHROME("HKEY_CURRENT_USER\\Software\\Google\\Chrome\\NativeMessagingHosts\\org.keepassxc.keepassxc_browser")
Expand All @@ -53,6 +55,7 @@ HostInstaller::HostInstaller()
, TARGET_DIR_FIREFOX("HKEY_CURRENT_USER\\Software\\Mozilla\\NativeMessagingHosts\\org.keepassxc.keepassxc_browser")
, TARGET_DIR_VIVALDI(TARGET_DIR_CHROME)
, TARGET_DIR_TOR_BROWSER(TARGET_DIR_FIREFOX)
, TARGET_DIR_BRAVE(TARGET_DIR_CHROME)
#endif
{
}
Expand Down Expand Up @@ -140,7 +143,8 @@ void HostInstaller::installBrowser(SupportedBrowsers browser,
*/
void HostInstaller::updateBinaryPaths(const bool& proxy, const QString& location)
{
for (int i = 0; i < 4; ++i) {
// Where 6 is the number of entries in the SupportedBrowsers enum declared in HostInstaller.h
for (int i = 0; i < 6; ++i) {
if (checkIfInstalled(static_cast<SupportedBrowsers>(i))) {
installBrowser(static_cast<SupportedBrowsers>(i), true, proxy, location);
}
Expand All @@ -166,6 +170,8 @@ QString HostInstaller::getTargetPath(SupportedBrowsers browser) const
return TARGET_DIR_VIVALDI;
case SupportedBrowsers::TOR_BROWSER:
return TARGET_DIR_TOR_BROWSER;
case SupportedBrowsers::BRAVE:
return TARGET_DIR_BRAVE;
default:
return QString();
}
Expand All @@ -188,9 +194,11 @@ QString HostInstaller::getBrowserName(SupportedBrowsers browser) const
case SupportedBrowsers::FIREFOX:
return "firefox";
case SupportedBrowsers::VIVALDI:
return "vivaldi";
return "vivaldi";
case SupportedBrowsers::TOR_BROWSER:
return "tor-browser";
case SupportedBrowsers::BRAVE:
return "brave";
default:
return QString();
}
Expand Down
4 changes: 3 additions & 1 deletion src/browser/HostInstaller.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ class HostInstaller : public QObject
CHROMIUM = 1,
FIREFOX = 2,
VIVALDI = 3,
TOR_BROWSER = 4
TOR_BROWSER = 4,
BRAVE = 5
};

public:
Expand Down Expand Up @@ -66,6 +67,7 @@ class HostInstaller : public QObject
const QString TARGET_DIR_FIREFOX;
const QString TARGET_DIR_VIVALDI;
const QString TARGET_DIR_TOR_BROWSER;
const QString TARGET_DIR_BRAVE;
};

#endif // HOSTINSTALLER_H
18 changes: 12 additions & 6 deletions utils/keepassxc-snap-helper.sh
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,11 @@ setupVivaldi() {
INSTALL_DIR="${BASE_DIR}/.config/vivaldi/NativeMessagingHosts"
}

setupBrave() {
buildJson
INSTALL_DIR="${BASE_DIR}/.config/BraveSoftware/Brave-Browser/NativeMessagingHosts"
}

setupTorBrowser() {
buildJson "firefox"
INSTALL_DIR="${BASE_DIR}/.tor-browser/app/Browser/TorBrowser/Data/Browser/.mozilla/native-messaging-hosts"
Expand All @@ -109,9 +114,10 @@ BROWSER=$(whiptail \
"2" "Chrome" \
"3" "Chromium" \
"4" "Vivaldi" \
"5" "Tor Browser" \
"5" "Brave" \
"6" "Tor Browser" \
3>&1 1>&2 2>&3)

clear

exitstatus=$?
Expand All @@ -122,21 +128,21 @@ if [ $exitstatus = 0 ]; then
2) setupChrome ;;
3) setupChromium ;;
4) setupVivaldi ;;
5) setupTorBrowser ;;
5) setupBrave ;;
6) setupTorBrowser ;;
esac

# Install the JSON file
cd ~
mkdir -p "$INSTALL_DIR"
echo "$JSON_OUT" > ${INSTALL_DIR}/${INSTALL_FILE}

$DEBUG && echo "Installed to: ${INSTALL_DIR}/${INSTALL_FILE}"

whiptail \
--title "Installation Complete" \
--msgbox "You will need to restart your browser in order to connect to KeePassXC" \
8 50
else
whiptail --title "Installation Canceled" --msgbox "No changes were made to your system" 8 50
fi

0 comments on commit 1493943

Please sign in to comment.