2019-03-22 23:11:51 +01:00
|
|
|
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
|
2015-02-14 00:17:08 +01:00
|
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
|
|
// found in the LICENSE file.
|
|
|
|
|
|
|
|
#include "libcef/browser/browser_context.h"
|
2019-03-22 23:11:51 +01:00
|
|
|
|
|
|
|
#include <map>
|
|
|
|
#include <utility>
|
|
|
|
|
2021-04-09 20:34:45 +02:00
|
|
|
#include "libcef/browser/context.h"
|
2020-03-19 16:34:15 +01:00
|
|
|
#include "libcef/browser/media_router/media_router_manager.h"
|
2019-03-22 23:11:51 +01:00
|
|
|
#include "libcef/browser/request_context_impl.h"
|
2015-10-17 02:44:00 +02:00
|
|
|
#include "libcef/browser/thread_util.h"
|
2019-03-22 23:11:51 +01:00
|
|
|
#include "libcef/common/cef_switches.h"
|
2021-08-19 23:07:44 +02:00
|
|
|
#include "libcef/common/frame_util.h"
|
2021-04-07 00:09:45 +02:00
|
|
|
#include "libcef/features/runtime.h"
|
2015-02-14 00:17:08 +01:00
|
|
|
|
2019-03-22 23:11:51 +01:00
|
|
|
#include "base/files/file_util.h"
|
|
|
|
#include "base/lazy_instance.h"
|
2015-02-14 00:17:08 +01:00
|
|
|
#include "base/logging.h"
|
2021-04-09 20:34:45 +02:00
|
|
|
#include "base/no_destructor.h"
|
|
|
|
#include "base/strings/string_split.h"
|
2019-03-22 23:11:51 +01:00
|
|
|
#include "base/strings/string_util.h"
|
2021-04-07 00:09:45 +02:00
|
|
|
#include "chrome/browser/profiles/profile.h"
|
2020-07-01 02:57:00 +02:00
|
|
|
#include "content/public/browser/browser_context.h"
|
2019-03-22 23:11:51 +01:00
|
|
|
#include "content/public/browser/browser_task_traits.h"
|
2015-02-14 00:17:08 +01:00
|
|
|
#include "content/public/browser/browser_thread.h"
|
2015-10-17 02:44:00 +02:00
|
|
|
#include "content/public/browser/storage_partition.h"
|
2019-03-22 23:11:51 +01:00
|
|
|
|
|
|
|
using content::BrowserThread;
|
|
|
|
|
|
|
|
namespace {
|
|
|
|
|
|
|
|
// Manages the global list of Impl instances.
|
|
|
|
class ImplManager {
|
|
|
|
public:
|
2021-12-06 21:40:25 +01:00
|
|
|
using Vector = std::vector<CefBrowserContext*>;
|
2019-03-22 23:11:51 +01:00
|
|
|
|
|
|
|
ImplManager() {}
|
2021-12-06 21:40:25 +01:00
|
|
|
|
|
|
|
ImplManager(const ImplManager&) = delete;
|
|
|
|
ImplManager& operator=(const ImplManager&) = delete;
|
|
|
|
|
2019-03-22 23:11:51 +01:00
|
|
|
~ImplManager() {
|
|
|
|
DCHECK(all_.empty());
|
|
|
|
DCHECK(map_.empty());
|
|
|
|
}
|
|
|
|
|
|
|
|
void AddImpl(CefBrowserContext* impl) {
|
|
|
|
CEF_REQUIRE_UIT();
|
|
|
|
DCHECK(!IsValidImpl(impl));
|
|
|
|
all_.push_back(impl);
|
|
|
|
}
|
|
|
|
|
|
|
|
void RemoveImpl(CefBrowserContext* impl, const base::FilePath& path) {
|
|
|
|
CEF_REQUIRE_UIT();
|
|
|
|
|
|
|
|
Vector::iterator it = GetImplPos(impl);
|
|
|
|
DCHECK(it != all_.end());
|
|
|
|
all_.erase(it);
|
|
|
|
|
|
|
|
if (!path.empty()) {
|
|
|
|
PathMap::iterator it = map_.find(path);
|
|
|
|
DCHECK(it != map_.end());
|
|
|
|
if (it != map_.end())
|
|
|
|
map_.erase(it);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bool IsValidImpl(const CefBrowserContext* impl) {
|
|
|
|
CEF_REQUIRE_UIT();
|
|
|
|
return GetImplPos(impl) != all_.end();
|
|
|
|
}
|
|
|
|
|
2021-08-19 23:07:44 +02:00
|
|
|
CefBrowserContext* GetImplFromGlobalId(
|
|
|
|
const content::GlobalRenderFrameHostId& global_id,
|
|
|
|
bool require_frame_match) {
|
2019-10-01 15:55:16 +02:00
|
|
|
CEF_REQUIRE_UIT();
|
|
|
|
for (const auto& context : all_) {
|
2021-08-19 23:07:44 +02:00
|
|
|
if (context->IsAssociatedContext(global_id, require_frame_match)) {
|
2019-10-01 15:55:16 +02:00
|
|
|
return context;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2020-07-01 02:57:00 +02:00
|
|
|
CefBrowserContext* GetImplFromBrowserContext(
|
|
|
|
const content::BrowserContext* context) {
|
2019-03-22 23:11:51 +01:00
|
|
|
CEF_REQUIRE_UIT();
|
|
|
|
if (!context)
|
2019-10-01 15:55:16 +02:00
|
|
|
return nullptr;
|
2019-03-22 23:11:51 +01:00
|
|
|
|
2020-07-01 02:57:00 +02:00
|
|
|
for (const auto& bc : all_) {
|
|
|
|
if (bc->AsBrowserContext() == context)
|
|
|
|
return bc;
|
2019-03-22 23:11:51 +01:00
|
|
|
}
|
2019-10-01 15:55:16 +02:00
|
|
|
return nullptr;
|
2019-03-22 23:11:51 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void SetImplPath(CefBrowserContext* impl, const base::FilePath& path) {
|
|
|
|
CEF_REQUIRE_UIT();
|
|
|
|
DCHECK(!path.empty());
|
|
|
|
DCHECK(IsValidImpl(impl));
|
2020-07-01 02:57:00 +02:00
|
|
|
DCHECK(GetImplFromPath(path) == nullptr);
|
2019-03-22 23:11:51 +01:00
|
|
|
map_.insert(std::make_pair(path, impl));
|
|
|
|
}
|
|
|
|
|
2020-07-01 02:57:00 +02:00
|
|
|
CefBrowserContext* GetImplFromPath(const base::FilePath& path) {
|
2019-03-22 23:11:51 +01:00
|
|
|
CEF_REQUIRE_UIT();
|
|
|
|
DCHECK(!path.empty());
|
|
|
|
PathMap::const_iterator it = map_.find(path);
|
|
|
|
if (it != map_.end())
|
|
|
|
return it->second;
|
2019-10-01 15:55:16 +02:00
|
|
|
return nullptr;
|
2019-03-22 23:11:51 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
const Vector GetAllImpl() const { return all_; }
|
|
|
|
|
|
|
|
private:
|
|
|
|
Vector::iterator GetImplPos(const CefBrowserContext* impl) {
|
|
|
|
Vector::iterator it = all_.begin();
|
|
|
|
for (; it != all_.end(); ++it) {
|
|
|
|
if (*it == impl)
|
|
|
|
return it;
|
|
|
|
}
|
|
|
|
return all_.end();
|
|
|
|
}
|
|
|
|
|
2021-12-06 21:40:25 +01:00
|
|
|
using PathMap = std::map<base::FilePath, CefBrowserContext*>;
|
2019-03-22 23:11:51 +01:00
|
|
|
PathMap map_;
|
|
|
|
|
|
|
|
Vector all_;
|
|
|
|
};
|
|
|
|
|
|
|
|
#if DCHECK_IS_ON()
|
|
|
|
// Because of DCHECK()s in the object destructor.
|
|
|
|
base::LazyInstance<ImplManager>::DestructorAtExit g_manager =
|
|
|
|
LAZY_INSTANCE_INITIALIZER;
|
|
|
|
#else
|
|
|
|
base::LazyInstance<ImplManager>::Leaky g_manager = LAZY_INSTANCE_INITIALIZER;
|
|
|
|
#endif
|
|
|
|
|
2020-03-19 16:34:15 +01:00
|
|
|
CefBrowserContext* GetSelf(base::WeakPtr<CefBrowserContext> self) {
|
|
|
|
CEF_REQUIRE_UIT();
|
|
|
|
return self.get();
|
|
|
|
}
|
|
|
|
|
2021-04-09 20:34:45 +02:00
|
|
|
CefBrowserContext::CookieableSchemes MakeSupportedSchemes(
|
|
|
|
const CefString& schemes_list,
|
|
|
|
bool include_defaults) {
|
|
|
|
std::vector<std::string> all_schemes;
|
|
|
|
if (!schemes_list.empty()) {
|
|
|
|
all_schemes =
|
|
|
|
base::SplitString(schemes_list.ToString(), std::string(","),
|
|
|
|
base::TRIM_WHITESPACE, base::SPLIT_WANT_NONEMPTY);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (include_defaults) {
|
|
|
|
// Add default schemes that should always support cookies.
|
|
|
|
// This list should match CookieMonster::kDefaultCookieableSchemes.
|
|
|
|
all_schemes.push_back("http");
|
|
|
|
all_schemes.push_back("https");
|
|
|
|
all_schemes.push_back("ws");
|
|
|
|
all_schemes.push_back("wss");
|
|
|
|
}
|
|
|
|
|
2021-07-23 18:40:13 +02:00
|
|
|
return absl::make_optional(all_schemes);
|
2021-04-09 20:34:45 +02:00
|
|
|
}
|
|
|
|
|
2019-03-22 23:11:51 +01:00
|
|
|
} // namespace
|
|
|
|
|
|
|
|
CefBrowserContext::CefBrowserContext(const CefRequestContextSettings& settings)
|
2020-03-19 16:34:15 +01:00
|
|
|
: settings_(settings), weak_ptr_factory_(this) {
|
2019-03-22 23:11:51 +01:00
|
|
|
g_manager.Get().AddImpl(this);
|
2020-03-19 16:34:15 +01:00
|
|
|
getter_ = base::BindRepeating(GetSelf, weak_ptr_factory_.GetWeakPtr());
|
2019-03-22 23:11:51 +01:00
|
|
|
}
|
2015-02-14 00:17:08 +01:00
|
|
|
|
|
|
|
CefBrowserContext::~CefBrowserContext() {
|
2019-03-22 23:11:51 +01:00
|
|
|
CEF_REQUIRE_UIT();
|
2020-07-14 19:38:13 +02:00
|
|
|
#if DCHECK_IS_ON()
|
2020-07-01 02:57:00 +02:00
|
|
|
DCHECK(is_shutdown_);
|
2020-07-14 19:38:13 +02:00
|
|
|
#endif
|
2015-02-14 00:17:08 +01:00
|
|
|
}
|
|
|
|
|
2015-07-16 23:40:01 +02:00
|
|
|
void CefBrowserContext::Initialize() {
|
2019-03-22 23:11:51 +01:00
|
|
|
cache_path_ = base::FilePath(CefString(&settings_.cache_path));
|
|
|
|
|
|
|
|
if (!cache_path_.empty())
|
|
|
|
g_manager.Get().SetImplPath(this, cache_path_);
|
|
|
|
|
2021-04-07 22:58:43 +02:00
|
|
|
iothread_state_ = base::MakeRefCounted<CefIOThreadState>();
|
2021-04-09 20:34:45 +02:00
|
|
|
|
|
|
|
if (settings_.cookieable_schemes_list.length > 0 ||
|
|
|
|
settings_.cookieable_schemes_exclude_defaults) {
|
|
|
|
cookieable_schemes_ =
|
|
|
|
MakeSupportedSchemes(CefString(&settings_.cookieable_schemes_list),
|
|
|
|
!settings_.cookieable_schemes_exclude_defaults);
|
|
|
|
}
|
2020-07-01 02:57:00 +02:00
|
|
|
}
|
2019-07-25 21:27:15 +02:00
|
|
|
|
2020-07-01 02:57:00 +02:00
|
|
|
void CefBrowserContext::Shutdown() {
|
|
|
|
CEF_REQUIRE_UIT();
|
2015-07-16 23:40:01 +02:00
|
|
|
|
2020-07-01 02:57:00 +02:00
|
|
|
#if DCHECK_IS_ON()
|
|
|
|
is_shutdown_ = true;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
// No CefRequestContext should be referencing this object any longer.
|
|
|
|
DCHECK(request_context_set_.empty());
|
|
|
|
|
|
|
|
// Unregister the context first to avoid re-entrancy during shutdown.
|
|
|
|
g_manager.Get().RemoveImpl(this, cache_path_);
|
|
|
|
|
|
|
|
// Destroy objects that may hold references to the MediaRouter.
|
|
|
|
media_router_manager_.reset();
|
2019-03-22 23:11:51 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void CefBrowserContext::AddCefRequestContext(CefRequestContextImpl* context) {
|
|
|
|
CEF_REQUIRE_UIT();
|
|
|
|
request_context_set_.insert(context);
|
2015-07-16 23:40:01 +02:00
|
|
|
}
|
|
|
|
|
2019-03-22 23:11:51 +01:00
|
|
|
void CefBrowserContext::RemoveCefRequestContext(
|
|
|
|
CefRequestContextImpl* context) {
|
2015-10-17 02:44:00 +02:00
|
|
|
CEF_REQUIRE_UIT();
|
|
|
|
|
2019-03-22 23:11:51 +01:00
|
|
|
request_context_set_.erase(context);
|
2017-12-07 22:44:24 +01:00
|
|
|
|
2019-03-22 23:11:51 +01:00
|
|
|
// Delete ourselves when the reference count reaches zero.
|
2020-07-01 02:57:00 +02:00
|
|
|
if (request_context_set_.empty()) {
|
|
|
|
Shutdown();
|
2021-07-23 21:55:22 +02:00
|
|
|
|
|
|
|
// Allow the current call stack to unwind before deleting |this|.
|
|
|
|
content::BrowserThread::DeleteSoon(CEF_UIT, FROM_HERE, this);
|
2020-07-01 02:57:00 +02:00
|
|
|
}
|
2019-03-22 23:11:51 +01:00
|
|
|
}
|
2016-08-31 13:25:56 +02:00
|
|
|
|
2019-03-22 23:11:51 +01:00
|
|
|
// static
|
2020-07-01 02:57:00 +02:00
|
|
|
CefBrowserContext* CefBrowserContext::FromCachePath(
|
2019-03-22 23:11:51 +01:00
|
|
|
const base::FilePath& cache_path) {
|
2020-07-01 02:57:00 +02:00
|
|
|
return g_manager.Get().GetImplFromPath(cache_path);
|
2019-03-22 23:11:51 +01:00
|
|
|
}
|
|
|
|
|
2019-10-01 15:55:16 +02:00
|
|
|
// static
|
2021-08-19 23:07:44 +02:00
|
|
|
CefBrowserContext* CefBrowserContext::FromGlobalId(
|
|
|
|
const content::GlobalRenderFrameHostId& global_id,
|
|
|
|
bool require_frame_match) {
|
|
|
|
return g_manager.Get().GetImplFromGlobalId(global_id, require_frame_match);
|
2019-10-01 15:55:16 +02:00
|
|
|
}
|
|
|
|
|
2019-03-22 23:11:51 +01:00
|
|
|
// static
|
2020-07-01 02:57:00 +02:00
|
|
|
CefBrowserContext* CefBrowserContext::FromBrowserContext(
|
|
|
|
const content::BrowserContext* context) {
|
|
|
|
return g_manager.Get().GetImplFromBrowserContext(context);
|
2019-03-22 23:11:51 +01:00
|
|
|
}
|
|
|
|
|
2021-04-07 00:09:45 +02:00
|
|
|
// static
|
|
|
|
CefBrowserContext* CefBrowserContext::FromProfile(const Profile* profile) {
|
|
|
|
auto* cef_context = FromBrowserContext(profile);
|
|
|
|
if (cef_context)
|
|
|
|
return cef_context;
|
|
|
|
|
|
|
|
if (cef::IsChromeRuntimeEnabled()) {
|
|
|
|
auto* original_profile = profile->GetOriginalProfile();
|
|
|
|
if (original_profile != profile) {
|
|
|
|
// With the Chrome runtime if the user launches an incognito window via
|
|
|
|
// the UI we might be associated with the original Profile instead of the
|
|
|
|
// (current) incognito profile.
|
|
|
|
return FromBrowserContext(original_profile);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2019-03-22 23:11:51 +01:00
|
|
|
// static
|
|
|
|
std::vector<CefBrowserContext*> CefBrowserContext::GetAll() {
|
|
|
|
return g_manager.Get().GetAllImpl();
|
2015-10-17 02:44:00 +02:00
|
|
|
}
|
|
|
|
|
2019-03-24 00:40:32 +01:00
|
|
|
void CefBrowserContext::OnRenderFrameCreated(
|
|
|
|
CefRequestContextImpl* request_context,
|
2021-08-19 23:07:44 +02:00
|
|
|
const content::GlobalRenderFrameHostId& global_id,
|
2019-03-24 00:40:32 +01:00
|
|
|
bool is_main_frame,
|
|
|
|
bool is_guest_view) {
|
|
|
|
CEF_REQUIRE_UIT();
|
2021-08-19 23:07:44 +02:00
|
|
|
DCHECK(frame_util::IsValidGlobalId(global_id));
|
2019-04-24 04:50:25 +02:00
|
|
|
|
2021-08-19 23:07:44 +02:00
|
|
|
render_id_set_.insert(global_id);
|
2019-10-01 15:55:16 +02:00
|
|
|
|
2019-03-24 00:40:32 +01:00
|
|
|
CefRefPtr<CefRequestContextHandler> handler = request_context->GetHandler();
|
2019-10-01 15:55:16 +02:00
|
|
|
if (handler) {
|
2021-08-19 23:07:44 +02:00
|
|
|
handler_map_.AddHandler(global_id, handler);
|
2019-10-01 15:55:16 +02:00
|
|
|
|
2021-08-19 23:07:44 +02:00
|
|
|
CEF_POST_TASK(CEF_IOT, base::BindOnce(&CefIOThreadState::AddHandler,
|
|
|
|
iothread_state_, global_id, handler));
|
2019-03-24 00:40:32 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void CefBrowserContext::OnRenderFrameDeleted(
|
|
|
|
CefRequestContextImpl* request_context,
|
2021-08-19 23:07:44 +02:00
|
|
|
const content::GlobalRenderFrameHostId& global_id,
|
2019-03-24 00:40:32 +01:00
|
|
|
bool is_main_frame,
|
|
|
|
bool is_guest_view) {
|
2017-02-14 23:27:19 +01:00
|
|
|
CEF_REQUIRE_UIT();
|
2021-08-19 23:07:44 +02:00
|
|
|
DCHECK(frame_util::IsValidGlobalId(global_id));
|
2019-04-24 04:50:25 +02:00
|
|
|
|
2021-08-19 23:07:44 +02:00
|
|
|
auto it1 = render_id_set_.find(global_id);
|
2019-10-01 15:55:16 +02:00
|
|
|
if (it1 != render_id_set_.end())
|
|
|
|
render_id_set_.erase(it1);
|
|
|
|
|
2019-03-24 00:40:32 +01:00
|
|
|
CefRefPtr<CefRequestContextHandler> handler = request_context->GetHandler();
|
2019-10-01 15:55:16 +02:00
|
|
|
if (handler) {
|
2021-08-19 23:07:44 +02:00
|
|
|
handler_map_.RemoveHandler(global_id);
|
2019-10-01 15:55:16 +02:00
|
|
|
|
2021-06-04 03:34:56 +02:00
|
|
|
CEF_POST_TASK(CEF_IOT, base::BindOnce(&CefIOThreadState::RemoveHandler,
|
2021-08-19 23:07:44 +02:00
|
|
|
iothread_state_, global_id));
|
2019-03-24 00:40:32 +01:00
|
|
|
}
|
2019-10-01 15:55:16 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
CefRefPtr<CefRequestContextHandler> CefBrowserContext::GetHandler(
|
2021-08-19 23:07:44 +02:00
|
|
|
const content::GlobalRenderFrameHostId& global_id,
|
2019-10-01 15:55:16 +02:00
|
|
|
bool require_frame_match) const {
|
|
|
|
CEF_REQUIRE_UIT();
|
2021-08-19 23:07:44 +02:00
|
|
|
return handler_map_.GetHandler(global_id, require_frame_match);
|
2019-10-01 15:55:16 +02:00
|
|
|
}
|
|
|
|
|
2021-08-19 23:07:44 +02:00
|
|
|
bool CefBrowserContext::IsAssociatedContext(
|
|
|
|
const content::GlobalRenderFrameHostId& global_id,
|
|
|
|
bool require_frame_match) const {
|
2019-10-01 15:55:16 +02:00
|
|
|
CEF_REQUIRE_UIT();
|
|
|
|
|
2021-08-19 23:07:44 +02:00
|
|
|
if (frame_util::IsValidGlobalId(global_id)) {
|
|
|
|
const auto it1 = render_id_set_.find(global_id);
|
2019-10-01 15:55:16 +02:00
|
|
|
if (it1 != render_id_set_.end())
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2021-08-19 23:07:44 +02:00
|
|
|
if (frame_util::IsValidChildId(global_id.child_id) && !require_frame_match) {
|
2019-10-01 15:55:16 +02:00
|
|
|
// Choose an arbitrary handler for the same process.
|
|
|
|
for (const auto& render_ids : render_id_set_) {
|
2021-08-19 23:07:44 +02:00
|
|
|
if (render_ids.child_id == global_id.child_id)
|
2019-10-01 15:55:16 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
2016-10-17 20:14:44 +02:00
|
|
|
}
|
|
|
|
|
2019-04-24 04:50:25 +02:00
|
|
|
void CefBrowserContext::RegisterSchemeHandlerFactory(
|
2020-07-01 02:57:00 +02:00
|
|
|
const CefString& scheme_name,
|
|
|
|
const CefString& domain_name,
|
2019-04-24 04:50:25 +02:00
|
|
|
CefRefPtr<CefSchemeHandlerFactory> factory) {
|
2021-06-04 03:34:56 +02:00
|
|
|
CEF_POST_TASK(
|
|
|
|
CEF_IOT,
|
|
|
|
base::BindOnce(&CefIOThreadState::RegisterSchemeHandlerFactory,
|
|
|
|
iothread_state_, scheme_name, domain_name, factory));
|
2019-04-24 04:50:25 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void CefBrowserContext::ClearSchemeHandlerFactories() {
|
2021-04-07 22:58:43 +02:00
|
|
|
CEF_POST_TASK(CEF_IOT,
|
2021-06-04 03:34:56 +02:00
|
|
|
base::BindOnce(&CefIOThreadState::ClearSchemeHandlerFactories,
|
|
|
|
iothread_state_));
|
2019-05-18 19:41:14 +02:00
|
|
|
}
|
|
|
|
|
2020-07-01 02:57:00 +02:00
|
|
|
void CefBrowserContext::LoadExtension(
|
|
|
|
const CefString& root_directory,
|
|
|
|
CefRefPtr<CefDictionaryValue> manifest,
|
|
|
|
CefRefPtr<CefExtensionHandler> handler,
|
|
|
|
CefRefPtr<CefRequestContext> loader_context) {
|
|
|
|
NOTIMPLEMENTED();
|
|
|
|
if (handler)
|
|
|
|
handler->OnExtensionLoadFailed(ERR_ABORTED);
|
2019-05-18 19:41:14 +02:00
|
|
|
}
|
2019-07-17 20:47:27 +02:00
|
|
|
|
2020-07-01 02:57:00 +02:00
|
|
|
bool CefBrowserContext::GetExtensions(std::vector<CefString>& extension_ids) {
|
|
|
|
NOTIMPLEMENTED();
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
CefRefPtr<CefExtension> CefBrowserContext::GetExtension(
|
|
|
|
const CefString& extension_id) {
|
|
|
|
NOTIMPLEMENTED();
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool CefBrowserContext::UnloadExtension(const CefString& extension_id) {
|
|
|
|
NOTIMPLEMENTED();
|
|
|
|
return false;
|
2019-07-17 20:47:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
bool CefBrowserContext::IsPrintPreviewSupported() const {
|
2020-07-01 02:57:00 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
network::mojom::NetworkContext* CefBrowserContext::GetNetworkContext() {
|
|
|
|
CEF_REQUIRE_UIT();
|
|
|
|
auto browser_context = AsBrowserContext();
|
2021-06-04 03:34:56 +02:00
|
|
|
return browser_context->GetDefaultStoragePartition()->GetNetworkContext();
|
2019-07-17 20:47:27 +02:00
|
|
|
}
|
2020-03-19 16:34:15 +01:00
|
|
|
|
|
|
|
CefMediaRouterManager* CefBrowserContext::GetMediaRouterManager() {
|
|
|
|
CEF_REQUIRE_UIT();
|
|
|
|
if (!media_router_manager_) {
|
2020-07-01 02:57:00 +02:00
|
|
|
media_router_manager_.reset(new CefMediaRouterManager(AsBrowserContext()));
|
2020-03-19 16:34:15 +01:00
|
|
|
}
|
|
|
|
return media_router_manager_.get();
|
|
|
|
}
|
2020-09-25 03:40:47 +02:00
|
|
|
|
|
|
|
CefBrowserContext::CookieableSchemes CefBrowserContext::GetCookieableSchemes()
|
|
|
|
const {
|
|
|
|
CEF_REQUIRE_UIT();
|
|
|
|
if (cookieable_schemes_)
|
|
|
|
return cookieable_schemes_;
|
|
|
|
|
2021-04-09 20:34:45 +02:00
|
|
|
return GetGlobalCookieableSchemes();
|
|
|
|
}
|
|
|
|
|
|
|
|
// static
|
|
|
|
CefBrowserContext::CookieableSchemes
|
|
|
|
CefBrowserContext::GetGlobalCookieableSchemes() {
|
|
|
|
CEF_REQUIRE_UIT();
|
|
|
|
|
|
|
|
static base::NoDestructor<CookieableSchemes> schemes(
|
|
|
|
[]() -> CookieableSchemes {
|
|
|
|
const auto& settings = CefContext::Get()->settings();
|
|
|
|
if (settings.cookieable_schemes_list.length > 0 ||
|
|
|
|
settings.cookieable_schemes_exclude_defaults) {
|
|
|
|
return MakeSupportedSchemes(
|
|
|
|
CefString(&settings.cookieable_schemes_list),
|
|
|
|
!settings.cookieable_schemes_exclude_defaults);
|
|
|
|
}
|
2021-06-04 03:34:56 +02:00
|
|
|
return absl::nullopt;
|
2021-04-09 20:34:45 +02:00
|
|
|
}());
|
|
|
|
return *schemes;
|
2020-09-25 03:40:47 +02:00
|
|
|
}
|