| 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 "base/basictypes.h" | 7 #include "base/basictypes.h" |
| 8 #include "base/files/file_path.h" | 8 #include "base/files/file_path.h" |
| 9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
| 10 #include "base/values.h" | 10 #include "base/values.h" |
| (...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 343 CHECK(length % 2 == 0); | 343 CHECK(length % 2 == 0); |
| 344 | 344 |
| 345 scoped_ptr<DictionaryValue> dictionary(new DictionaryValue); | 345 scoped_ptr<DictionaryValue> dictionary(new DictionaryValue); |
| 346 for (size_t i = 0; i < length; i += 2) { | 346 for (size_t i = 0; i < length; i += 2) { |
| 347 const std::string* name = array[i]; | 347 const std::string* name = array[i]; |
| 348 const std::string* value = array[i+1]; | 348 const std::string* value = array[i+1]; |
| 349 if (dictionary->HasKey(*name)) { | 349 if (dictionary->HasKey(*name)) { |
| 350 Value* entry = NULL; | 350 Value* entry = NULL; |
| 351 ListValue* list = NULL; | 351 ListValue* list = NULL; |
| 352 if (!dictionary->GetWithoutPathExpansion(*name, &entry)) | 352 if (!dictionary->GetWithoutPathExpansion(*name, &entry)) |
| 353 return scoped_ptr<DictionaryValue>(NULL); | 353 return scoped_ptr<DictionaryValue>(); |
| 354 switch (entry->GetType()) { | 354 switch (entry->GetType()) { |
| 355 case Value::TYPE_STRING: // Replace the present string with a list. | 355 case Value::TYPE_STRING: // Replace the present string with a list. |
| 356 list = new ListValue; | 356 list = new ListValue; |
| 357 // Ignoring return value, we already verified the entry is there. | 357 // Ignoring return value, we already verified the entry is there. |
| 358 dictionary->RemoveWithoutPathExpansion(*name, &entry); | 358 dictionary->RemoveWithoutPathExpansion(*name, &entry); |
| 359 list->Append(entry); | 359 list->Append(entry); |
| 360 list->Append(Value::CreateStringValue(*value)); | 360 list->Append(Value::CreateStringValue(*value)); |
| 361 dictionary->SetWithoutPathExpansion(*name, list); | 361 dictionary->SetWithoutPathExpansion(*name, list); |
| 362 break; | 362 break; |
| 363 case Value::TYPE_LIST: // Just append to the list. | 363 case Value::TYPE_LIST: // Just append to the list. |
| 364 CHECK(entry->GetAsList(&list)); | 364 CHECK(entry->GetAsList(&list)); |
| 365 list->Append(Value::CreateStringValue(*value)); | 365 list->Append(Value::CreateStringValue(*value)); |
| 366 break; | 366 break; |
| 367 default: | 367 default: |
| 368 NOTREACHED(); // We never put other Values here. | 368 NOTREACHED(); // We never put other Values here. |
| 369 return scoped_ptr<DictionaryValue>(NULL); | 369 return scoped_ptr<DictionaryValue>(); |
| 370 } | 370 } |
| 371 } else { | 371 } else { |
| 372 dictionary->SetString(*name, *value); | 372 dictionary->SetString(*name, *value); |
| 373 } | 373 } |
| 374 } | 374 } |
| 375 return dictionary.Pass(); | 375 return dictionary.Pass(); |
| 376 } | 376 } |
| 377 | 377 |
| 378 // Returns whether the response headers from |url_request| satisfy the match | 378 // Returns whether the response headers from |url_request| satisfy the match |
| 379 // criteria given in |tests|. For at least one |i| all tests from |tests[i]| | 379 // criteria given in |tests|. For at least one |i| all tests from |tests[i]| |
| (...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 663 keys::kValueEqualsKey, "valueB" | 663 keys::kValueEqualsKey, "valueB" |
| 664 }; | 664 }; |
| 665 const size_t kExistingSize[] = { arraysize(kExisting) }; | 665 const size_t kExistingSize[] = { arraysize(kExisting) }; |
| 666 GetArrayAsVector(kExisting, kExistingSize, 1u, &tests); | 666 GetArrayAsVector(kExisting, kExistingSize, 1u, &tests); |
| 667 MatchAndCheck( | 667 MatchAndCheck( |
| 668 tests, keys::kExcludeResponseHeadersKey, stage, &url_request, &result); | 668 tests, keys::kExcludeResponseHeadersKey, stage, &url_request, &result); |
| 669 EXPECT_FALSE(result); | 669 EXPECT_FALSE(result); |
| 670 } | 670 } |
| 671 | 671 |
| 672 } // namespace extensions | 672 } // namespace extensions |
| OLD | NEW |