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_webrequest/webrequest_condit
ion_attribute.h" | 5 #include "chrome/browser/extensions/api/declarative_webrequest/webrequest_condit
ion_attribute.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/lazy_instance.h" | 9 #include "base/lazy_instance.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
118 return g_web_request_condition_attribute_factory.Get().factory.Instantiate( | 118 return g_web_request_condition_attribute_factory.Get().factory.Instantiate( |
119 name, value, error, &bad_message); | 119 name, value, error, &bad_message); |
120 } | 120 } |
121 | 121 |
122 // | 122 // |
123 // WebRequestConditionAttributeResourceType | 123 // WebRequestConditionAttributeResourceType |
124 // | 124 // |
125 | 125 |
126 WebRequestConditionAttributeResourceType:: | 126 WebRequestConditionAttributeResourceType:: |
127 WebRequestConditionAttributeResourceType( | 127 WebRequestConditionAttributeResourceType( |
128 const std::vector<ResourceType::Type>& types) | 128 const std::vector<ResourceType>& types) |
129 : types_(types) {} | 129 : types_(types) {} |
130 | 130 |
131 WebRequestConditionAttributeResourceType:: | 131 WebRequestConditionAttributeResourceType:: |
132 ~WebRequestConditionAttributeResourceType() {} | 132 ~WebRequestConditionAttributeResourceType() {} |
133 | 133 |
134 // static | 134 // static |
135 scoped_refptr<const WebRequestConditionAttribute> | 135 scoped_refptr<const WebRequestConditionAttribute> |
136 WebRequestConditionAttributeResourceType::Create( | 136 WebRequestConditionAttributeResourceType::Create( |
137 const std::string& instance_type, | 137 const std::string& instance_type, |
138 const base::Value* value, | 138 const base::Value* value, |
139 std::string* error, | 139 std::string* error, |
140 bool* bad_message) { | 140 bool* bad_message) { |
141 DCHECK(instance_type == keys::kResourceTypeKey); | 141 DCHECK(instance_type == keys::kResourceTypeKey); |
142 const base::ListValue* value_as_list = NULL; | 142 const base::ListValue* value_as_list = NULL; |
143 if (!value->GetAsList(&value_as_list)) { | 143 if (!value->GetAsList(&value_as_list)) { |
144 *error = ErrorUtils::FormatErrorMessage(kInvalidValue, | 144 *error = ErrorUtils::FormatErrorMessage(kInvalidValue, |
145 keys::kResourceTypeKey); | 145 keys::kResourceTypeKey); |
146 return scoped_refptr<const WebRequestConditionAttribute>(NULL); | 146 return scoped_refptr<const WebRequestConditionAttribute>(NULL); |
147 } | 147 } |
148 | 148 |
149 size_t number_types = value_as_list->GetSize(); | 149 size_t number_types = value_as_list->GetSize(); |
150 | 150 |
151 std::vector<ResourceType::Type> passed_types; | 151 std::vector<ResourceType> passed_types; |
152 passed_types.reserve(number_types); | 152 passed_types.reserve(number_types); |
153 for (size_t i = 0; i < number_types; ++i) { | 153 for (size_t i = 0; i < number_types; ++i) { |
154 std::string resource_type_string; | 154 std::string resource_type_string; |
155 ResourceType::Type type = ResourceType::LAST_TYPE; | 155 ResourceType type = content::RESOURCE_TYPE_LAST_TYPE; |
156 if (!value_as_list->GetString(i, &resource_type_string) || | 156 if (!value_as_list->GetString(i, &resource_type_string) || |
157 !helpers::ParseResourceType(resource_type_string, &type)) { | 157 !helpers::ParseResourceType(resource_type_string, &type)) { |
158 *error = ErrorUtils::FormatErrorMessage(kInvalidValue, | 158 *error = ErrorUtils::FormatErrorMessage(kInvalidValue, |
159 keys::kResourceTypeKey); | 159 keys::kResourceTypeKey); |
160 return scoped_refptr<const WebRequestConditionAttribute>(NULL); | 160 return scoped_refptr<const WebRequestConditionAttribute>(NULL); |
161 } | 161 } |
162 passed_types.push_back(type); | 162 passed_types.push_back(type); |
163 } | 163 } |
164 | 164 |
165 return scoped_refptr<const WebRequestConditionAttribute>( | 165 return scoped_refptr<const WebRequestConditionAttribute>( |
(...skipping 703 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
869 bool WebRequestConditionAttributeStages::Equals( | 869 bool WebRequestConditionAttributeStages::Equals( |
870 const WebRequestConditionAttribute* other) const { | 870 const WebRequestConditionAttribute* other) const { |
871 if (!WebRequestConditionAttribute::Equals(other)) | 871 if (!WebRequestConditionAttribute::Equals(other)) |
872 return false; | 872 return false; |
873 const WebRequestConditionAttributeStages* casted_other = | 873 const WebRequestConditionAttributeStages* casted_other = |
874 static_cast<const WebRequestConditionAttributeStages*>(other); | 874 static_cast<const WebRequestConditionAttributeStages*>(other); |
875 return allowed_stages_ == casted_other->allowed_stages_; | 875 return allowed_stages_ == casted_other->allowed_stages_; |
876 } | 876 } |
877 | 877 |
878 } // namespace extensions | 878 } // namespace extensions |
OLD | NEW |