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

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: Implement DelegationTracker for tracking delegated permissions to RenderFrameHosts 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
16 class RenderFrameHost;
17 class WebContents;
18 enum class PermissionType;
19
20 } // namespace content
21
22 // Keeps track of which permissions are delegated to frames. There are two
23 // operations possible:
24 // 1) Setting the permissions which are delegated to a frame by its parent, and
25 // 2) Querying whether a particular permission is granted to a frame.
26 //
27 // If a frame is destroyed or navigated, permissions will no longer be delegated
28 // to it.
29 class DelegationTracker {
30 public:
31 DelegationTracker();
32 ~DelegationTracker();
33
34 // Set the |permissions| which are delegated to |child_rfh| by its parent.
35 void SetDelegatedPermissions(
36 content::RenderFrameHost* child_rfh,
37 const std::vector<content::PermissionType>& permissions);
38
39 // Query whether |permission| is granted to |requesting_rfh|. This will return
40 // true if |requesting_rfh| is a top-level frame or if it has been delegated
41 // |permission| through its ancestor frames. Specifically, each frame on the
42 // path between the main frame and |requesting_rfh| must either delegate
43 // |permission| to it's child OR have the same origin as it's child on that
44 // path in order for this to return true.
45 bool IsGranted(content::RenderFrameHost* requesting_rfh,
46 const content::PermissionType& permission);
47
48 private:
49 class DelegatedForChild;
50
51 void RenderFrameHostChanged(content::RenderFrameHost* rfh);
52
53 std::unordered_map<content::RenderFrameHost*,
54 std::unique_ptr<DelegatedForChild>>
55 delegated_permissions_;
56
57 DISALLOW_COPY_AND_ASSIGN(DelegationTracker);
58 };
59
60 #endif // CHROME_BROWSER_PERMISSIONS_DELEGATION_TRACKER_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/permissions/delegation_tracker.cc » ('j') | content/public/browser/permission_type.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698