Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(116)

Side by Side Diff: extensions/browser/api/declarative_webrequest/webrequest_condition_attribute_unittest.cc

Issue 2843813002: Remove SetWithoutPathExpansion (Closed)
Patch Set: Fix CrOS Error Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 "extensions/browser/api/declarative_webrequest/webrequest_condition_att ribute.h" 5 #include "extensions/browser/api/declarative_webrequest/webrequest_condition_att ribute.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <memory> 9 #include <memory>
10 #include <utility> 10 #include <utility>
(...skipping 367 matching lines...) Expand 10 before | Expand all | Expand 10 after
378 const size_t length = array.size(); 378 const size_t length = array.size();
379 CHECK(length % 2 == 0); 379 CHECK(length % 2 == 0);
380 380
381 std::unique_ptr<base::DictionaryValue> dictionary(new base::DictionaryValue); 381 std::unique_ptr<base::DictionaryValue> dictionary(new base::DictionaryValue);
382 for (size_t i = 0; i < length; i += 2) { 382 for (size_t i = 0; i < length; i += 2) {
383 const std::string* name = array[i]; 383 const std::string* name = array[i];
384 const std::string* value = array[i+1]; 384 const std::string* value = array[i+1];
385 if (dictionary->HasKey(*name)) { 385 if (dictionary->HasKey(*name)) {
386 base::Value* entry = NULL; 386 base::Value* entry = NULL;
387 std::unique_ptr<base::Value> entry_owned; 387 std::unique_ptr<base::Value> entry_owned;
388 base::ListValue* list = NULL; 388 std::unique_ptr<base::ListValue> list;
389 if (!dictionary->GetWithoutPathExpansion(*name, &entry)) 389 if (!dictionary->GetWithoutPathExpansion(*name, &entry))
390 return std::unique_ptr<base::DictionaryValue>(); 390 return std::unique_ptr<base::DictionaryValue>();
391 switch (entry->GetType()) { 391 switch (entry->GetType()) {
392 case base::Value::Type::STRING: 392 case base::Value::Type::STRING:
393 // Replace the present string with a list. 393 // Replace the present string with a list.
394 list = new base::ListValue; 394 list = base::MakeUnique<base::ListValue>();
395 // Ignoring return value, we already verified the entry is there. 395 // Ignoring return value, we already verified the entry is there.
396 dictionary->RemoveWithoutPathExpansion(*name, &entry_owned); 396 dictionary->RemoveWithoutPathExpansion(*name, &entry_owned);
397 list->Append(std::move(entry_owned)); 397 list->Append(std::move(entry_owned));
398 list->AppendString(*value); 398 list->AppendString(*value);
399 dictionary->SetWithoutPathExpansion(*name, base::WrapUnique(list)); 399 dictionary->SetWithoutPathExpansion(*name, std::move(list));
400 break; 400 break;
401 case base::Value::Type::LIST: // Just append to the list. 401 case base::Value::Type::LIST: // Just append to the list.
402 CHECK(entry->GetAsList(&list)); 402 entry->GetList().emplace_back(*value);
403 list->AppendString(*value);
404 break; 403 break;
405 default: 404 default:
406 NOTREACHED(); // We never put other Values here. 405 NOTREACHED(); // We never put other Values here.
407 return std::unique_ptr<base::DictionaryValue>(); 406 return std::unique_ptr<base::DictionaryValue>();
408 } 407 }
409 } else { 408 } else {
410 dictionary->SetString(*name, *value); 409 dictionary->SetString(*name, *value);
411 } 410 }
412 } 411 }
413 return dictionary; 412 return dictionary;
(...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after
719 }; 718 };
720 const size_t kExistingSize[] = { arraysize(kExisting) }; 719 const size_t kExistingSize[] = { arraysize(kExisting) };
721 GetArrayAsVector(kExisting, kExistingSize, 1u, &tests); 720 GetArrayAsVector(kExisting, kExistingSize, 1u, &tests);
722 MatchAndCheck(tests, keys::kExcludeResponseHeadersKey, stage, 721 MatchAndCheck(tests, keys::kExcludeResponseHeadersKey, stage,
723 url_request.get(), &result); 722 url_request.get(), &result);
724 EXPECT_FALSE(result); 723 EXPECT_FALSE(result);
725 } 724 }
726 725
727 } // namespace 726 } // namespace
728 } // namespace extensions 727 } // namespace extensions
OLDNEW
« no previous file with comments | « extensions/browser/api/bluetooth_low_energy/utils.cc ('k') | extensions/browser/api/web_request/upload_data_presenter.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698