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.
5 #ifndef COMPONENTS_CUSTOM_HANDLERS_REGISTER_PROTOCOL_HANDLER_PERMISSION_REQUEST_H_
6 #define COMPONENTS_CUSTOM_HANDLERS_REGISTER_PROTOCOL_HANDLER_PERMISSION_REQUEST_H_
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"
13 namespace permissions {
14 enum class RequestType;
15 } // namespace permissions
18 namespace custom_handlers {
19 class ProtocolHandlerRegistry;
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 {
26 RegisterProtocolHandlerPermissionRequest(
27 custom_handlers::ProtocolHandlerRegistry* registry,
28 const ProtocolHandler& handler,
30 base::ScopedClosureRunner fullscreen_block);
32 RegisterProtocolHandlerPermissionRequest(
33 const RegisterProtocolHandlerPermissionRequest&) = delete;
34 RegisterProtocolHandlerPermissionRequest& operator=(
35 const RegisterProtocolHandlerPermissionRequest&) = delete;
37 ~RegisterProtocolHandlerPermissionRequest() override;
40 // permissions::PermissionRequest:
42 permissions::PermissionRequest* other_request) const override;
43 std::u16string GetMessageTextFragment() const override;
45 void PermissionDecided(ContentSetting result,
47 bool is_final_decision);
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_;
58 } // namespace custom_handlers
60 #endif // COMONENTS_CUSTOM_HANDLERS_REGISTER_PROTOCOL_HANDLER_PERMISSION_REQUEST_H_