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/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
10 #include "base/values.h" | 10 #include "base/values.h" |
(...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
341 const std::vector<const std::string*>& array) { | 341 const std::vector<const std::string*>& array) { |
342 const size_t length = array.size(); | 342 const size_t length = array.size(); |
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 scoped_ptr<Value> entry_owned; |
351 ListValue* list = NULL; | 352 ListValue* list = NULL; |
352 if (!dictionary->GetWithoutPathExpansion(*name, &entry)) | 353 if (!dictionary->GetWithoutPathExpansion(*name, &entry)) |
353 return scoped_ptr<DictionaryValue>(); | 354 return scoped_ptr<DictionaryValue>(); |
354 switch (entry->GetType()) { | 355 switch (entry->GetType()) { |
355 case Value::TYPE_STRING: // Replace the present string with a list. | 356 case Value::TYPE_STRING: // Replace the present string with a list. |
356 list = new ListValue; | 357 list = new ListValue; |
357 // Ignoring return value, we already verified the entry is there. | 358 // Ignoring return value, we already verified the entry is there. |
358 dictionary->RemoveWithoutPathExpansion(*name, &entry); | 359 dictionary->RemoveWithoutPathExpansion(*name, &entry_owned); |
359 list->Append(entry); | 360 list->Append(entry_owned.release()); |
360 list->Append(Value::CreateStringValue(*value)); | 361 list->Append(Value::CreateStringValue(*value)); |
361 dictionary->SetWithoutPathExpansion(*name, list); | 362 dictionary->SetWithoutPathExpansion(*name, list); |
362 break; | 363 break; |
363 case Value::TYPE_LIST: // Just append to the list. | 364 case Value::TYPE_LIST: // Just append to the list. |
364 CHECK(entry->GetAsList(&list)); | 365 CHECK(entry->GetAsList(&list)); |
365 list->Append(Value::CreateStringValue(*value)); | 366 list->Append(Value::CreateStringValue(*value)); |
366 break; | 367 break; |
367 default: | 368 default: |
368 NOTREACHED(); // We never put other Values here. | 369 NOTREACHED(); // We never put other Values here. |
369 return scoped_ptr<DictionaryValue>(); | 370 return scoped_ptr<DictionaryValue>(); |
(...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
663 keys::kValueEqualsKey, "valueB" | 664 keys::kValueEqualsKey, "valueB" |
664 }; | 665 }; |
665 const size_t kExistingSize[] = { arraysize(kExisting) }; | 666 const size_t kExistingSize[] = { arraysize(kExisting) }; |
666 GetArrayAsVector(kExisting, kExistingSize, 1u, &tests); | 667 GetArrayAsVector(kExisting, kExistingSize, 1u, &tests); |
667 MatchAndCheck( | 668 MatchAndCheck( |
668 tests, keys::kExcludeResponseHeadersKey, stage, &url_request, &result); | 669 tests, keys::kExcludeResponseHeadersKey, stage, &url_request, &result); |
669 EXPECT_FALSE(result); | 670 EXPECT_FALSE(result); |
670 } | 671 } |
671 | 672 |
672 } // namespace extensions | 673 } // namespace extensions |
OLD | NEW |