OLD | NEW |
(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 COMPONENTS_CONTENT_SETTINGS_CORE_COMMON_CONTENT_SETTINGS_STRUCT_TRAITS_H |
| 6 #define COMPONENTS_CONTENT_SETTINGS_CORE_COMMON_CONTENT_SETTINGS_STRUCT_TRAITS_H |
| 7 |
| 8 #include <string> |
| 9 |
| 10 #include "components/content_settings/core/common/content_settings.h" |
| 11 #include "components/content_settings/core/common/content_settings.mojom.h" |
| 12 #include "mojo/public/cpp/bindings/enum_traits.h" |
| 13 #include "mojo/public/cpp/bindings/struct_traits.h" |
| 14 |
| 15 namespace mojo { |
| 16 |
| 17 template <> |
| 18 struct StructTraits<content_settings::mojom::PatternPartsDataView, |
| 19 ContentSettingsPattern::PatternParts> { |
| 20 static const std::string& scheme( |
| 21 const ContentSettingsPattern::PatternParts& r) { |
| 22 return r.scheme; |
| 23 } |
| 24 |
| 25 static bool is_scheme_wildcard( |
| 26 const ContentSettingsPattern::PatternParts& r) { |
| 27 return r.is_scheme_wildcard; |
| 28 } |
| 29 |
| 30 static const std::string& host( |
| 31 const ContentSettingsPattern::PatternParts& r) { |
| 32 return r.host; |
| 33 } |
| 34 |
| 35 static bool has_domain_wildcard( |
| 36 const ContentSettingsPattern::PatternParts& r) { |
| 37 return r.has_domain_wildcard; |
| 38 } |
| 39 |
| 40 static const std::string& port( |
| 41 const ContentSettingsPattern::PatternParts& r) { |
| 42 return r.port; |
| 43 } |
| 44 |
| 45 static bool is_port_wildcard(const ContentSettingsPattern::PatternParts& r) { |
| 46 return r.is_port_wildcard; |
| 47 } |
| 48 |
| 49 static const std::string& path( |
| 50 const ContentSettingsPattern::PatternParts& r) { |
| 51 return r.path; |
| 52 } |
| 53 |
| 54 static bool is_path_wildcard(const ContentSettingsPattern::PatternParts& r) { |
| 55 return r.is_path_wildcard; |
| 56 } |
| 57 |
| 58 static bool Read(content_settings::mojom::PatternPartsDataView data, |
| 59 ContentSettingsPattern::PatternParts* out); |
| 60 }; |
| 61 |
| 62 template <> |
| 63 struct StructTraits<content_settings::mojom::ContentSettingsPatternDataView, |
| 64 ContentSettingsPattern> { |
| 65 static const ContentSettingsPattern::PatternParts& parts( |
| 66 const ContentSettingsPattern& r) { |
| 67 return r.parts_; |
| 68 } |
| 69 |
| 70 static bool is_valid(const ContentSettingsPattern& r) { return r.is_valid_; } |
| 71 |
| 72 static bool Read(content_settings::mojom::ContentSettingsPatternDataView data, |
| 73 ContentSettingsPattern* out); |
| 74 }; |
| 75 |
| 76 template <> |
| 77 struct EnumTraits<content_settings::mojom::ContentSetting, ContentSetting> { |
| 78 static content_settings::mojom::ContentSetting ToMojom( |
| 79 ContentSetting setting); |
| 80 |
| 81 static bool FromMojom(content_settings::mojom::ContentSetting setting, |
| 82 ContentSetting* out); |
| 83 }; |
| 84 |
| 85 template <> |
| 86 struct StructTraits< |
| 87 content_settings::mojom::ContentSettingPatternSourceDataView, |
| 88 ContentSettingPatternSource> { |
| 89 static const ContentSettingsPattern& primary_pattern( |
| 90 const ContentSettingPatternSource& r) { |
| 91 return r.primary_pattern; |
| 92 } |
| 93 |
| 94 static const ContentSettingsPattern& secondary_pattern( |
| 95 const ContentSettingPatternSource& r) { |
| 96 return r.secondary_pattern; |
| 97 } |
| 98 |
| 99 static ContentSetting setting(const ContentSettingPatternSource& r) { |
| 100 return r.setting; |
| 101 } |
| 102 |
| 103 static const std::string& source(const ContentSettingPatternSource& r) { |
| 104 return r.source; |
| 105 } |
| 106 |
| 107 static bool incognito(const ContentSettingPatternSource& r) { |
| 108 return r.incognito; |
| 109 } |
| 110 |
| 111 static bool Read( |
| 112 content_settings::mojom::ContentSettingPatternSourceDataView data, |
| 113 ContentSettingPatternSource* out); |
| 114 }; |
| 115 |
| 116 template <> |
| 117 struct StructTraits< |
| 118 content_settings::mojom::RendererContentSettingRulesDataView, |
| 119 RendererContentSettingRules> { |
| 120 static const std::vector<ContentSettingPatternSource>& image_rules( |
| 121 const RendererContentSettingRules& r) { |
| 122 return r.image_rules; |
| 123 } |
| 124 |
| 125 static const std::vector<ContentSettingPatternSource>& script_rules( |
| 126 const RendererContentSettingRules& r) { |
| 127 return r.script_rules; |
| 128 } |
| 129 |
| 130 static const std::vector<ContentSettingPatternSource>& autoplay_rules( |
| 131 const RendererContentSettingRules& r) { |
| 132 return r.autoplay_rules; |
| 133 } |
| 134 |
| 135 static bool Read( |
| 136 content_settings::mojom::RendererContentSettingRulesDataView data, |
| 137 RendererContentSettingRules* out); |
| 138 }; |
| 139 |
| 140 } // namespace mojo |
| 141 |
| 142 #endif // COMPONENTS_CONTENT_SETTINGS_CORE_COMMON_CONTENT_SETTINGS_STRUCT_TRAIT
S_H |
OLD | NEW |