summaryrefslogtreecommitdiffstats
path: root/src/core/autofill_client_qt.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/core/autofill_client_qt.cpp')
-rw-r--r--src/core/autofill_client_qt.cpp95
1 files changed, 40 insertions, 55 deletions
diff --git a/src/core/autofill_client_qt.cpp b/src/core/autofill_client_qt.cpp
index b599560d1..3bdc62e19 100644
--- a/src/core/autofill_client_qt.cpp
+++ b/src/core/autofill_client_qt.cpp
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2022 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtWebEngine module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2022 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#include "autofill_client_qt.h"
@@ -46,16 +10,24 @@
#include "web_contents_adapter_client.h"
#include "web_contents_view_qt.h"
-#include "base/task/thread_pool.h"
-#include "base/threading/thread_task_runner_handle.h"
#include "chrome/browser/profiles/profile.h"
#include "components/autofill/core/common/autofill_prefs.h"
#include "content/browser/web_contents/web_contents_impl.h"
+#include "services/network/public/cpp/shared_url_loader_factory.h"
namespace QtWebEngineCore {
+void AutofillClientQt::CreateForWebContents(content::WebContents *contents)
+{
+ DCHECK(contents);
+ if (!FromWebContents(contents))
+ contents->SetUserData(UserDataKey(), base::WrapUnique(new AutofillClientQt(contents)));
+}
+
AutofillClientQt::AutofillClientQt(content::WebContents *webContents)
- : content::WebContentsObserver(webContents)
+ : autofill::ContentAutofillClient(
+ webContents, base::BindRepeating(&autofill::BrowserDriverInitHook, this, ""))
+ , content::WebContentsObserver(webContents)
, m_popupController(new AutofillPopupController(new AutofillPopupControllerPrivate))
{
}
@@ -74,7 +46,7 @@ autofill::AutocompleteHistoryManager *AutofillClientQt::GetAutocompleteHistoryMa
PrefService *AutofillClientQt::GetPrefs()
{
- return const_cast<PrefService *>(base::as_const(*this).GetPrefs());
+ return const_cast<PrefService *>(std::as_const(*this).GetPrefs());
}
const PrefService *AutofillClientQt::GetPrefs() const
@@ -86,16 +58,16 @@ const PrefService *AutofillClientQt::GetPrefs() const
void AutofillClientQt::ShowAutofillPopup(const autofill::AutofillClient::PopupOpenArgs &open_args,
base::WeakPtr<autofill::AutofillPopupDelegate> delegate)
{
- // Specific popups (personal, address, credit card, password) are not supported.
- DCHECK(open_args.popup_type == autofill::PopupType::kUnspecified);
-
m_popupController->d->delegate = delegate;
m_popupController->d->suggestions = open_args.suggestions;
m_popupController->updateModel();
+ bool autoSelectFirstSuggestion =
+ open_args.trigger_source == autofill::AutofillSuggestionTriggerSource::kTextFieldDidReceiveKeyDown;
+
adapterClient()->showAutofillPopup(m_popupController.data(),
QRect(toQt(gfx::ToEnclosingRect(open_args.element_bounds))),
- open_args.autoselect_first_suggestion.value());
+ autoSelectFirstSuggestion);
}
void AutofillClientQt::UpdateAutofillPopupDataListValues(const std::vector<std::u16string> &values,
@@ -113,21 +85,21 @@ void AutofillClientQt::PinPopupView()
NOTIMPLEMENTED();
}
-autofill::AutofillClient::PopupOpenArgs AutofillClientQt::GetReopenPopupArgs() const
+autofill::AutofillClient::PopupOpenArgs AutofillClientQt::GetReopenPopupArgs(autofill::AutofillSuggestionTriggerSource trigger_source) const
{
// Called by password_manager component only.
NOTIMPLEMENTED();
return autofill::AutofillClient::PopupOpenArgs();
}
-base::span<const autofill::Suggestion> AutofillClientQt::GetPopupSuggestions() const
+std::vector<autofill::Suggestion> AutofillClientQt::GetPopupSuggestions() const
{
// Called by password_manager component only.
NOTIMPLEMENTED();
- return base::span<const autofill::Suggestion>();
+ return {};
}
-void AutofillClientQt::UpdatePopup(const std::vector<autofill::Suggestion> &, autofill::PopupType)
+void AutofillClientQt::UpdatePopup(const std::vector<autofill::Suggestion> &, autofill::PopupType, autofill::AutofillSuggestionTriggerSource)
{
// Called by password_manager component only.
NOTIMPLEMENTED();
@@ -138,13 +110,28 @@ void AutofillClientQt::HideAutofillPopup(autofill::PopupHidingReason)
adapterClient()->hideAutofillPopup();
}
-bool AutofillClientQt::IsAutocompleteEnabled()
+bool AutofillClientQt::IsAutocompleteEnabled() const
{
return autofill::prefs::IsAutocompleteEnabled(GetPrefs());
}
-void AutofillClientQt::PropagateAutofillPredictions(content::RenderFrameHost *,
- const std::vector<autofill::FormStructure *> &)
+bool AutofillClientQt::IsPasswordManagerEnabled()
+{
+ return false;
+}
+
+bool AutofillClientQt::IsOffTheRecord()
+{
+ return web_contents()->GetBrowserContext()->IsOffTheRecord();
+}
+
+scoped_refptr<network::SharedURLLoaderFactory> AutofillClientQt::GetURLLoaderFactory()
+{
+ return nullptr;
+}
+
+void AutofillClientQt::PropagateAutofillPredictionsDeprecated(autofill::AutofillDriver *,
+ const std::vector<autofill::FormStructure *> &)
{
// For testing purposes only.
NOTIMPLEMENTED();
@@ -157,6 +144,4 @@ WebContentsAdapterClient *AutofillClientQt::adapterClient()
->client();
}
-WEB_CONTENTS_USER_DATA_KEY_IMPL(AutofillClientQt);
-
} // namespace QtWebEngineCore