1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
|
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef COMPONENTS_CONTENT_SETTINGS_CORE_BROWSER_CONTENT_SETTINGS_UTILS_H_
#define COMPONENTS_CONTENT_SETTINGS_CORE_BROWSER_CONTENT_SETTINGS_UTILS_H_
#include <string>
#include <utility>
#include "base/compiler_specific.h"
#include "base/memory/scoped_ptr.h"
#include "components/content_settings/core/common/content_settings.h"
#include "components/content_settings/core/common/content_settings_pattern.h"
#include "components/content_settings/core/common/content_settings_types.h"
namespace base {
class Value;
}
class GURL;
class HostContentSettingsMap;
namespace content_settings {
class ProviderInterface;
class RuleIterator;
typedef std::pair<ContentSettingsPattern, ContentSettingsPattern> PatternPair;
// Deprecated, do not call this!
// Call WebsiteSettingsRegistry::GetInstance()->Get(type)->name() instead.
// TODO(raymes): Inline this function at it's callsites.
std::string GetTypeName(ContentSettingsType type);
std::string ContentSettingToString(ContentSetting setting);
ContentSetting ContentSettingFromString(const std::string& name);
// Converts |Value| to |ContentSetting|.
ContentSetting ValueToContentSetting(const base::Value* value);
// Converts a |Value| to a |ContentSetting|. Returns true if |value| encodes
// a valid content setting, false otherwise. Note that |CONTENT_SETTING_DEFAULT|
// is encoded as a NULL value, so it is not allowed as an integer value.
bool ParseContentSettingValue(const base::Value* value,
ContentSetting* setting);
PatternPair ParsePatternString(const std::string& pattern_str);
std::string CreatePatternString(
const ContentSettingsPattern& item_pattern,
const ContentSettingsPattern& top_level_frame_pattern);
// Caller takes the ownership of the returned |base::Value*|.
base::Value* GetContentSettingValueAndPatterns(
RuleIterator* rule_iterator,
const GURL& primary_url,
const GURL& secondary_url,
ContentSettingsPattern* primary_pattern,
ContentSettingsPattern* secondary_pattern);
// Returns a |base::Value*| representation of |setting| if |setting| is
// a valid content setting. Otherwise, returns a nullptr.
scoped_ptr<base::Value> ContentSettingToValue(ContentSetting setting);
base::Value* GetContentSettingValueAndPatterns(
const ProviderInterface* provider,
const GURL& primary_url,
const GURL& secondary_url,
ContentSettingsType content_type,
const std::string& resource_identifier,
bool include_incognito,
ContentSettingsPattern* primary_pattern,
ContentSettingsPattern* secondary_pattern);
// Populates |rules| with content setting rules for content types that are
// handled by the renderer.
void GetRendererContentSettingRules(const HostContentSettingsMap* map,
RendererContentSettingRules* rules);
// Get the flags to use when registering the preference to store |content_type|
// settings.
uint32 PrefRegistrationFlagsForType(ContentSettingsType content_type);
} // namespace content_settings
#endif // COMPONENTS_CONTENT_SETTINGS_CORE_BROWSER_CONTENT_SETTINGS_UTILS_H_
|