From 28a67f9957f826d1ceb9fff5bb16fe90a69570e5 Mon Sep 17 00:00:00 2001 From: Janek Bevendorff Date: Sun, 14 Jan 2018 23:50:31 +0100 Subject: [PATCH 1/3] Remove old chrome extension IDs and add new official extension ID --- src/browser/HostInstaller.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/browser/HostInstaller.cpp b/src/browser/HostInstaller.cpp index bbb5fb6f..9271da69 100644 --- a/src/browser/HostInstaller.cpp +++ b/src/browser/HostInstaller.cpp @@ -28,8 +28,7 @@ const QString HostInstaller::HOST_NAME = "org.keepassxc.keepassxc_browser"; const QStringList HostInstaller::ALLOWED_ORIGINS = QStringList() << "chrome-extension://iopaggbpplllidnfmcghoonnokmjoicf/" - << "chrome-extension://fhakpkpdnjecjfceboihdjpfmgajebii/" - << "chrome-extension://jaikbblhommnkeialomogohhdlndpfbi/"; + << "chrome-extension://oboonakemofpalcgghocfoadofidjkkk/"; const QStringList HostInstaller::ALLOWED_EXTENSIONS = QStringList() << "keepassxc-browser@keepassxc.org"; From 48ac3790c25cf0a4d3b069801c42e870e7ab3b38 Mon Sep 17 00:00:00 2001 From: Janek Bevendorff Date: Mon, 15 Jan 2018 00:09:15 +0100 Subject: [PATCH 2/3] Show "key already exists" warning only if key really exists --- src/browser/BrowserService.cpp | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/src/browser/BrowserService.cpp b/src/browser/BrowserService.cpp index 97b8fea4..b6af4e39 100644 --- a/src/browser/BrowserService.cpp +++ b/src/browser/BrowserService.cpp @@ -174,15 +174,15 @@ QString BrowserService::storeKey(const QString& key) Entry* config = getConfigEntry(true); if (!config) { - return QString(); + return {}; } - bool contains = false; + bool contains; QMessageBox::StandardButton dialogResult = QMessageBox::No; do { bool ok = false; - id = QInputDialog::getText(0, tr("KeePassXC: New key association request"), + id = QInputDialog::getText(nullptr, tr("KeePassXC: New key association request"), tr("You have received an association " "request for the above key.\n" "If you would like to allow it access " @@ -190,13 +190,17 @@ QString BrowserService::storeKey(const QString& key) "give it a unique name to identify and accept it."), QLineEdit::Normal, QString(), &ok); if (!ok || id.isEmpty()) { - return QString(); + return {}; } contains = config->attributes()->contains(QLatin1String(ASSOCIATE_KEY_PREFIX) + id); - dialogResult = QMessageBox::warning(0, tr("KeePassXC: Overwrite existing key?"), - tr("A shared encryption key with the name \"%1\" already exists.\nDo you want to overwrite it?").arg(id), - QMessageBox::Yes | QMessageBox::No); + if (contains) { + dialogResult = QMessageBox::warning(nullptr, tr("KeePassXC: Overwrite existing key?"), + tr("A shared encryption key with the name \"%1\" " + "already exists.\nDo you want to overwrite it?") + .arg(id), + QMessageBox::Yes | QMessageBox::No); + } } while (contains && dialogResult == QMessageBox::No); config->attributes()->set(QLatin1String(ASSOCIATE_KEY_PREFIX) + id, key, true); From 7665bc6c631758ecf30cd797fc34aaa47a03f45b Mon Sep 17 00:00:00 2001 From: Janek Bevendorff Date: Mon, 15 Jan 2018 01:15:39 +0100 Subject: [PATCH 3/3] Properly active key association dialog and main window upon unlock request --- src/browser/BrowserService.cpp | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/src/browser/BrowserService.cpp b/src/browser/BrowserService.cpp index b6af4e39..9e2b86cb 100644 --- a/src/browser/BrowserService.cpp +++ b/src/browser/BrowserService.cpp @@ -31,6 +31,7 @@ #include "core/Metadata.h" #include "core/Uuid.h" #include "core/PasswordGenerator.h" +#include "gui/MainWindow.h" // de887cc3-0363-43b8-974b-5911b8816224 @@ -60,11 +61,8 @@ bool BrowserService::isDatabaseOpened() const return false; } - if (dbWidget->currentMode() == DatabaseWidget::ViewMode || dbWidget->currentMode() == DatabaseWidget::EditMode) { - return true; - } + return dbWidget->currentMode() == DatabaseWidget::ViewMode || dbWidget->currentMode() == DatabaseWidget::EditMode; - return false; } bool BrowserService::openDatabase() @@ -82,7 +80,8 @@ bool BrowserService::openDatabase() return true; } - m_dbTabWidget->activateWindow(); + KEEPASSXC_MAIN_WINDOW->bringToFront(); + return false; } @@ -181,15 +180,20 @@ QString BrowserService::storeKey(const QString& key) QMessageBox::StandardButton dialogResult = QMessageBox::No; do { - bool ok = false; - id = QInputDialog::getText(nullptr, tr("KeePassXC: New key association request"), - tr("You have received an association " - "request for the above key.\n" - "If you would like to allow it access " - "to your KeePassXC database,\n" - "give it a unique name to identify and accept it."), - QLineEdit::Normal, QString(), &ok); - if (!ok || id.isEmpty()) { + QInputDialog keyDialog; + keyDialog.setWindowTitle(tr("KeePassXC: New key association request")); + keyDialog.setLabelText(tr("You have received an association request for the above key.\n\n" + "If you would like to allow it access to your KeePassXC database,\n" + "give it a unique name to identify and accept it.")); + keyDialog.setOkButtonText(tr("Save and allow access")); + keyDialog.show(); + keyDialog.activateWindow(); + keyDialog.raise(); + auto ok = keyDialog.exec(); + + id = keyDialog.textValue(); + + if (ok != QDialog::Accepted || id.isEmpty()) { return {}; }