Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(398)

Side by Side Diff: chrome/browser/permissions/delegation_tracker.h

Issue 2046293002: Implement DelegationTracker for tracking delegated permissions to RenderFrameHosts (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@permission-delegation-2-blink
Patch Set: Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
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 CHROME_BROWSER_PERMISSIONS_DELEGATION_TRACKER_H_
6 #define CHROME_BROWSER_PERMISSIONS_DELEGATION_TRACKER_H_
7
8 #include <memory>
9 #include <unordered_map>
10 #include <vector>
11
12 #include "base/macros.h"
13
14 namespace content {
15 class RenderFrameHost;
16 class WebContents;
17 enum class PermissionType;
18 } // namespace content
19
20 // Keeps track of which permissions are delegated to frames. There are two
21 // operations possible:
22 // 1) Setting the permissions which are delegated to a frame by its parent, and
23 // 2) Querying whether a particular permission is granted to a frame.
24 //
25 // If a frame is destroyed or navigated, permissions will no longer be delegated
26 // to it.
27 class DelegationTracker {
28 public:
29 DelegationTracker();
30 ~DelegationTracker();
31
32 // Set the |permissions| which are delegated to |child_rfh| by its parent.
33 void SetDelegatedPermissions(
34 content::RenderFrameHost* child_rfh,
35 const std::vector<content::PermissionType>& permissions);
36
37 // Query whether |permission| is granted to |requesting_rfh|. This will return
38 // true if |requesting_rfh| is a top-level frame or if it has been delegated
39 // |permission| through its ancestor frames. Specifically, each frame on the
40 // path between the main frame and |requesting_rfh| must either delegate
41 // |permission| to it's child OR have the same origin as it's child on that
42 // path in order for this to return true.
43 bool IsGranted(content::RenderFrameHost* requesting_rfh,
44 const content::PermissionType& permission);
45
46 private:
47 friend class DelegationTrackerTest;
48 class DelegatedForChild;
49
50 // Used for testing.
51 void SetDelegatedPermissionsInternal(
52 content::RenderFrameHost* child_rfh,
53 content::WebContents* web_contents,
54 const std::vector<content::PermissionType>& permissions);
55
56 void RenderFrameHostChanged(content::RenderFrameHost* rfh);
57
58 std::unordered_map<content::RenderFrameHost*,
59 std::unique_ptr<DelegatedForChild>>
60 delegated_permissions_;
61
62 DISALLOW_COPY_AND_ASSIGN(DelegationTracker);
63 };
64
65 #endif // CHROME_BROWSER_PERMISSIONS_DELEGATION_TRACKER_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/permissions/delegation_tracker.cc » ('j') | chrome/browser/permissions/delegation_tracker.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698