OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/extensions/api/content_settings/content_settings_helper
s.h" | 5 #include "chrome/browser/extensions/api/content_settings/content_settings_helper
s.h" |
6 | 6 |
| 7 #include <memory> |
| 8 |
7 #include "base/logging.h" | 9 #include "base/logging.h" |
8 #include "base/memory/scoped_ptr.h" | |
9 #include "components/content_settings/core/browser/website_settings_info.h" | 10 #include "components/content_settings/core/browser/website_settings_info.h" |
10 #include "components/content_settings/core/browser/website_settings_registry.h" | 11 #include "components/content_settings/core/browser/website_settings_registry.h" |
11 #include "content/public/common/url_constants.h" | 12 #include "content/public/common/url_constants.h" |
12 #include "extensions/common/url_pattern.h" | 13 #include "extensions/common/url_pattern.h" |
13 | 14 |
14 namespace { | 15 namespace { |
15 | 16 |
16 const char kNoPathWildcardsError[] = | 17 const char kNoPathWildcardsError[] = |
17 "Path wildcards in file URL patterns are not allowed."; | 18 "Path wildcards in file URL patterns are not allowed."; |
18 const char kNoPathsError[] = "Specific paths are not allowed."; | 19 const char kNoPathsError[] = "Specific paths are not allowed."; |
(...skipping 18 matching lines...) Expand all Loading... |
37 std::string* error) { | 38 std::string* error) { |
38 const int kAllowedSchemes = | 39 const int kAllowedSchemes = |
39 URLPattern::SCHEME_HTTP | URLPattern::SCHEME_HTTPS | | 40 URLPattern::SCHEME_HTTP | URLPattern::SCHEME_HTTPS | |
40 URLPattern::SCHEME_FILE; | 41 URLPattern::SCHEME_FILE; |
41 URLPattern url_pattern(kAllowedSchemes); | 42 URLPattern url_pattern(kAllowedSchemes); |
42 URLPattern::ParseResult result = url_pattern.Parse(pattern_str); | 43 URLPattern::ParseResult result = url_pattern.Parse(pattern_str); |
43 if (result != URLPattern::PARSE_SUCCESS) { | 44 if (result != URLPattern::PARSE_SUCCESS) { |
44 *error = URLPattern::GetParseResultString(result); | 45 *error = URLPattern::GetParseResultString(result); |
45 return ContentSettingsPattern(); | 46 return ContentSettingsPattern(); |
46 } else { | 47 } else { |
47 scoped_ptr<ContentSettingsPattern::BuilderInterface> builder( | 48 std::unique_ptr<ContentSettingsPattern::BuilderInterface> builder( |
48 ContentSettingsPattern::CreateBuilder(false)); | 49 ContentSettingsPattern::CreateBuilder(false)); |
49 builder->WithHost(url_pattern.host()); | 50 builder->WithHost(url_pattern.host()); |
50 if (url_pattern.match_subdomains()) | 51 if (url_pattern.match_subdomains()) |
51 builder->WithDomainWildcard(); | 52 builder->WithDomainWildcard(); |
52 | 53 |
53 std::string scheme = url_pattern.scheme(); | 54 std::string scheme = url_pattern.scheme(); |
54 if (scheme == "*") | 55 if (scheme == "*") |
55 builder->WithSchemeWildcard(); | 56 builder->WithSchemeWildcard(); |
56 else | 57 else |
57 builder->WithScheme(scheme); | 58 builder->WithScheme(scheme); |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
102 } | 103 } |
103 | 104 |
104 std::string ContentSettingsTypeToString(ContentSettingsType type) { | 105 std::string ContentSettingsTypeToString(ContentSettingsType type) { |
105 return content_settings::WebsiteSettingsRegistry::GetInstance() | 106 return content_settings::WebsiteSettingsRegistry::GetInstance() |
106 ->Get(type) | 107 ->Get(type) |
107 ->name(); | 108 ->name(); |
108 } | 109 } |
109 | 110 |
110 } // namespace content_settings_helpers | 111 } // namespace content_settings_helpers |
111 } // namespace extensions | 112 } // namespace extensions |
OLD | NEW |