1 // Copyright 2016 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.
4 
5 #ifndef CONTENT_PUBLIC_TEST_MOCK_PERMISSION_MANAGER_H_
6 #define CONTENT_PUBLIC_TEST_MOCK_PERMISSION_MANAGER_H_
7 
8 #include "content/public/browser/permission_controller_delegate.h"
9 #include "testing/gmock/include/gmock/gmock.h"
10 #include "url/gurl.h"
11 
12 class GURL;
13 
14 namespace content {
15 
16 enum class PermissionType;
17 
18 // Mock of the permission manager for unit tests.
19 class MockPermissionManager : public PermissionControllerDelegate {
20  public:
21   MockPermissionManager();
22 
23   ~MockPermissionManager() override;
24 
25   // PermissionManager:
26   MOCK_METHOD3(GetPermissionStatus,
27                blink::mojom::PermissionStatus(PermissionType permission,
28                                               const GURL& requesting_origin,
29                                               const GURL& embedding_origin));
30   MOCK_METHOD3(GetPermissionStatusForFrame,
31                blink::mojom::PermissionStatus(
32                    PermissionType permission,
33                    content::RenderFrameHost* render_frame_host,
34                    const GURL& requesting_origin));
35   int RequestPermission(PermissionType permission,
36                         RenderFrameHost* render_frame_host,
37                         const GURL& requesting_origin,
38                         bool user_gesture,
39                         base::OnceCallback<void(blink::mojom::PermissionStatus)>
40                             callback) override;
41   int RequestPermissions(
42       const std::vector<PermissionType>& permission,
43       RenderFrameHost* render_frame_host,
44       const GURL& requesting_origin,
45       bool user_gesture,
46       base::OnceCallback<
47           void(const std::vector<blink::mojom::PermissionStatus>&)> callback)
48       override;
ResetPermission(PermissionType permission,const GURL & requesting_origin,const GURL & embedding_origin)49   void ResetPermission(PermissionType permission,
50                        const GURL& requesting_origin,
51                        const GURL& embedding_origin) override {}
52   MOCK_METHOD4(SubscribePermissionStatusChange,
53                int(PermissionType permission,
54                    RenderFrameHost* render_frame_host,
55                    const GURL& requesting_origin,
56                    base::RepeatingCallback<void(blink::mojom::PermissionStatus)>
57                        callback));
58   MOCK_METHOD1(UnsubscribePermissionStatusChange, void(int subscription_id));
59 
60  private:
61   DISALLOW_COPY_AND_ASSIGN(MockPermissionManager);
62 };
63 
64 }  // namespace content
65 
66 #endif  // CONTENT_PUBLIC_TEST_MOCK_PERMISSION_MANAGER_H_
67