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 and how |
| 27 // they are displayed to the user. |
| 28 class ChooserContextBase : public KeyedService { |
| 29 public: |
| 30 ChooserContextBase(Profile* profile, |
| 31 ContentSettingsType permission_type, |
| 32 ContentSettingsType chooser_type); |
| 33 ~ChooserContextBase() override; |
| 34 |
| 35 ScopedVector<base::DictionaryValue> GetPreviouslyChosenObjects( |
| 36 const GURL& requesting_origin, |
| 37 const GURL& embedding_origin); |
| 38 void GrantObjectPermission(const GURL& requesting_origin, |
| 39 const GURL& embedding_origin, |
| 40 scoped_ptr<base::DictionaryValue> object); |
| 41 void RevokeObjectPermission(const GURL& requesting_origin, |
| 42 const GURL& embedding_origin, |
| 43 const base::DictionaryValue& object); |
| 44 |
| 45 virtual bool IsValidObject(const base::DictionaryValue& object) = 0; |
| 46 virtual std::string GetStringToDisplayForObject( |
| 47 const base::DictionaryValue& object) = 0; |
| 48 |
| 49 private: |
| 50 scoped_ptr<base::DictionaryValue> GetWebsiteSetting( |
| 51 const GURL& requesting_origin, |
| 52 const GURL& embedding_origin); |
| 53 void SetWebsiteSetting(const GURL& requesting_origin, |
| 54 const GURL& embedding_origin, |
| 55 scoped_ptr<base::Value> value); |
| 56 |
| 57 HostContentSettingsMap* const host_content_settings_map_; |
| 58 const ContentSettingsType permission_type_; |
| 59 const ContentSettingsType chooser_type_; |
| 60 }; |
| 61 |
| 62 #endif // CHROME_BROWSER_PERMISSIONS_CHOOSER_CONTEXT_BASE_H_ |
OLD | NEW |