Upload upstream chromium 120.0.6099.5
[platform/framework/web/chromium-efl.git] / components / custom_handlers / register_protocol_handler_permission_request.h
1 // Copyright 2014 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 COMPONENTS_CUSTOM_HANDLERS_REGISTER_PROTOCOL_HANDLER_PERMISSION_REQUEST_H_
6 #define COMPONENTS_CUSTOM_HANDLERS_REGISTER_PROTOCOL_HANDLER_PERMISSION_REQUEST_H_
7
8 #include "base/functional/callback_helpers.h"
9 #include "base/memory/raw_ptr.h"
10 #include "components/custom_handlers/protocol_handler.h"
11 #include "components/permissions/permission_request.h"
12
13 namespace permissions {
14 enum class RequestType;
15 }  // namespace permissions
16
17 class GURL;
18 namespace custom_handlers {
19 class ProtocolHandlerRegistry;
20
21 // This class provides display data for a permission request, shown when a page
22 // wants to register a protocol handler and was triggered by a user action.
23 class RegisterProtocolHandlerPermissionRequest
24     : public permissions::PermissionRequest {
25  public:
26   RegisterProtocolHandlerPermissionRequest(
27       custom_handlers::ProtocolHandlerRegistry* registry,
28       const ProtocolHandler& handler,
29       GURL url,
30       base::ScopedClosureRunner fullscreen_block);
31
32   RegisterProtocolHandlerPermissionRequest(
33       const RegisterProtocolHandlerPermissionRequest&) = delete;
34   RegisterProtocolHandlerPermissionRequest& operator=(
35       const RegisterProtocolHandlerPermissionRequest&) = delete;
36
37   ~RegisterProtocolHandlerPermissionRequest() override;
38
39  private:
40   // permissions::PermissionRequest:
41   bool IsDuplicateOf(
42       permissions::PermissionRequest* other_request) const override;
43   std::u16string GetMessageTextFragment() const override;
44
45   void PermissionDecided(ContentSetting result,
46                          bool is_one_time,
47                          bool is_final_decision);
48   void DeleteRequest();
49
50   raw_ptr<custom_handlers::ProtocolHandlerRegistry> registry_;
51   ProtocolHandler handler_;
52   // Fullscreen will be blocked for the duration of the lifetime of this block.
53   // TODO(avi): Move to either permissions::PermissionRequest or the
54   // PermissionRequestManager?
55   base::ScopedClosureRunner fullscreen_block_;
56 };
57
58 }  // namespace custom_handlers
59
60 #endif  // COMONENTS_CUSTOM_HANDLERS_REGISTER_PROTOCOL_HANDLER_PERMISSION_REQUEST_H_