mirror of
https://bitbucket.org/chromiumembedded/cef
synced 2025-01-07 07:42:21 +01:00
48fc0bd220
Existing CefBrowserContext functionality is now split between CefBrowserContext and AlloyBrowserContext. Runtime implementations of CefBrowserContext will provide access to the content::BrowserContext and Profile types via different inheritance paths. For example, the Alloy runtime uses ChromeProfileAlloy and the Chrome runtime uses ProfileImpl. This change also renames CefResourceContext to CefIOThreadState to more accurately represent its purpose as it no longer needs to extend content::ResourceContext.
50 lines
1.4 KiB
C++
50 lines
1.4 KiB
C++
// Copyright (c) 2012 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.
|
|
|
|
#include "libcef/browser/net/devtools_scheme_handler.h"
|
|
|
|
#include <string>
|
|
|
|
#include "libcef/browser/iothread_state.h"
|
|
#include "libcef/browser/net/internal_scheme_handler.h"
|
|
|
|
#include "base/memory/ptr_util.h"
|
|
#include "base/strings/string_util.h"
|
|
#include "content/public/browser/devtools_frontend_host.h"
|
|
#include "content/public/common/url_constants.h"
|
|
|
|
namespace scheme {
|
|
|
|
const char kChromeDevToolsHost[] = "devtools";
|
|
|
|
namespace {
|
|
|
|
class Delegate : public InternalHandlerDelegate {
|
|
public:
|
|
Delegate() {}
|
|
|
|
bool OnRequest(CefRefPtr<CefBrowser> browser,
|
|
CefRefPtr<CefRequest> request,
|
|
Action* action) override {
|
|
GURL url = GURL(request->GetURL().ToString());
|
|
std::string path = url.path();
|
|
if (path.length() > 0)
|
|
path = path.substr(1);
|
|
|
|
action->bytes =
|
|
content::DevToolsFrontendHost::GetFrontendResourceBytes(path);
|
|
return !!action->bytes;
|
|
}
|
|
};
|
|
|
|
} // namespace
|
|
|
|
void RegisterChromeDevToolsHandler(CefIOThreadState* iothread_state) {
|
|
iothread_state->RegisterSchemeHandlerFactory(
|
|
content::kChromeDevToolsScheme, kChromeDevToolsHost,
|
|
CreateInternalHandlerFactory(base::WrapUnique(new Delegate())));
|
|
}
|
|
|
|
} // namespace scheme
|