2015-02-14 00:17:08 +01:00
|
|
|
// Copyright (c) 2015 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.
|
|
|
|
|
2020-07-01 02:57:00 +02:00
|
|
|
#ifndef CEF_LIBCEF_BROWSER_IOTHREAD_STATE_H_
|
|
|
|
#define CEF_LIBCEF_BROWSER_IOTHREAD_STATE_H_
|
2015-02-14 00:17:08 +01:00
|
|
|
#pragma once
|
|
|
|
|
2024-04-30 17:45:07 +02:00
|
|
|
#include "cef/include/cef_request_context.h"
|
|
|
|
#include "cef/include/cef_request_context_handler.h"
|
|
|
|
#include "cef/include/cef_scheme.h"
|
|
|
|
#include "cef/libcef/browser/request_context_handler_map.h"
|
2021-04-07 22:58:43 +02:00
|
|
|
#include "content/public/browser/browser_thread.h"
|
|
|
|
|
2021-08-19 23:07:44 +02:00
|
|
|
namespace content {
|
|
|
|
struct GlobalRenderFrameHostId;
|
|
|
|
}
|
|
|
|
|
2019-10-01 15:55:16 +02:00
|
|
|
class GURL;
|
2015-02-14 00:17:08 +01:00
|
|
|
|
2020-07-01 02:57:00 +02:00
|
|
|
// Stores state that will be accessed on the IO thread. Life span is controlled
|
|
|
|
// by CefBrowserContext. Created on the UI thread but accessed and destroyed on
|
|
|
|
// the IO thread. See browser_context.h for an object relationship diagram.
|
2021-04-07 22:58:43 +02:00
|
|
|
class CefIOThreadState : public base::RefCountedThreadSafe<
|
|
|
|
CefIOThreadState,
|
|
|
|
content::BrowserThread::DeleteOnIOThread> {
|
2015-02-14 00:17:08 +01:00
|
|
|
public:
|
2020-07-01 02:57:00 +02:00
|
|
|
CefIOThreadState();
|
2015-02-14 00:17:08 +01:00
|
|
|
|
2021-12-06 21:40:25 +01:00
|
|
|
CefIOThreadState(const CefIOThreadState&) = delete;
|
|
|
|
CefIOThreadState& operator=(const CefIOThreadState&) = delete;
|
|
|
|
|
2019-10-01 15:55:16 +02:00
|
|
|
// See comments in CefRequestContextHandlerMap.
|
2021-08-19 23:07:44 +02:00
|
|
|
void AddHandler(const content::GlobalRenderFrameHostId& global_id,
|
2019-03-24 00:40:32 +01:00
|
|
|
CefRefPtr<CefRequestContextHandler> handler);
|
2021-08-19 23:07:44 +02:00
|
|
|
void RemoveHandler(const content::GlobalRenderFrameHostId& global_id);
|
2019-10-01 15:55:16 +02:00
|
|
|
CefRefPtr<CefRequestContextHandler> 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;
|
2016-10-17 20:14:44 +02:00
|
|
|
|
2019-04-24 04:50:25 +02:00
|
|
|
// Manage scheme handler factories associated with this context.
|
|
|
|
void RegisterSchemeHandlerFactory(const std::string& scheme_name,
|
|
|
|
const std::string& domain_name,
|
|
|
|
CefRefPtr<CefSchemeHandlerFactory> factory);
|
|
|
|
void ClearSchemeHandlerFactories();
|
|
|
|
CefRefPtr<CefSchemeHandlerFactory> GetSchemeHandlerFactory(const GURL& url);
|
|
|
|
|
2015-02-14 00:17:08 +01:00
|
|
|
private:
|
2021-04-07 22:58:43 +02:00
|
|
|
friend struct content::BrowserThread::DeleteOnThread<
|
|
|
|
content::BrowserThread::IO>;
|
|
|
|
friend class base::DeleteHelper<CefIOThreadState>;
|
|
|
|
|
|
|
|
~CefIOThreadState();
|
|
|
|
|
2019-10-01 15:55:16 +02:00
|
|
|
// Map IDs to CefRequestContextHandler objects.
|
|
|
|
CefRequestContextHandlerMap handler_map_;
|
2016-10-17 20:14:44 +02:00
|
|
|
|
2019-04-24 04:50:25 +02:00
|
|
|
// Map (scheme, domain) to factories.
|
2021-12-06 21:40:25 +01:00
|
|
|
using SchemeHandlerFactoryMap = std::map<std::pair<std::string, std::string>,
|
|
|
|
CefRefPtr<CefSchemeHandlerFactory>>;
|
2019-04-24 04:50:25 +02:00
|
|
|
SchemeHandlerFactoryMap scheme_handler_factory_map_;
|
2015-02-14 00:17:08 +01:00
|
|
|
};
|
|
|
|
|
2020-07-01 02:57:00 +02:00
|
|
|
#endif // CEF_LIBCEF_BROWSER_IOTHREAD_STATE_H_
|