Update code documentation for enum in EWK headers
[platform/framework/web/chromium-efl.git] / chrome / renderer / chrome_content_settings_agent_delegate.h
1 // Copyright 2020 The Chromium Authors
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef CHROME_RENDERER_CHROME_CONTENT_SETTINGS_AGENT_DELEGATE_H_
6 #define CHROME_RENDERER_CHROME_CONTENT_SETTINGS_AGENT_DELEGATE_H_
7
8 #include "base/gtest_prod_util.h"
9 #include "base/memory/raw_ptr.h"
10 #include "components/content_settings/renderer/content_settings_agent_impl.h"
11 #include "extensions/buildflags/buildflags.h"
12
13 #if BUILDFLAG(ENABLE_EXTENSIONS)
14 namespace extensions {
15 class Dispatcher;
16 class Extension;
17 }  // namespace extensions
18 #endif
19
20 class ChromeContentSettingsAgentDelegate
21     : public content_settings::ContentSettingsAgentImpl::Delegate,
22       public content::RenderFrameObserver,
23       public content::RenderFrameObserverTracker<
24           ChromeContentSettingsAgentDelegate> {
25  public:
26   explicit ChromeContentSettingsAgentDelegate(
27       content::RenderFrame* render_frame);
28   ~ChromeContentSettingsAgentDelegate() override;
29
30 #if BUILDFLAG(ENABLE_EXTENSIONS)
31   // Sets the extension dispatcher. Call this right after constructing this
32   // class. This should only be called once.
33   void SetExtensionDispatcher(extensions::Dispatcher* extension_dispatcher);
34 #endif
35
36   bool IsPluginTemporarilyAllowed(const std::string& identifier);
37   void AllowPluginTemporarily(const std::string& identifier);
38
39   // content_settings::ContentSettingsAgentImpl::Delegate:
40   bool IsSchemeAllowlisted(const std::string& scheme) override;
41   absl::optional<bool> AllowReadFromClipboard() override;
42   absl::optional<bool> AllowWriteToClipboard() override;
43   absl::optional<bool> AllowMutationEvents() override;
44
45  private:
46   FRIEND_TEST_ALL_PREFIXES(ChromeContentSettingsAgentDelegateBrowserTest,
47                            PluginsTemporarilyAllowed);
48
49   // RenderFrameObserver:
50   void DidCommitProvisionalLoad(ui::PageTransition transition) override;
51   void OnDestruct() override;
52
53   // Whether the observed RenderFrame is for a platform app.
54   bool IsPlatformApp();
55
56   // Whether the observed RenderFrame is an allow-listed System Web App.
57   bool IsAllowListedSystemWebApp();
58
59 #if BUILDFLAG(ENABLE_EXTENSIONS)
60   // If |origin| corresponds to an installed extension, returns that extension.
61   // Otherwise returns null.
62   const extensions::Extension* GetExtension(
63       const blink::WebSecurityOrigin& origin) const;
64
65   // Owned by ChromeContentRendererClient and outlive us.
66   raw_ptr<extensions::Dispatcher, ExperimentalRenderer> extension_dispatcher_ =
67       nullptr;
68 #endif
69
70   base::flat_set<std::string> temporarily_allowed_plugins_;
71
72   raw_ptr<content::RenderFrame, ExperimentalRenderer> render_frame_ = nullptr;
73 };
74
75 #endif  // CHROME_RENDERER_CHROME_CONTENT_SETTINGS_AGENT_DELEGATE_H_