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 data_content_settings_type); |
| 31 ~ChooserContextBase() override; |
| 32 |
| 33 // Returns the list of objects that |requesting_origin| has been granted |
| 34 // permission to access when embedded within |embedding_origin|. |
| 35 ScopedVector<base::DictionaryValue> GetGrantedObjects( |
| 36 const GURL& requesting_origin, |
| 37 const GURL& embedding_origin); |
| 38 |
| 39 // Grants |requesting_origin| access to |object| when embedded within |
| 40 // |embedding_origin| by writing it into |host_content_settings_map_|. |
| 41 void GrantObjectPermission(const GURL& requesting_origin, |
| 42 const GURL& embedding_origin, |
| 43 scoped_ptr<base::DictionaryValue> object); |
| 44 |
| 45 // Revokes |requesting_origin|'s permission to access |object| when embedded |
| 46 // within |embedding_origin|. |
| 47 void RevokeObjectPermission(const GURL& requesting_origin, |
| 48 const GURL& embedding_origin, |
| 49 const base::DictionaryValue& object); |
| 50 |
| 51 // Validates the structure of an object read from |
| 52 // |host_content_settings_map_|. |
| 53 virtual bool IsValidObject(const base::DictionaryValue& object) = 0; |
| 54 |
| 55 private: |
| 56 scoped_ptr<base::DictionaryValue> GetWebsiteSetting( |
| 57 const GURL& requesting_origin, |
| 58 const GURL& embedding_origin); |
| 59 void SetWebsiteSetting(const GURL& requesting_origin, |
| 60 const GURL& embedding_origin, |
| 61 scoped_ptr<base::Value> value); |
| 62 |
| 63 HostContentSettingsMap* const host_content_settings_map_; |
| 64 const ContentSettingsType data_content_settings_type_; |
| 65 }; |
| 66 |
| 67 #endif // CHROME_BROWSER_PERMISSIONS_CHOOSER_CONTEXT_BASE_H_ |
OLD | NEW |