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

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

Issue 2675483002: Replace PermissionType in chrome/ with ContentSettingsType (Closed)
Patch Set: rebase + include content_settings_types.h more Created 3 years, 10 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
1 // Copyright 2016 The Chromium Authors. All rights reserved. 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 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_DELEGATION_TRACKER_H_ 5 #ifndef CHROME_BROWSER_PERMISSIONS_DELEGATION_TRACKER_H_
6 #define CHROME_BROWSER_PERMISSIONS_DELEGATION_TRACKER_H_ 6 #define CHROME_BROWSER_PERMISSIONS_DELEGATION_TRACKER_H_
7 7
8 #include <memory> 8 #include <memory>
9 #include <unordered_map> 9 #include <unordered_map>
10 #include <vector> 10 #include <vector>
11 11
12 #include "base/macros.h" 12 #include "base/macros.h"
13 #include "components/content_settings/core/common/content_settings_types.h"
13 14
14 namespace content { 15 namespace content {
15 16
16 class RenderFrameHost; 17 class RenderFrameHost;
17 enum class PermissionType;
18 18
19 } // namespace content 19 } // namespace content
20 20
21 // Keeps track of which permissions are delegated to frames. There are two 21 // Keeps track of which permissions are delegated to frames. There are two
22 // operations possible: 22 // operations possible:
23 // 1) Setting the permissions which are delegated to a frame by its parent, and 23 // 1) Setting the permissions which are delegated to a frame by its parent, and
24 // 2) Querying whether a particular permission is granted to a frame. 24 // 2) Querying whether a particular permission is granted to a frame.
25 // 25 //
26 // If a frame is destroyed or navigated, permissions will no longer be delegated 26 // If a frame is destroyed or navigated, permissions will no longer be delegated
27 // to it. 27 // to it.
28 class DelegationTracker { 28 class DelegationTracker {
29 public: 29 public:
30 DelegationTracker(); 30 DelegationTracker();
31 ~DelegationTracker(); 31 ~DelegationTracker();
32 32
33 // Set the |permissions| which are delegated to |child_rfh| by its parent. 33 // Set the |permissions| which are delegated to |child_rfh| by its parent.
34 void SetDelegatedPermissions( 34 void SetDelegatedPermissions(
35 content::RenderFrameHost* child_rfh, 35 content::RenderFrameHost* child_rfh,
36 const std::vector<content::PermissionType>& permissions); 36 const std::vector<ContentSettingsType>& permissions);
37 37
38 // Query whether |permission| is granted to |requesting_rfh|. This will return 38 // Query whether |permission| is granted to |requesting_rfh|. This will return
39 // true if |requesting_rfh| is a top-level frame or if it has been delegated 39 // true if |requesting_rfh| is a top-level frame or if it has been delegated
40 // |permission| through its ancestor frames. Specifically, each frame on the 40 // |permission| through its ancestor frames. Specifically, each frame on the
41 // path between the main frame and |requesting_rfh| must either delegate 41 // path between the main frame and |requesting_rfh| must either delegate
42 // |permission| to it's child OR have the same origin as it's child on that 42 // |permission| to it's child OR have the same origin as it's child on that
43 // path in order for this to return true. 43 // path in order for this to return true.
44 bool IsGranted(content::RenderFrameHost* requesting_rfh, 44 bool IsGranted(content::RenderFrameHost* requesting_rfh,
45 const content::PermissionType& permission); 45 ContentSettingsType permission);
46 46
47 private: 47 private:
48 class DelegatedForChild; 48 class DelegatedForChild;
49 49
50 void RenderFrameHostChanged(content::RenderFrameHost* rfh); 50 void RenderFrameHostChanged(content::RenderFrameHost* rfh);
51 51
52 std::unordered_map<content::RenderFrameHost*, 52 std::unordered_map<content::RenderFrameHost*,
53 std::unique_ptr<DelegatedForChild>> 53 std::unique_ptr<DelegatedForChild>>
54 delegated_permissions_; 54 delegated_permissions_;
55 55
56 DISALLOW_COPY_AND_ASSIGN(DelegationTracker); 56 DISALLOW_COPY_AND_ASSIGN(DelegationTracker);
57 }; 57 };
58 58
59 #endif // CHROME_BROWSER_PERMISSIONS_DELEGATION_TRACKER_H_ 59 #endif // CHROME_BROWSER_PERMISSIONS_DELEGATION_TRACKER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698