OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CHROME_BROWSER_PERMISSIONS_PERMISSION_BUBBLE_REQUEST_IMPL_H_ | 5 #ifndef CHROME_BROWSER_PERMISSIONS_PERMISSION_BUBBLE_REQUEST_IMPL_H_ |
6 #define CHROME_BROWSER_PERMISSIONS_PERMISSION_BUBBLE_REQUEST_IMPL_H_ | 6 #define CHROME_BROWSER_PERMISSIONS_PERMISSION_BUBBLE_REQUEST_IMPL_H_ |
7 | 7 |
8 #include "base/callback.h" | 8 #include "base/callback.h" |
9 #include "base/macros.h" | 9 #include "base/macros.h" |
10 #include "chrome/browser/permissions/permission_request_id.h" | 10 #include "chrome/browser/permissions/permission_request_id.h" |
11 #include "chrome/browser/ui/website_settings/permission_bubble_request.h" | 11 #include "chrome/browser/ui/website_settings/permission_bubble_request.h" |
12 #include "components/content_settings/core/common/content_settings.h" | 12 #include "components/content_settings/core/common/content_settings.h" |
13 #include "content/public/browser/permission_type.h" | 13 #include "content/public/browser/permission_type.h" |
14 | 14 |
15 class GURL; | 15 class GURL; |
16 class PermissionContextBase; | 16 class PermissionContextBase; |
17 | 17 |
18 // Default implementation of PermissionBubbleRequest, it is assumed that the | 18 // Default implementation of PermissionBubbleRequest, it is assumed that the |
19 // caller owns it and that it can be deleted once the |delete_callback| | 19 // caller owns it and that it can be deleted once the |delete_callback| |
20 // is executed. | 20 // is executed. |
21 class PermissionBubbleRequestImpl : public PermissionBubbleRequest { | 21 class PermissionBubbleRequestImpl : public PermissionBubbleRequest { |
22 public: | 22 public: |
23 using PermissionDecidedCallback = base::Callback<void(bool, ContentSetting)>; | 23 using PermissionDecidedCallback = base::Callback<void(bool, ContentSetting)>; |
24 | 24 |
25 PermissionBubbleRequestImpl( | 25 PermissionBubbleRequestImpl( |
26 const GURL& request_origin, | 26 const GURL& request_origin, |
27 content::PermissionType permission_type, | 27 content::PermissionType permission_type, |
28 const std::string& display_languages, | |
29 const PermissionDecidedCallback& permission_decided_callback, | 28 const PermissionDecidedCallback& permission_decided_callback, |
30 const base::Closure delete_callback); | 29 const base::Closure delete_callback); |
31 | 30 |
32 ~PermissionBubbleRequestImpl() override; | 31 ~PermissionBubbleRequestImpl() override; |
33 | 32 |
34 // PermissionBubbleRequest: | 33 // PermissionBubbleRequest: |
35 gfx::VectorIconId GetVectorIconId() const override; | 34 gfx::VectorIconId GetVectorIconId() const override; |
36 int GetIconId() const override; | 35 int GetIconId() const override; |
37 base::string16 GetMessageText() const override; | 36 base::string16 GetMessageText() const override; |
38 base::string16 GetMessageTextFragment() const override; | 37 base::string16 GetMessageTextFragment() const override; |
39 GURL GetOrigin() const override; | 38 GURL GetOrigin() const override; |
40 // Remember to call RegisterActionTaken for these methods if you are | 39 // Remember to call RegisterActionTaken for these methods if you are |
41 // overriding them. | 40 // overriding them. |
42 void PermissionGranted() override; | 41 void PermissionGranted() override; |
43 void PermissionDenied() override; | 42 void PermissionDenied() override; |
44 void Cancelled() override; | 43 void Cancelled() override; |
45 void RequestFinished() override; | 44 void RequestFinished() override; |
46 | 45 |
47 protected: | 46 protected: |
48 void RegisterActionTaken() { action_taken_ = true; } | 47 void RegisterActionTaken() { action_taken_ = true; } |
49 | 48 |
50 private: | 49 private: |
51 GURL request_origin_; | 50 GURL request_origin_; |
52 content::PermissionType permission_type_; | 51 content::PermissionType permission_type_; |
53 std::string display_languages_; | |
54 | 52 |
55 // Called once a decision is made about the permission. | 53 // Called once a decision is made about the permission. |
56 const PermissionDecidedCallback permission_decided_callback_; | 54 const PermissionDecidedCallback permission_decided_callback_; |
57 | 55 |
58 // Called when the bubble is no longer in use so it can be deleted by | 56 // Called when the bubble is no longer in use so it can be deleted by |
59 // the caller. | 57 // the caller. |
60 const base::Closure delete_callback_; | 58 const base::Closure delete_callback_; |
61 bool is_finished_; | 59 bool is_finished_; |
62 bool action_taken_; | 60 bool action_taken_; |
63 | 61 |
64 DISALLOW_COPY_AND_ASSIGN(PermissionBubbleRequestImpl); | 62 DISALLOW_COPY_AND_ASSIGN(PermissionBubbleRequestImpl); |
65 }; | 63 }; |
66 | 64 |
67 #endif // CHROME_BROWSER_PERMISSIONS_PERMISSION_BUBBLE_REQUEST_IMPL_H_ | 65 #endif // CHROME_BROWSER_PERMISSIONS_PERMISSION_BUBBLE_REQUEST_IMPL_H_ |
OLD | NEW |