mirror of
https://bitbucket.org/chromiumembedded/cef
synced 2025-06-05 21:39:12 +02:00
Add NetworkService support for chrome and chrome-devtools schemes (see issue #2622).
Known behavior changes: - Unsupported chrome hosts no longer redirect to chrome://version. To test: All tests pass with NetworkService disabled. WebUITest.* and V8Test.* tests pass with NetworkService enabled.
This commit is contained in:
@@ -4,9 +4,11 @@
|
||||
|
||||
#include "libcef/browser/resource_context.h"
|
||||
|
||||
#include "libcef/browser/net/scheme_handler.h"
|
||||
#include "libcef/browser/net/url_request_context_getter.h"
|
||||
#include "libcef/browser/thread_util.h"
|
||||
#include "libcef/common/net/scheme_registration.h"
|
||||
#include "libcef/common/net_service/util.h"
|
||||
|
||||
#include "base/i18n/case_conversion.h"
|
||||
#include "base/logging.h"
|
||||
@@ -29,7 +31,13 @@
|
||||
#endif
|
||||
|
||||
CefResourceContext::CefResourceContext(bool is_off_the_record)
|
||||
: is_off_the_record_(is_off_the_record) {}
|
||||
: is_off_the_record_(is_off_the_record) {
|
||||
// Using base::Unretained() is safe because both this callback and possible
|
||||
// deletion of |this| will execute on the IO thread, and this callback will
|
||||
// be executed first.
|
||||
CEF_POST_TASK(CEF_IOT, base::Bind(&CefResourceContext::InitOnIOThread,
|
||||
base::Unretained(this)));
|
||||
}
|
||||
|
||||
CefResourceContext::~CefResourceContext() {
|
||||
// This is normally called in the parent ResourceContext destructor, but we
|
||||
@@ -187,6 +195,7 @@ void CefResourceContext::RegisterSchemeHandlerFactory(
|
||||
const std::string& domain_name,
|
||||
CefRefPtr<CefSchemeHandlerFactory> factory) {
|
||||
CEF_REQUIRE_IOT();
|
||||
DCHECK(net_service::IsEnabled());
|
||||
|
||||
const std::string& scheme_lower = base::ToLowerASCII(scheme_name);
|
||||
std::string domain_lower;
|
||||
@@ -213,12 +222,18 @@ void CefResourceContext::RegisterSchemeHandlerFactory(
|
||||
|
||||
void CefResourceContext::ClearSchemeHandlerFactories() {
|
||||
CEF_REQUIRE_IOT();
|
||||
DCHECK(net_service::IsEnabled());
|
||||
|
||||
scheme_handler_factory_map_.clear();
|
||||
|
||||
// Restore the default internal handlers.
|
||||
scheme::RegisterInternalHandlers(this);
|
||||
}
|
||||
|
||||
CefRefPtr<CefSchemeHandlerFactory> CefResourceContext::GetSchemeHandlerFactory(
|
||||
const GURL& url) {
|
||||
CEF_REQUIRE_IOT();
|
||||
DCHECK(net_service::IsEnabled());
|
||||
|
||||
if (scheme_handler_factory_map_.empty())
|
||||
return nullptr;
|
||||
@@ -246,3 +261,12 @@ CefRefPtr<CefSchemeHandlerFactory> CefResourceContext::GetSchemeHandlerFactory(
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void CefResourceContext::InitOnIOThread() {
|
||||
CEF_REQUIRE_IOT();
|
||||
|
||||
if (net_service::IsEnabled()) {
|
||||
// Add the default internal handlers.
|
||||
scheme::RegisterInternalHandlers(this);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user