• 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::BindRepeating(
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,mojo::PendingRemote<content_settings::mojom::ContentSettingsManager> content_settings_manager)51 void AlloyRenderThreadObserver::SetInitialConfiguration(
52     bool is_incognito_process,
53     mojo::PendingReceiver<chrome::mojom::ChromeOSListener> chromeos_listener,
54     mojo::PendingRemote<content_settings::mojom::ContentSettingsManager>
55         content_settings_manager) {
56   is_incognito_process_ = is_incognito_process;
57 }
58 
SetConfiguration(chrome::mojom::DynamicParamsPtr params)59 void AlloyRenderThreadObserver::SetConfiguration(
60     chrome::mojom::DynamicParamsPtr params) {
61   *GetDynamicConfigParams() = std::move(*params);
62 }
63 
SetContentSettingRules(const RendererContentSettingRules & rules)64 void AlloyRenderThreadObserver::SetContentSettingRules(
65     const RendererContentSettingRules& rules) {}
66 
OnRendererConfigurationAssociatedRequest(mojo::PendingAssociatedReceiver<chrome::mojom::RendererConfiguration> receiver)67 void AlloyRenderThreadObserver::OnRendererConfigurationAssociatedRequest(
68     mojo::PendingAssociatedReceiver<chrome::mojom::RendererConfiguration>
69         receiver) {
70   renderer_configuration_receivers_.Add(this, std::move(receiver));
71 }
72