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
|
|
|
|
|
2017-08-04 00:55:19 +02:00
|
|
|
#include "include/cef_request_context.h"
|
2015-09-25 13:59:30 +02:00
|
|
|
#include "include/cef_request_context_handler.h"
|
2019-07-29 23:27:12 +02:00
|
|
|
#include "include/cef_scheme.h"
|
2015-09-25 13:59:30 +02:00
|
|
|
|
2019-10-01 15:55:16 +02:00
|
|
|
#include "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
|
|
|
|
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-04-30 22:45:13 +02:00
|
|
|
void InitOnIOThread();
|
|
|
|
|
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.
|
|
|
|
typedef std::map<std::pair<std::string, std::string>,
|
|
|
|
CefRefPtr<CefSchemeHandlerFactory>>
|
|
|
|
SchemeHandlerFactoryMap;
|
|
|
|
SchemeHandlerFactoryMap scheme_handler_factory_map_;
|
|
|
|
|
2020-07-01 02:57:00 +02:00
|
|
|
DISALLOW_COPY_AND_ASSIGN(CefIOThreadState);
|
2015-02-14 00:17:08 +01:00
|
|
|
};
|
|
|
|
|
2020-07-01 02:57:00 +02:00
|
|
|
#endif // CEF_LIBCEF_BROWSER_IOTHREAD_STATE_H_
|