OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2015 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_CHOOSER_CONTEXT_BASE_H_ | |
6 #define CHROME_BROWSER_PERMISSIONS_CHOOSER_CONTEXT_BASE_H_ | |
7 | |
8 #include <string> | |
9 | |
10 #include "base/memory/scoped_ptr.h" | |
11 #include "base/memory/scoped_vector.h" | |
12 #include "components/content_settings/core/common/content_settings_types.h" | |
13 #include "components/keyed_service/core/keyed_service.h" | |
14 | |
15 namespace base { | |
16 class DictionaryValue; | |
17 class Value; | |
18 } | |
19 | |
20 class GURL; | |
21 class HostContentSettingsMap; | |
22 class Profile; | |
23 | |
24 // This is the base class for services that manage any type of permission that | |
25 // is granted through a chooser-style UI instead of a simple allow/deny prompt. | |
26 // Subclasses must define the structure of the objects that are stored. | |
27 class ChooserContextBase : public KeyedService { | |
28 public: | |
29 ChooserContextBase(Profile* profile, | |
30 ContentSettingsType permission_type, | |
31 ContentSettingsType chooser_type); | |
32 ~ChooserContextBase() override; | |
33 | |
34 // Returns the list of objects that |requesting_origin| has been granted | |
35 // permission to access when embedded within |embedding_origin|. | |
36 ScopedVector<base::DictionaryValue> GetPreviouslyChosenObjects( | |
mlamouri (slow - plz ping)
2015/11/06 15:22:46
nit: GetGrantedObjects()
| |
37 const GURL& requesting_origin, | |
38 const GURL& embedding_origin); | |
39 | |
40 // Grants |requesting_origin| access to |object| when embedded within | |
41 // |embedding_origin| by writing it into |host_content_settings_map_|. | |
42 void GrantObjectPermission(const GURL& requesting_origin, | |
43 const GURL& embedding_origin, | |
44 scoped_ptr<base::DictionaryValue> object); | |
45 | |
46 // Revokes |requesting_origin|'s permission to access |object| when embedded | |
47 // within |embedding_origin|. | |
48 void RevokeObjectPermission(const GURL& requesting_origin, | |
49 const GURL& embedding_origin, | |
50 const base::DictionaryValue& object); | |
51 | |
52 // Validates the structure of an object read from | |
53 // |host_content_settings_map_|. | |
54 virtual bool IsValidObject(const base::DictionaryValue& object) = 0; | |
55 | |
56 private: | |
57 scoped_ptr<base::DictionaryValue> GetWebsiteSetting( | |
58 const GURL& requesting_origin, | |
59 const GURL& embedding_origin); | |
60 void SetWebsiteSetting(const GURL& requesting_origin, | |
61 const GURL& embedding_origin, | |
62 scoped_ptr<base::Value> value); | |
63 | |
64 HostContentSettingsMap* const host_content_settings_map_; | |
65 const ContentSettingsType permission_type_; | |
mlamouri (slow - plz ping)
2015/11/06 15:22:46
nit: could you rename this |guard_content_setting_
| |
66 const ContentSettingsType chooser_type_; | |
mlamouri (slow - plz ping)
2015/11/06 15:22:46
nit: could you rename this |objects_content_settin
| |
67 }; | |
68 | |
69 #endif // CHROME_BROWSER_PERMISSIONS_CHOOSER_CONTEXT_BASE_H_ | |
OLD | NEW |