OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/content_settings/content_settings_provider.h" | 5 #include "chrome/browser/content_settings/content_settings_provider.h" |
6 | 6 |
7 namespace content_settings { | 7 namespace content_settings { |
8 | 8 |
9 ProviderInterface::Rule::Rule() | 9 ProviderInterface::Rule::Rule() |
10 : content_setting(CONTENT_SETTING_DEFAULT) { | 10 : content_setting(CONTENT_SETTING_DEFAULT) { |
11 } | 11 } |
12 | 12 |
13 ProviderInterface::Rule::Rule(const ContentSettingsPattern& primary_pattern, | 13 ProviderInterface::Rule::Rule(const ContentSettingsPattern& primary_pattern, |
14 const ContentSettingsPattern& secondary_pattern, | 14 const ContentSettingsPattern& secondary_pattern, |
15 ContentSetting setting) | 15 ContentSetting setting) |
16 : primary_pattern(primary_pattern), | 16 : primary_pattern(primary_pattern), |
17 secondary_pattern(secondary_pattern), | 17 secondary_pattern(secondary_pattern), |
18 content_setting(setting) { | 18 content_setting(setting) { |
19 } | 19 } |
20 | 20 |
| 21 // static |
| 22 bool ProviderInterface::Rule::LexicographicalSort( |
| 23 const ProviderInterface::Rule& a, |
| 24 const ProviderInterface::Rule& b) { |
| 25 if (a.primary_pattern.ToString() < b.primary_pattern.ToString()) |
| 26 return true; |
| 27 if (b.primary_pattern.ToString() < a.primary_pattern.ToString()) |
| 28 return false; |
| 29 return (a.secondary_pattern.ToString() < b.secondary_pattern.ToString()); |
| 30 } |
| 31 |
| 32 // static |
| 33 bool ProviderInterface::Rule::PatternPrecedenceSort( |
| 34 const ProviderInterface::Rule& a, |
| 35 const ProviderInterface::Rule& b) { |
| 36 if (a.primary_pattern < b.primary_pattern) |
| 37 return true; |
| 38 if (b.primary_pattern < a.primary_pattern) |
| 39 return false; |
| 40 return (a.secondary_pattern < b.secondary_pattern); |
| 41 } |
| 42 |
21 } // namespace content_settings | 43 } // namespace content_settings |
OLD | NEW |