2012-06-19 18:29:49 +02:00
|
|
|
// 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 "base/logging.h"
|
2020-07-08 19:23:29 +02:00
|
|
|
#include "base/notreached.h"
|
2024-04-30 17:45:07 +02:00
|
|
|
#include "cef/include/cef_urlrequest.h"
|
|
|
|
#include "cef/libcef/browser/net_service/browser_urlrequest_impl.h"
|
|
|
|
#include "cef/libcef/common/app_manager.h"
|
|
|
|
#include "cef/libcef/common/task_runner_impl.h"
|
2012-06-19 18:29:49 +02:00
|
|
|
#include "content/public/common/content_client.h"
|
|
|
|
|
|
|
|
// static
|
|
|
|
CefRefPtr<CefURLRequest> CefURLRequest::Create(
|
2017-05-17 11:29:28 +02:00
|
|
|
CefRefPtr<CefRequest> request,
|
|
|
|
CefRefPtr<CefURLRequestClient> client,
|
|
|
|
CefRefPtr<CefRequestContext> request_context) {
|
2012-06-19 18:29:49 +02:00
|
|
|
if (!request.get() || !client.get()) {
|
2023-05-08 17:07:57 +02:00
|
|
|
DCHECK(false) << "called with invalid parameters";
|
2020-01-15 14:36:24 +01:00
|
|
|
return nullptr;
|
2012-06-19 18:29:49 +02:00
|
|
|
}
|
|
|
|
|
2017-09-21 13:57:40 +02:00
|
|
|
if (!CefTaskRunnerImpl::GetCurrentTaskRunner()) {
|
2023-05-08 17:07:57 +02:00
|
|
|
DCHECK(false) << "called on invalid thread";
|
2020-01-15 14:36:24 +01:00
|
|
|
return nullptr;
|
2012-06-19 18:29:49 +02:00
|
|
|
}
|
|
|
|
|
2020-06-28 23:05:36 +02:00
|
|
|
auto content_client = CefAppManager::Get()->GetContentClient();
|
|
|
|
if (content_client->browser()) {
|
2012-06-19 18:29:49 +02:00
|
|
|
// In the browser process.
|
2019-07-29 23:27:12 +02:00
|
|
|
CefRefPtr<CefBrowserURLRequest> impl =
|
|
|
|
new CefBrowserURLRequest(nullptr, request, client, request_context);
|
2023-01-02 23:59:03 +01:00
|
|
|
if (impl->Start()) {
|
2019-07-29 23:27:12 +02:00
|
|
|
return impl.get();
|
2023-01-02 23:59:03 +01:00
|
|
|
}
|
2020-01-15 14:36:24 +01:00
|
|
|
return nullptr;
|
2012-06-19 18:29:49 +02:00
|
|
|
} else {
|
2023-05-08 17:07:57 +02:00
|
|
|
DCHECK(false) << "called in unsupported process";
|
2020-01-15 14:36:24 +01:00
|
|
|
return nullptr;
|
2012-06-19 18:29:49 +02:00
|
|
|
}
|
|
|
|
}
|