page_specific_content_settings_delegate.cc 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. // Copyright 2020 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. #include "weblayer/browser/page_specific_content_settings_delegate.h"
  5. #include "base/callback_helpers.h"
  6. #include "base/feature_list.h"
  7. #include "components/content_settings/core/common/content_settings.h"
  8. #include "components/permissions/permission_decision_auto_blocker.h"
  9. #include "content/public/browser/render_process_host.h"
  10. #include "content/public/common/content_features.h"
  11. #include "ipc/ipc_channel_proxy.h"
  12. #include "mojo/public/cpp/bindings/associated_remote.h"
  13. #include "weblayer/browser/browser_context_impl.h"
  14. #include "weblayer/browser/content_settings_manager_delegate.h"
  15. #include "weblayer/browser/host_content_settings_map_factory.h"
  16. #include "weblayer/browser/permissions/permission_decision_auto_blocker_factory.h"
  17. #include "weblayer/common/renderer_configuration.mojom.h"
  18. namespace weblayer {
  19. PageSpecificContentSettingsDelegate::PageSpecificContentSettingsDelegate(
  20. content::WebContents* web_contents)
  21. : web_contents_(web_contents) {}
  22. PageSpecificContentSettingsDelegate::~PageSpecificContentSettingsDelegate() =
  23. default;
  24. // static
  25. void PageSpecificContentSettingsDelegate::InitializeRenderer(
  26. content::RenderProcessHost* process) {
  27. mojo::AssociatedRemote<mojom::RendererConfiguration> rc_interface;
  28. process->GetChannel()->GetRemoteAssociatedInterface(&rc_interface);
  29. mojo::PendingRemote<content_settings::mojom::ContentSettingsManager>
  30. content_settings_manager;
  31. if (base::FeatureList::IsEnabled(
  32. features::kNavigationThreadingOptimizations)) {
  33. content_settings::ContentSettingsManagerImpl::Create(
  34. process, content_settings_manager.InitWithNewPipeAndPassReceiver(),
  35. std::make_unique<ContentSettingsManagerDelegate>());
  36. }
  37. rc_interface->SetInitialConfiguration(std::move(content_settings_manager));
  38. }
  39. void PageSpecificContentSettingsDelegate::UpdateLocationBar() {}
  40. PrefService* PageSpecificContentSettingsDelegate::GetPrefs() {
  41. return static_cast<BrowserContextImpl*>(web_contents_->GetBrowserContext())
  42. ->pref_service();
  43. }
  44. HostContentSettingsMap* PageSpecificContentSettingsDelegate::GetSettingsMap() {
  45. return HostContentSettingsMapFactory::GetForBrowserContext(
  46. web_contents_->GetBrowserContext());
  47. }
  48. void PageSpecificContentSettingsDelegate::SetDefaultRendererContentSettingRules(
  49. content::RenderFrameHost* rfh,
  50. RendererContentSettingRules* rules) {}
  51. std::vector<storage::FileSystemType>
  52. PageSpecificContentSettingsDelegate::GetAdditionalFileSystemTypes() {
  53. return {};
  54. }
  55. browsing_data::CookieHelper::IsDeletionDisabledCallback
  56. PageSpecificContentSettingsDelegate::GetIsDeletionDisabledCallback() {
  57. return base::NullCallback();
  58. }
  59. bool PageSpecificContentSettingsDelegate::IsMicrophoneCameraStateChanged(
  60. content_settings::PageSpecificContentSettings::MicrophoneCameraState
  61. microphone_camera_state,
  62. const std::string& media_stream_selected_audio_device,
  63. const std::string& media_stream_selected_video_device) {
  64. return false;
  65. }
  66. content_settings::PageSpecificContentSettings::MicrophoneCameraState
  67. PageSpecificContentSettingsDelegate::GetMicrophoneCameraState() {
  68. return content_settings::PageSpecificContentSettings::
  69. MICROPHONE_CAMERA_NOT_ACCESSED;
  70. }
  71. void PageSpecificContentSettingsDelegate::OnContentAllowed(
  72. ContentSettingsType type) {}
  73. void PageSpecificContentSettingsDelegate::OnContentBlocked(
  74. ContentSettingsType type) {}
  75. void PageSpecificContentSettingsDelegate::OnStorageAccessAllowed(
  76. content_settings::mojom::ContentSettingsManager::StorageType storage_type,
  77. const url::Origin& origin,
  78. content::Page& page) {}
  79. void PageSpecificContentSettingsDelegate::OnCookieAccessAllowed(
  80. const net::CookieList& accessed_cookies,
  81. content::Page& page) {}
  82. void PageSpecificContentSettingsDelegate::OnServiceWorkerAccessAllowed(
  83. const url::Origin& origin,
  84. content::Page& page) {}
  85. } // namespace weblayer