diff options
author | Peter Varga <pvarga@inf.u-szeged.hu> | 2023-02-06 14:33:16 +0100 |
---|---|---|
committer | Peter Varga <pvarga@inf.u-szeged.hu> | 2023-02-23 16:29:59 +0000 |
commit | 595e8b6a73e69c57ac7f331f0610f4b8e2c448ff (patch) | |
tree | 43a5fb05626d64edd7fca6808d1068130bfc4322 /src | |
parent | df9a9c357f3ce2298846839d24878d519903ca9f (diff) | |
download | qtwebengine-595e8b6a73e69c57ac7f331f0610f4b8e2c448ff.tar.gz |
Add Origin Trial Policy support
This makes SharedArrayBuffer available for earth.google.com
For enabling certain experimental feature for a web page, the
page provides a token in a meta tag for the browser. The token
is requested by the web developer and generated by Google. The
verification of the token happens without any server calls or
network access. See,
* http://googlechrome.github.io/OriginTrials/developer-guide.html#23-how-are-tokens-verified
* blink::TrialToken::Parse() and blink::TrialTokenValidator
implementation (//third_party/blink/common/origin_trials)
Pick-to: 6.5
Change-Id: I6f102af8efcd12b6b267dceb9de59d685fd22f9e
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Diffstat (limited to 'src')
-rw-r--r-- | src/core/configure/BUILD.root.gn.in | 1 | ||||
-rw-r--r-- | src/core/content_client_qt.cpp | 15 | ||||
-rw-r--r-- | src/core/content_client_qt.h | 11 |
3 files changed, 27 insertions, 0 deletions
diff --git a/src/core/configure/BUILD.root.gn.in b/src/core/configure/BUILD.root.gn.in index 2c6b15d4c..40b5fe602 100644 --- a/src/core/configure/BUILD.root.gn.in +++ b/src/core/configure/BUILD.root.gn.in @@ -117,6 +117,7 @@ shared_library("QtWebEngineCore") { "//components/autofill/core/browser", "//components/autofill/core/browser:buildflags", "//components/cdm/renderer", + "//components/embedder_support/origin_trials", "//components/error_page/common", "//components/favicon/content", "//components/gcm_driver", diff --git a/src/core/content_client_qt.cpp b/src/core/content_client_qt.cpp index 4a67dc029..fab8a5abb 100644 --- a/src/core/content_client_qt.cpp +++ b/src/core/content_client_qt.cpp @@ -420,4 +420,19 @@ std::u16string ContentClientQt::GetLocalizedString(int message_id) return l10n_util::GetStringUTF16(message_id); } +// This method is a copy from chrome/common/chrome_content_client.cc: +// Copyright 2012 The Chromium Authors +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE.Chromium file. +blink::OriginTrialPolicy *ContentClientQt::GetOriginTrialPolicy() +{ + // Prevent initialization race (see crbug.com/721144). There may be a + // race when the policy is needed for worker startup (which happens on a + // separate worker thread). + base::AutoLock auto_lock(origin_trial_policy_lock_); + if (!origin_trial_policy_) + origin_trial_policy_ = std::make_unique<embedder_support::OriginTrialPolicyImpl>(); + return origin_trial_policy_.get(); +} + } // namespace QtWebEngineCore diff --git a/src/core/content_client_qt.h b/src/core/content_client_qt.h index 92d41b748..f58e17f96 100644 --- a/src/core/content_client_qt.h +++ b/src/core/content_client_qt.h @@ -5,10 +5,15 @@ #define CONTENT_CLIENT_QT_H #include "qtwebenginecoreglobal_p.h" + #include "base/strings/string_piece.h" +#include "base/synchronization/lock.h" +#include "components/embedder_support/origin_trials/origin_trial_policy_impl.h" #include "content/public/common/content_client.h" #include "ui/base/layout.h" +#include <memory> + namespace QtWebEngineCore { class ContentClientQt : public content::ContentClient { @@ -24,6 +29,12 @@ public: base::RefCountedMemory* GetDataResourceBytes(int resource_id) override; gfx::Image &GetNativeImageNamed(int resource_id) override; std::u16string GetLocalizedString(int message_id) override; + blink::OriginTrialPolicy *GetOriginTrialPolicy() override; + +private: + // Used to lock when |origin_trial_policy_| is initialized. + base::Lock origin_trial_policy_lock_; + std::unique_ptr<embedder_support::OriginTrialPolicyImpl> origin_trial_policy_; }; } // namespace QtWebEngineCore |