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 "components/content_settings/core/browser/content_settings_utils.h" | 5 #include "components/content_settings/core/browser/content_settings_utils.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
105 | 105 |
106 std::string CreatePatternString( | 106 std::string CreatePatternString( |
107 const ContentSettingsPattern& item_pattern, | 107 const ContentSettingsPattern& item_pattern, |
108 const ContentSettingsPattern& top_level_frame_pattern) { | 108 const ContentSettingsPattern& top_level_frame_pattern) { |
109 return item_pattern.ToString() | 109 return item_pattern.ToString() |
110 + std::string(kPatternSeparator) | 110 + std::string(kPatternSeparator) |
111 + top_level_frame_pattern.ToString(); | 111 + top_level_frame_pattern.ToString(); |
112 } | 112 } |
113 | 113 |
114 PatternPair ParsePatternString(const std::string& pattern_str) { | 114 PatternPair ParsePatternString(const std::string& pattern_str) { |
115 std::vector<std::string> pattern_str_list; | 115 std::vector<std::string> pattern_str_list = base::SplitString( |
116 base::SplitString(pattern_str, kPatternSeparator[0], &pattern_str_list); | 116 pattern_str, std::string(1, kPatternSeparator[0]), |
| 117 base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL); |
117 | 118 |
118 // If the |pattern_str| is an empty string then the |pattern_string_list| | 119 // If the |pattern_str| is an empty string then the |pattern_string_list| |
119 // contains a single empty string. In this case the empty string will be | 120 // contains a single empty string. In this case the empty string will be |
120 // removed to signal an invalid |pattern_str|. Invalid pattern strings are | 121 // removed to signal an invalid |pattern_str|. Invalid pattern strings are |
121 // handle by the "if"-statment below. So the order of the if statements here | 122 // handle by the "if"-statment below. So the order of the if statements here |
122 // must be preserved. | 123 // must be preserved. |
123 if (pattern_str_list.size() == 1) { | 124 if (pattern_str_list.size() == 1) { |
124 if (pattern_str_list[0].empty()) { | 125 if (pattern_str_list[0].empty()) { |
125 pattern_str_list.pop_back(); | 126 pattern_str_list.pop_back(); |
126 } else { | 127 } else { |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
237 if (IsContentSettingsTypeSyncable(content_type)) | 238 if (IsContentSettingsTypeSyncable(content_type)) |
238 flags |= user_prefs::PrefRegistrySyncable::SYNCABLE_PREF; | 239 flags |= user_prefs::PrefRegistrySyncable::SYNCABLE_PREF; |
239 | 240 |
240 if (IsContentSettingsTypeLossy(content_type)) | 241 if (IsContentSettingsTypeLossy(content_type)) |
241 flags |= PrefRegistry::LOSSY_PREF; | 242 flags |= PrefRegistry::LOSSY_PREF; |
242 | 243 |
243 return flags; | 244 return flags; |
244 } | 245 } |
245 | 246 |
246 } // namespace content_settings | 247 } // namespace content_settings |
OLD | NEW |