• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /// Copyright (c) 2013 The Chromium Embedded Framework Authors.
2 // Portions (c) 2011 The Chromium Authors. All rights reserved.
3 // Use of this source code is governed by a BSD-style license that can be
4 // found in the LICENSE file.
5 
6 #include "libcef/renderer/alloy/alloy_render_thread_observer.h"
7 
8 #include "libcef/common/net/net_resource_provider.h"
9 
10 #include "base/no_destructor.h"
11 #include "net/base/net_module.h"
12 #include "services/service_manager/public/cpp/connector.h"
13 #include "third_party/blink/public/common/associated_interfaces/associated_interface_registry.h"
14 
15 namespace {
16 
GetDynamicConfigParams()17 chrome::mojom::DynamicParams* GetDynamicConfigParams() {
18   static base::NoDestructor<chrome::mojom::DynamicParams> dynamic_params;
19   return dynamic_params.get();
20 }
21 
22 }  // namespace
23 
24 bool AlloyRenderThreadObserver::is_incognito_process_ = false;
25 
AlloyRenderThreadObserver()26 AlloyRenderThreadObserver::AlloyRenderThreadObserver() {
27   net::NetModule::SetResourceProvider(NetResourceProvider);
28 }
29 
~AlloyRenderThreadObserver()30 AlloyRenderThreadObserver::~AlloyRenderThreadObserver() {}
31 
32 // static
33 const chrome::mojom::DynamicParams&
GetDynamicParams()34 AlloyRenderThreadObserver::GetDynamicParams() {
35   return *GetDynamicConfigParams();
36 }
37 
RegisterMojoInterfaces(blink::AssociatedInterfaceRegistry * associated_interfaces)38 void AlloyRenderThreadObserver::RegisterMojoInterfaces(
39     blink::AssociatedInterfaceRegistry* associated_interfaces) {
40   associated_interfaces->AddInterface(base::Bind(
41       &AlloyRenderThreadObserver::OnRendererConfigurationAssociatedRequest,
42       base::Unretained(this)));
43 }
44 
UnregisterMojoInterfaces(blink::AssociatedInterfaceRegistry * associated_interfaces)45 void AlloyRenderThreadObserver::UnregisterMojoInterfaces(
46     blink::AssociatedInterfaceRegistry* associated_interfaces) {
47   associated_interfaces->RemoveInterface(
48       chrome::mojom::RendererConfiguration::Name_);
49 }
50 
SetInitialConfiguration(bool is_incognito_process,mojo::PendingReceiver<chrome::mojom::ChromeOSListener> chromeos_listener)51 void AlloyRenderThreadObserver::SetInitialConfiguration(
52     bool is_incognito_process,
53     mojo::PendingReceiver<chrome::mojom::ChromeOSListener> chromeos_listener) {
54   is_incognito_process_ = is_incognito_process;
55 }
56 
SetConfiguration(chrome::mojom::DynamicParamsPtr params)57 void AlloyRenderThreadObserver::SetConfiguration(
58     chrome::mojom::DynamicParamsPtr params) {
59   *GetDynamicConfigParams() = std::move(*params);
60 }
61 
SetContentSettingRules(const RendererContentSettingRules & rules)62 void AlloyRenderThreadObserver::SetContentSettingRules(
63     const RendererContentSettingRules& rules) {}
64 
OnRendererConfigurationAssociatedRequest(mojo::PendingAssociatedReceiver<chrome::mojom::RendererConfiguration> receiver)65 void AlloyRenderThreadObserver::OnRendererConfigurationAssociatedRequest(
66     mojo::PendingAssociatedReceiver<chrome::mojom::RendererConfiguration>
67         receiver) {
68   renderer_configuration_receivers_.Add(this, std::move(receiver));
69 }
70