1 // Copyright 2014 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.
5 #ifndef CHROME_BROWSER_PERMISSIONS_PERMISSION_BUBBLE_REQUEST_IMPL_H_
6 #define CHROME_BROWSER_PERMISSIONS_PERMISSION_BUBBLE_REQUEST_IMPL_H_
8 #include "base/callback.h"
9 #include "chrome/browser/permissions/permission_request_id.h"
10 #include "chrome/browser/ui/website_settings/permission_bubble_request.h"
11 #include "components/content_settings/core/common/content_settings.h"
12 #include "components/content_settings/core/common/content_settings_types.h"
15 class PermissionContextBase
;
17 // Default implementation of PermissionBubbleRequest, it is assumed that the
18 // caller owns it and that it can be deleted once the |delete_callback|
20 class PermissionBubbleRequestImpl
: public PermissionBubbleRequest
{
22 using PermissionDecidedCallback
= base::Callback
<void(bool, ContentSetting
)>;
24 PermissionBubbleRequestImpl(
25 const GURL
& request_origin
,
27 ContentSettingsType type
,
28 const std::string
& display_languages
,
29 const PermissionDecidedCallback
& permission_decided_callback
,
30 const base::Closure delete_callback
);
32 ~PermissionBubbleRequestImpl() override
;
34 // PermissionBubbleRequest:
35 gfx::VectorIconId
GetVectorIconId() const override
;
36 int GetIconId() const override
;
37 base::string16
GetMessageText() const override
;
38 base::string16
GetMessageTextFragment() const override
;
39 bool HasUserGesture() const override
;
41 // TODO(miguelg) Change this method to GetOrigin()
42 GURL
GetRequestingHostname() const override
;
44 // Remember to call RegisterActionTaken for these methods if you are
46 void PermissionGranted() override
;
47 void PermissionDenied() override
;
48 void Cancelled() override
;
49 void RequestFinished() override
;
52 void RegisterActionTaken() { action_taken_
= true; }
57 ContentSettingsType type_
;
58 std::string display_languages_
;
60 // Called once a decision is made about the permission.
61 const PermissionDecidedCallback permission_decided_callback_
;
63 // Called when the bubble is no longer in use so it can be deleted by
65 const base::Closure delete_callback_
;
69 DISALLOW_COPY_AND_ASSIGN(PermissionBubbleRequestImpl
);
72 #endif // CHROME_BROWSER_PERMISSIONS_PERMISSION_BUBBLE_REQUEST_IMPL_H_