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

Side by Side Diff: content/browser/mojo/merge_dictionary.cc

Issue 2259903002: Enforce capability spec renderer <--> browser (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . Created 4 years, 3 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
(Empty)
1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "content/browser/mojo/merge_dictionary.h"
6
7 namespace content {
8
9 void MergeDictionary(base::DictionaryValue* target,
10 const base::DictionaryValue* source) {
11 for (base::DictionaryValue::Iterator it(*source); !it.IsAtEnd();
12 it.Advance()) {
13 const base::Value* merge_value = &it.value();
14 // Check whether we have to merge dictionaries.
15 if (merge_value->IsType(base::Value::TYPE_DICTIONARY)) {
16 base::DictionaryValue* sub_dict;
17 if (target->GetDictionaryWithoutPathExpansion(it.key(), &sub_dict)) {
18 MergeDictionary(
19 sub_dict,
20 static_cast<const base::DictionaryValue*>(merge_value));
21 continue;
22 }
23 }
24 bool needs_clobber = true;
25 if (merge_value->IsType(base::Value::TYPE_LIST)) {
26 const base::ListValue* merge_list = nullptr;
27 if (merge_value->GetAsList(&merge_list)) {
28 base::ListValue* target_list = nullptr;
29 if (target->GetListWithoutPathExpansion(it.key(), &target_list)) {
30 for (size_t i = 0; i < merge_list->GetSize(); ++i) {
31 std::string value;
32 CHECK(merge_list->GetString(i, &value));
Ken Rockot(use gerrit already) 2016/09/15 20:08:46 Any reason to enforce that every list is only of s
33 target_list->AppendString(value);
34 }
35 needs_clobber = false;
Ken Rockot(use gerrit already) 2016/09/15 20:08:45 nit: You could just continue here like you do abov
36 }
37 }
38 }
39 if (needs_clobber) {
40 // All other cases: Make a copy and hook it up.
41 target->SetWithoutPathExpansion(it.key(), merge_value->DeepCopy());
42 }
43 }
44 }
45
46 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/mojo/merge_dictionary.h ('k') | content/browser/mojo/merge_dictionary_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698