| 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/declarative_content/content_condition.h" | 5 #include "chrome/browser/extensions/api/declarative_content/content_condition.h" |
| 6 | 6 |
| 7 #include "base/strings/stringprintf.h" | 7 #include "base/strings/stringprintf.h" |
| 8 #include "base/values.h" | 8 #include "base/values.h" |
| 9 #include "chrome/browser/extensions/api/declarative_content/content_constants.h" | 9 #include "chrome/browser/extensions/api/declarative_content/content_constants.h" |
| 10 #include "components/url_matcher/url_matcher_factory.h" | 10 #include "components/url_matcher/url_matcher_factory.h" |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 87 *error = kExpectedOtherConditionType; | 87 *error = kExpectedOtherConditionType; |
| 88 return scoped_ptr<ContentCondition>(); | 88 return scoped_ptr<ContentCondition>(); |
| 89 } | 89 } |
| 90 | 90 |
| 91 scoped_refptr<URLMatcherConditionSet> url_matcher_condition_set; | 91 scoped_refptr<URLMatcherConditionSet> url_matcher_condition_set; |
| 92 std::vector<std::string> css_rules; | 92 std::vector<std::string> css_rules; |
| 93 | 93 |
| 94 for (base::DictionaryValue::Iterator iter(*condition_dict); | 94 for (base::DictionaryValue::Iterator iter(*condition_dict); |
| 95 !iter.IsAtEnd(); iter.Advance()) { | 95 !iter.IsAtEnd(); iter.Advance()) { |
| 96 const std::string& condition_attribute_name = iter.key(); | 96 const std::string& condition_attribute_name = iter.key(); |
| 97 const Value& condition_attribute_value = iter.value(); | 97 const base::Value& condition_attribute_value = iter.value(); |
| 98 if (condition_attribute_name == keys::kInstanceType) { | 98 if (condition_attribute_name == keys::kInstanceType) { |
| 99 // Skip this. | 99 // Skip this. |
| 100 } else if (condition_attribute_name == keys::kPageUrl) { | 100 } else if (condition_attribute_name == keys::kPageUrl) { |
| 101 const base::DictionaryValue* dict = NULL; | 101 const base::DictionaryValue* dict = NULL; |
| 102 if (!condition_attribute_value.GetAsDictionary(&dict)) { | 102 if (!condition_attribute_value.GetAsDictionary(&dict)) { |
| 103 *error = base::StringPrintf(kInvalidTypeOfParamter, | 103 *error = base::StringPrintf(kInvalidTypeOfParamter, |
| 104 condition_attribute_name.c_str()); | 104 condition_attribute_name.c_str()); |
| 105 } else { | 105 } else { |
| 106 url_matcher_condition_set = | 106 url_matcher_condition_set = |
| 107 URLMatcherFactory::CreateFromURLFilterDictionary( | 107 URLMatcherFactory::CreateFromURLFilterDictionary( |
| (...skipping 29 matching lines...) Expand all Loading... |
| 137 url_matcher_condition_factory->CreateHostPrefixCondition( | 137 url_matcher_condition_factory->CreateHostPrefixCondition( |
| 138 std::string())); | 138 std::string())); |
| 139 url_matcher_condition_set = | 139 url_matcher_condition_set = |
| 140 new URLMatcherConditionSet(++g_next_id, url_matcher_conditions); | 140 new URLMatcherConditionSet(++g_next_id, url_matcher_conditions); |
| 141 } | 141 } |
| 142 return scoped_ptr<ContentCondition>( | 142 return scoped_ptr<ContentCondition>( |
| 143 new ContentCondition(url_matcher_condition_set, css_rules)); | 143 new ContentCondition(url_matcher_condition_set, css_rules)); |
| 144 } | 144 } |
| 145 | 145 |
| 146 } // namespace extensions | 146 } // namespace extensions |
| OLD | NEW |