summaryrefslogtreecommitdiffstats
path: root/src/core/net
diff options
context:
space:
mode:
Diffstat (limited to 'src/core/net')
-rw-r--r--src/core/net/restricted_cookie_manager_qt.cpp184
-rw-r--r--src/core/net/restricted_cookie_manager_qt.h100
-rw-r--r--src/core/net/ssl_host_state_delegate_qt.cpp4
-rw-r--r--src/core/net/ssl_host_state_delegate_qt.h4
-rw-r--r--src/core/net/webui_controller_factory_qt.cpp8
-rw-r--r--src/core/net/webui_controller_factory_qt.h8
6 files changed, 296 insertions, 12 deletions
diff --git a/src/core/net/restricted_cookie_manager_qt.cpp b/src/core/net/restricted_cookie_manager_qt.cpp
new file mode 100644
index 000000000..e01969f4d
--- /dev/null
+++ b/src/core/net/restricted_cookie_manager_qt.cpp
@@ -0,0 +1,184 @@
+/****************************************************************************
+**
+** Copyright (C) 2019 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$
+**
+****************************************************************************/
+
+// originally based on android_webview/browser/network_service/aw_proxying_restricted_cookie_manager.cc:
+// Copyright 2019 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "restricted_cookie_manager_qt.h"
+
+#include "api/qwebenginecookiestore.h"
+#include "api/qwebenginecookiestore_p.h"
+#include "profile_adapter.h"
+#include "profile_qt.h"
+#include "type_conversion.h"
+
+#include "base/memory/ptr_util.h"
+#include "base/task/post_task.h"
+#include "content/public/browser/browser_task_traits.h"
+#include "content/public/browser/browser_thread.h"
+#include "mojo/public/cpp/bindings/strong_binding.h"
+
+namespace QtWebEngineCore {
+
+class RestrictedCookieManagerListenerQt : public network::mojom::CookieChangeListener {
+public:
+ RestrictedCookieManagerListenerQt(const GURL &url,
+ const GURL &site_for_cookies,
+ base::WeakPtr<RestrictedCookieManagerQt> restricted_cookie_manager,
+ network::mojom::CookieChangeListenerPtr client_listener)
+ : url_(url)
+ , site_for_cookies_(site_for_cookies)
+ , restricted_cookie_manager_(restricted_cookie_manager)
+ , client_listener_(std::move(client_listener))
+ {}
+
+ void OnCookieChange(const net::CanonicalCookie &cookie, network::mojom::CookieChangeCause cause) override
+ {
+ if (restricted_cookie_manager_ && restricted_cookie_manager_->allowCookies(url_, site_for_cookies_))
+ client_listener_->OnCookieChange(cookie, cause);
+ }
+
+private:
+ const GURL url_;
+ const GURL site_for_cookies_;
+ base::WeakPtr<RestrictedCookieManagerQt> restricted_cookie_manager_;
+ network::mojom::CookieChangeListenerPtr client_listener_;
+};
+
+RestrictedCookieManagerQt::RestrictedCookieManagerQt(base::WeakPtr<ProfileIODataQt> profileIoData,
+ network::mojom::RestrictedCookieManagerRole role,
+ net::CookieStore *cookie_store,
+ network::CookieSettings *cookie_settings,
+ const url::Origin &origin,
+ bool is_service_worker,
+ int32_t process_id,
+ int32_t frame_id)
+ : network::RestrictedCookieManager(role, cookie_store, cookie_settings, origin,
+ nullptr, is_service_worker, process_id, frame_id)
+ , m_profileIoData(profileIoData)
+ , weak_factory_(this)
+{
+ DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
+}
+
+RestrictedCookieManagerQt::~RestrictedCookieManagerQt()
+{
+ DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
+}
+
+void RestrictedCookieManagerQt::GetAllForUrl(const GURL &url,
+ const GURL &site_for_cookies,
+ network::mojom::CookieManagerGetOptionsPtr options,
+ GetAllForUrlCallback callback)
+{
+ DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
+
+ if (allowCookies(url, site_for_cookies)) {
+ network::RestrictedCookieManager::GetAllForUrl(url, site_for_cookies, std::move(options), std::move(callback));
+ } else {
+ std::move(callback).Run(std::vector<net::CanonicalCookie>());
+ }
+}
+
+void RestrictedCookieManagerQt::SetCanonicalCookie(const net::CanonicalCookie &cookie,
+ const GURL &url,
+ const GURL &site_for_cookies,
+ SetCanonicalCookieCallback callback)
+{
+ DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
+
+ if (allowCookies(url, site_for_cookies)) {
+ network::RestrictedCookieManager::SetCanonicalCookie(cookie, url, site_for_cookies, std::move(callback));
+ } else {
+ std::move(callback).Run(false);
+ }
+}
+
+void RestrictedCookieManagerQt::AddChangeListener(const GURL &url,
+ const GURL &site_for_cookies,
+ network::mojom::CookieChangeListenerPtr listener,
+ AddChangeListenerCallback callback)
+{
+ DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
+
+ network::mojom::CookieChangeListenerPtr proxy_listener_ptr;
+ auto proxy_listener =
+ std::make_unique<RestrictedCookieManagerListenerQt>(
+ url, site_for_cookies, weak_factory_.GetWeakPtr(),
+ std::move(listener));
+
+ mojo::MakeStrongBinding(std::move(proxy_listener),
+ mojo::MakeRequest(&proxy_listener_ptr));
+
+ network::RestrictedCookieManager::AddChangeListener(
+ url, site_for_cookies, std::move(proxy_listener_ptr),
+ std::move(callback));
+}
+
+void RestrictedCookieManagerQt::GetCookiesString(const GURL &url,
+ const GURL &site_for_cookies,
+ GetCookiesStringCallback callback)
+{
+ DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
+
+ if (allowCookies(url, site_for_cookies)) {
+ network::RestrictedCookieManager::GetCookiesString(url, site_for_cookies, std::move(callback));
+ } else {
+ std::move(callback).Run("");
+ }
+}
+
+void RestrictedCookieManagerQt::CookiesEnabledFor(const GURL &url,
+ const GURL &site_for_cookies,
+ CookiesEnabledForCallback callback)
+{
+ DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
+ std::move(callback).Run(allowCookies(url, site_for_cookies));
+}
+
+bool RestrictedCookieManagerQt::allowCookies(const GURL &url, const GURL &site_for_cookies) const
+{
+ if (!m_profileIoData)
+ return false;
+ return m_profileIoData->canGetCookies(toQt(site_for_cookies), toQt(url));
+}
+
+} // namespace QtWebEngineCore
diff --git a/src/core/net/restricted_cookie_manager_qt.h b/src/core/net/restricted_cookie_manager_qt.h
new file mode 100644
index 000000000..a277c7c96
--- /dev/null
+++ b/src/core/net/restricted_cookie_manager_qt.h
@@ -0,0 +1,100 @@
+/****************************************************************************
+**
+** Copyright (C) 2019 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$
+**
+****************************************************************************/
+
+#ifndef RESTRICTED_COOKIE_MANAGER_QT_H
+#define RESTRICTED_COOKIE_MANAGER_QT_H
+
+#include "base/macros.h"
+#include "base/memory/weak_ptr.h"
+#include "services/network/restricted_cookie_manager.h"
+#include "url/gurl.h"
+
+namespace QtWebEngineCore {
+
+class ProfileIODataQt;
+
+class RestrictedCookieManagerQt : public network::RestrictedCookieManager
+{
+public:
+ RestrictedCookieManagerQt(base::WeakPtr<ProfileIODataQt> profileIoData,
+ network::mojom::RestrictedCookieManagerRole role,
+ net::CookieStore *cookie_store,
+ network::CookieSettings *cookie_settings,
+ const url::Origin &origin,
+ bool is_service_worker,
+ int32_t process_id,
+ int32_t frame_id);
+ ~RestrictedCookieManagerQt() override;
+
+ // network::mojom::RestrictedCookieManager interface:
+ void GetAllForUrl(const GURL &url,
+ const GURL &site_for_cookies,
+ network::mojom::CookieManagerGetOptionsPtr options,
+ GetAllForUrlCallback callback) override;
+ void SetCanonicalCookie(const net::CanonicalCookie& cookie,
+ const GURL &url,
+ const GURL &site_for_cookies,
+ SetCanonicalCookieCallback callback) override;
+ void AddChangeListener(const GURL &url,
+ const GURL &site_for_cookies,
+ network::mojom::CookieChangeListenerPtr listener,
+ AddChangeListenerCallback callback) override;
+
+ void GetCookiesString(const GURL &url,
+ const GURL &site_for_cookies,
+ GetCookiesStringCallback callback) override;
+
+ void CookiesEnabledFor(const GURL &url,
+ const GURL &site_for_cookies,
+ CookiesEnabledForCallback callback) override;
+
+ // Internal:
+ bool allowCookies(const GURL& url, const GURL &site_for_cookies) const;
+
+private:
+ base::WeakPtr<ProfileIODataQt> m_profileIoData;
+
+ base::WeakPtrFactory<RestrictedCookieManagerQt> weak_factory_;
+
+ DISALLOW_COPY_AND_ASSIGN(RestrictedCookieManagerQt);
+};
+
+} // namespace QtWebEngineCore
+
+#endif // RESTRICTED_COOKIE_MANAGER_QT_H
diff --git a/src/core/net/ssl_host_state_delegate_qt.cpp b/src/core/net/ssl_host_state_delegate_qt.cpp
index ecc3c681e..b6cdf68dc 100644
--- a/src/core/net/ssl_host_state_delegate_qt.cpp
+++ b/src/core/net/ssl_host_state_delegate_qt.cpp
@@ -120,7 +120,7 @@ void SSLHostStateDelegateQt::HostRanInsecureContent(const std::string &host, int
}
// Returns whether the specified host ran insecure content.
-bool SSLHostStateDelegateQt::DidHostRunInsecureContent(const std::string &host, int pid, InsecureContentType content_type) const
+bool SSLHostStateDelegateQt::DidHostRunInsecureContent(const std::string &host, int pid, InsecureContentType content_type)
{
return false;
}
@@ -136,7 +136,7 @@ void SSLHostStateDelegateQt::RevokeUserAllowExceptions(const std::string &host)
// |host|. This does not mean that *all* certificate errors are allowed, just
// that there exists an exception. To see if a particular certificate and
// error combination exception is allowed, use QueryPolicy().
-bool SSLHostStateDelegateQt::HasAllowException(const std::string &host) const
+bool SSLHostStateDelegateQt::HasAllowException(const std::string &host)
{
auto policy_iterator = m_certPolicyforHost.find(host);
return policy_iterator != m_certPolicyforHost.end() &&
diff --git a/src/core/net/ssl_host_state_delegate_qt.h b/src/core/net/ssl_host_state_delegate_qt.h
index b1b49bcf3..28e239304 100644
--- a/src/core/net/ssl_host_state_delegate_qt.h
+++ b/src/core/net/ssl_host_state_delegate_qt.h
@@ -69,9 +69,9 @@ public:
CertJudgment QueryPolicy(const std::string &host, const net::X509Certificate &cert,
int error, bool *expired_previous_decision) override;
void HostRanInsecureContent(const std::string& host, int child_id, InsecureContentType content_type) override;
- bool DidHostRunInsecureContent(const std::string& host, int child_id, InsecureContentType content_type) const override;
+ bool DidHostRunInsecureContent(const std::string& host, int child_id, InsecureContentType content_type) override;
void RevokeUserAllowExceptions(const std::string &host) override;
- bool HasAllowException(const std::string &host) const override;
+ bool HasAllowException(const std::string &host) override;
private:
std::map<std::string, CertPolicy> m_certPolicyforHost;
diff --git a/src/core/net/webui_controller_factory_qt.cpp b/src/core/net/webui_controller_factory_qt.cpp
index 92bb8854f..2bfd242e7 100644
--- a/src/core/net/webui_controller_factory_qt.cpp
+++ b/src/core/net/webui_controller_factory_qt.cpp
@@ -175,24 +175,24 @@ WebUIFactoryFunction GetWebUIFactoryFunction(WebUI *web_ui, Profile *profile, co
namespace QtWebEngineCore {
-WebUI::TypeID WebUIControllerFactoryQt::GetWebUIType(content::BrowserContext *browser_context, const GURL &url) const
+WebUI::TypeID WebUIControllerFactoryQt::GetWebUIType(content::BrowserContext *browser_context, const GURL &url)
{
Profile *profile = Profile::FromBrowserContext(browser_context);
WebUIFactoryFunction function = GetWebUIFactoryFunction(nullptr, profile, url);
return function ? reinterpret_cast<WebUI::TypeID>(function) : WebUI::kNoWebUI;
}
-bool WebUIControllerFactoryQt::UseWebUIForURL(content::BrowserContext *browser_context, const GURL &url) const
+bool WebUIControllerFactoryQt::UseWebUIForURL(content::BrowserContext *browser_context, const GURL &url)
{
return GetWebUIType(browser_context, url) != WebUI::kNoWebUI;
}
-bool WebUIControllerFactoryQt::UseWebUIBindingsForURL(content::BrowserContext *browser_context, const GURL &url) const
+bool WebUIControllerFactoryQt::UseWebUIBindingsForURL(content::BrowserContext *browser_context, const GURL &url)
{
return UseWebUIForURL(browser_context, url);
}
-std::unique_ptr<WebUIController> WebUIControllerFactoryQt::CreateWebUIControllerForURL(WebUI *web_ui, const GURL &url) const
+std::unique_ptr<WebUIController> WebUIControllerFactoryQt::CreateWebUIControllerForURL(WebUI *web_ui, const GURL &url)
{
Profile *profile = Profile::FromWebUI(web_ui);
WebUIFactoryFunction function = GetWebUIFactoryFunction(web_ui, profile, url);
diff --git a/src/core/net/webui_controller_factory_qt.h b/src/core/net/webui_controller_factory_qt.h
index 4038e6538..20ea62193 100644
--- a/src/core/net/webui_controller_factory_qt.h
+++ b/src/core/net/webui_controller_factory_qt.h
@@ -57,10 +57,10 @@ namespace QtWebEngineCore {
class WebUIControllerFactoryQt : public content::WebUIControllerFactory {
public:
- content::WebUI::TypeID GetWebUIType(content::BrowserContext *browserContext, const GURL &url) const override;
- bool UseWebUIForURL(content::BrowserContext *browserContext, const GURL &url) const override;
- bool UseWebUIBindingsForURL(content::BrowserContext *browserContext, const GURL &url) const override;
- std::unique_ptr<content::WebUIController> CreateWebUIControllerForURL(content::WebUI *webUi, const GURL &url) const override;
+ content::WebUI::TypeID GetWebUIType(content::BrowserContext *browserContext, const GURL &url) override;
+ bool UseWebUIForURL(content::BrowserContext *browserContext, const GURL &url) override;
+ bool UseWebUIBindingsForURL(content::BrowserContext *browserContext, const GURL &url) override;
+ std::unique_ptr<content::WebUIController> CreateWebUIControllerForURL(content::WebUI *webUi, const GURL &url) override;
static WebUIControllerFactoryQt *GetInstance();