cef/libcef/browser/net/url_request_manager.h
Marshall Greenblatt a23e845244 Remove methods that modify cookie storage at runtime (see issue #2622).
This change removes cookie and request handler functionality that will not
supported by the NetworkService. Specifically, it is no longer possible to
change cookie storage locations at runime by returning a different
CefCookieManager for an already initialized CefRequestContext. After this change
you will need to use a separate CefRequestContext when creating a CefBrowser if
you require separate cookie storage.

The following methods have been removed:
- CefCookieManager::CreateManager
- CefCookieManager::GetBlockingManager
- CefCookieManager::SetStoragePath
- CefRequestContextHandler::GetCookieManager

The following methods have been renamed:
- CefRequestContext::GetDefaultCookieManager to GetCookieManager.

This change substantially simplifies the network implementation in CEF because
it is no longer necessary to proxy objects that are normally owned by Chromium.
Chromium patches that are no longer necessary will be removed as a follow-up
commit.

To test: Verify that `ceftests --gtest_filter=-PluginTest.*` pass with
NetworkService disabled. Plugin tests will be fixed in a follow-up commit.
2019-03-24 16:45:06 -04:00

82 lines
2.8 KiB
C++

// Copyright (c) 2015 The Chromium Embedded Framework Authors. All rights
// reserved. Use of this source code is governed by a BSD-style license that can
// be found in the LICENSE file.
#ifndef CEF_LIBCEF_BROWSER_NET_URL_REQUEST_MANAGER_H_
#define CEF_LIBCEF_BROWSER_NET_URL_REQUEST_MANAGER_H_
#pragma once
#include <map>
#include "include/cef_scheme.h"
namespace net {
class NetworkDelegate;
class URLRequest;
class URLRequestJob;
class URLRequestJobFactoryImpl;
} // namespace net
class CefProtocolHandler;
// Class that manages CefSchemeHandlerFactory instances. Only accessed on the IO
// thread.
class CefURLRequestManager {
public:
explicit CefURLRequestManager(net::URLRequestJobFactoryImpl* job_factory);
~CefURLRequestManager();
// Add |factory| for the specified |scheme| and |domain|. See documentation on
// CefRequestContext::RegisterSchemeHandlerFactory() for usage.
bool AddFactory(const std::string& scheme,
const std::string& domain,
CefRefPtr<CefSchemeHandlerFactory> factory);
// Remove all factories associated with the specified |scheme| and |domain|.
void RemoveFactory(const std::string& scheme, const std::string& domain);
// Clear all the existing URL handlers and unregister the ProtocolFactory.
void ClearFactories();
// Helper for chaining ProtocolHandler implementations.
net::URLRequestJob* GetRequestJob(net::URLRequest* request,
net::NetworkDelegate* network_delegate);
private:
friend class CefProtocolHandler;
// Add or remove the protocol handler if necessary. |scheme| will already be
// in lower case.
void SetProtocolHandlerIfNecessary(const std::string& scheme, bool add);
// Returns true if any factory currently exists for |scheme|. |scheme| will
// already be in lower case.
bool HasFactory(const std::string& scheme);
// Retrieve the matching handler factory, if any. |scheme| will already be in
// lower case.
CefRefPtr<CefSchemeHandlerFactory> GetHandlerFactory(
net::URLRequest* request,
const std::string& scheme);
// Create the job that will handle the request. |scheme| will already be in
// lower case.
net::URLRequestJob* GetRequestJob(net::URLRequest* request,
net::NetworkDelegate* network_delegate,
const std::string& scheme);
// Life span of |job_factory_| is guaranteed by
// CefURLRequestContextGetter which also owns this object.
net::URLRequestJobFactoryImpl* job_factory_;
// Map (scheme, domain) to factories.
typedef std::map<std::pair<std::string, std::string>,
CefRefPtr<CefSchemeHandlerFactory>>
HandlerMap;
HandlerMap handler_map_;
DISALLOW_COPY_AND_ASSIGN(CefURLRequestManager);
};
#endif // CEF_LIBCEF_BROWSER_NET_URL_REQUEST_MANAGER_H_