"popup_controller_efl.h",
"scroll_detector.cc",
"scroll_detector.h",
+ "shared_url_loader_factory_efl.cc",
+ "shared_url_loader_factory_efl.h",
"text_encoding_map_efl.cc",
"text_encoding_map_efl.h",
"url_request_context_getter_efl.cc",
#include "content/public/common/content_switches.h"
#include "common/version_info.h"
#include "common/web_contents_utils.h"
+#include "shared_url_loader_factory_efl.h"
#if defined(OS_TIZEN)
#if !defined(EWK_BRINGUP)
CommandLineEfl::AppendProcessSpecificArgs(*command_line);
}
+scoped_refptr<network::SharedURLLoaderFactory>
+ContentBrowserClientEfl::GetSystemSharedURLLoaderFactory() {
+ DCHECK_CURRENTLY_ON(BrowserThread::UI);
+ if (!shared_url_loader_factory_)
+ shared_url_loader_factory_ = new SharedURLLoaderFactoryEfl();
+
+ return shared_url_loader_factory_;
+}
+
bool ContentBrowserClientEfl::CanCreateWindow(
RenderFrameHost* opener,
const GURL& opener_url,
#if defined(ENABLE_NOTIFICATIONS)
class NotificationControllerEfl;
#endif
+class SharedURLLoaderFactoryEfl;
class WebContents;
class WebContentsView;
std::string GetUserAgent() override;
private:
+ scoped_refptr<network::SharedURLLoaderFactory>
+ GetSystemSharedURLLoaderFactory() override;
+
static void SetCertificatePemOnUIThread(int render_process_id,
int render_view_id,
std::string certificate);
BrowserContextEfl* browser_context_efl_;
+ // URLLoaderFactory backed by the NetworkContext returned by GetContext(), so
+ // consumers don't all need to create their own factory.
+ scoped_refptr<SharedURLLoaderFactoryEfl> shared_url_loader_factory_;
+
DISALLOW_COPY_AND_ASSIGN(ContentBrowserClientEfl);
};
}
--- /dev/null
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Copyright 2019 Samsung Electronics. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "shared_url_loader_factory_efl.h"
+
+#include "content/public/browser/browser_thread.h"
+#include "content/public/browser/network_service_instance.h"
+#include "services/network/public/cpp/cross_thread_pending_shared_url_loader_factory.h"
+
+namespace content {
+
+/* LCOV_EXCL_START */
+network::mojom::NetworkContextParamsPtr CreateNetworkContextParams() {
+ return network::mojom::NetworkContextParams::New();
+}
+
+void SharedURLLoaderFactoryEfl::CreateLoaderAndStart(
+ mojo::PendingReceiver<network::mojom::URLLoader> receiver,
+ int32_t routing_id,
+ int32_t request_id,
+ uint32_t options,
+ const network::ResourceRequest& url_request,
+ mojo::PendingRemote<network::mojom::URLLoaderClient> client,
+ const net::MutableNetworkTrafficAnnotationTag& traffic_annotation) {
+ DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
+ GetURLLoaderFactory()->CreateLoaderAndStart(
+ std::move(receiver), routing_id, request_id, options, url_request,
+ std::move(client), traffic_annotation);
+}
+
+void SharedURLLoaderFactoryEfl::Clone(
+ mojo::PendingReceiver<network::mojom::URLLoaderFactory> receiver) {
+ GetURLLoaderFactory()->Clone(std::move(receiver));
+}
+
+std::unique_ptr<network::PendingSharedURLLoaderFactory>
+SharedURLLoaderFactoryEfl::Clone() {
+ DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
+ return std::make_unique<network::CrossThreadPendingSharedURLLoaderFactory>(
+ this);
+}
+
+network::mojom::NetworkContext* SharedURLLoaderFactoryEfl::GetContext() {
+ if (!network_service_network_context_ ||
+ !network_service_network_context_.is_connected()) {
+ // This should call into OnNetworkServiceCreated(), which will re-create
+ // the network service, if needed. There's a chance that it won't be
+ // invoked, if the NetworkContext has encountered an error but the
+ // NetworkService has not yet noticed its pipe was closed. In that case,
+ // trying to create a new NetworkContext would fail, anyways, and hopefully
+ // a new NetworkContext will be created on the next GetContext() call.
+ content::GetNetworkService();
+ DCHECK(network_service_network_context_);
+ }
+ return network_service_network_context_.get();
+}
+
+network::mojom::URLLoaderFactory*
+SharedURLLoaderFactoryEfl::GetURLLoaderFactory() {
+ if (url_loader_factory_ && url_loader_factory_.is_connected())
+ return url_loader_factory_.get();
+
+ network::mojom::URLLoaderFactoryParamsPtr params =
+ network::mojom::URLLoaderFactoryParams::New();
+ params->process_id = network::mojom::kBrowserProcessId;
+ params->is_corb_enabled = false;
+ params->is_trusted = true;
+
+ url_loader_factory_.reset();
+ GetContext()->CreateURLLoaderFactory(
+ url_loader_factory_.BindNewPipeAndPassReceiver(), std::move(params));
+ return url_loader_factory_.get();
+}
+/* LCOV_EXCL_STOP */
+
+} // namespace content
--- /dev/null
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Copyright 2019 Samsung Electronics. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef SHARED_URL_LOADER_FACTORY_EFL_H_
+#define SHARED_URL_LOADER_FACTORY_EFL_H_
+
+#include "base/memory/ref_counted.h"
+#include "services/network/network_context.h"
+#include "services/network/public/cpp/shared_url_loader_factory.h"
+
+namespace network {
+class PendingSharedURLLoaderFactory;
+}
+
+namespace content {
+
+/* LCOV_EXCL_START */
+// SharedURLLoaderFactory its network context. Transparently handles crashes.
+class SharedURLLoaderFactoryEfl : public network::SharedURLLoaderFactory {
+ public:
+ SharedURLLoaderFactoryEfl() {}
+
+ // mojom::URLLoaderFactory implementation:
+ void CreateLoaderAndStart(mojo::PendingReceiver<network::mojom::URLLoader> receiver,
+ int32_t routing_id,
+ int32_t request_id,
+ uint32_t options,
+ const network::ResourceRequest& url_request,
+ mojo::PendingRemote<network::mojom::URLLoaderClient> client,
+ const net::MutableNetworkTrafficAnnotationTag&
+ traffic_annotation) override;
+
+ // SharedURLLoaderFactory implementation:
+ void Clone(mojo::PendingReceiver<network::mojom::URLLoaderFactory> receiver) override;
+
+ std::unique_ptr<network::PendingSharedURLLoaderFactory> Clone() override;
+
+ // Returns the System NetworkContext. May only be called after SetUp(). Does
+ // any initialization of the NetworkService that may be needed when first
+ // called.
+ network::mojom::NetworkContext* GetContext();
+
+ // Returns a URLLoaderFactory that is backed by the SystemNetworkContext.
+ // Allows sharing of the URLLoaderFactory. Prefer this to creating a new one.
+ // Call Clone() on the value returned by this method to get a URLLoaderFactory
+ // that can be used on other threads.
+ network::mojom::URLLoaderFactory* GetURLLoaderFactory();
+
+ private:
+ friend class base::RefCounted<SharedURLLoaderFactoryEfl>;
+ ~SharedURLLoaderFactoryEfl() override = default;
+
+ // NetworkContext using the network service, if the network service is
+ // enabled. mojo::NullRemote(), otherwise.
+ mojo::Remote<network::mojom::NetworkContext> network_service_network_context_;
+
+ mojo::Remote<network::mojom::URLLoaderFactory> url_loader_factory_;
+
+ DISALLOW_COPY_AND_ASSIGN(SharedURLLoaderFactoryEfl);
+};
+/* LCOV_EXCL_STOP */
+
+} // namespace content
+
+#endif