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

Side by Side Diff: chrome/browser/permissions/chooser_context_base.cc

Issue 2740143002: Change base::Value::ListStorage to std::vector<base::Value> (Closed)
Patch Set: Rebase Created 3 years, 8 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
« no previous file with comments | « chrome/browser/net/predictor_unittest.cc ('k') | chrome/browser/plugins/plugin_finder.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/permissions/chooser_context_base.h" 5 #include "chrome/browser/permissions/chooser_context_base.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/memory/ptr_util.h" 9 #include "base/memory/ptr_util.h"
10 #include "chrome/browser/content_settings/host_content_settings_map_factory.h" 10 #include "chrome/browser/content_settings/host_content_settings_map_factory.h"
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 return results; 51 return results;
52 52
53 std::unique_ptr<base::ListValue> object_list = 53 std::unique_ptr<base::ListValue> object_list =
54 base::ListValue::From(std::move(objects)); 54 base::ListValue::From(std::move(objects));
55 if (!object_list) 55 if (!object_list)
56 return results; 56 return results;
57 57
58 for (auto& object : *object_list) { 58 for (auto& object : *object_list) {
59 // Steal ownership of |object| from |object_list|. 59 // Steal ownership of |object| from |object_list|.
60 std::unique_ptr<base::DictionaryValue> object_dict = 60 std::unique_ptr<base::DictionaryValue> object_dict =
61 base::DictionaryValue::From(std::move(object)); 61 base::DictionaryValue::From(
62 base::MakeUnique<base::Value>(std::move(object)));
62 if (object_dict && IsValidObject(*object_dict)) 63 if (object_dict && IsValidObject(*object_dict))
63 results.push_back(std::move(object_dict)); 64 results.push_back(std::move(object_dict));
64 } 65 }
65 return results; 66 return results;
66 } 67 }
67 68
68 std::vector<std::unique_ptr<ChooserContextBase::Object>> 69 std::vector<std::unique_ptr<ChooserContextBase::Object>>
69 ChooserContextBase::GetAllGrantedObjects() { 70 ChooserContextBase::GetAllGrantedObjects() {
70 ContentSettingsForOneType content_settings; 71 ContentSettingsForOneType content_settings;
71 host_content_settings_map_->GetSettingsForOneType( 72 host_content_settings_map_->GetSettingsForOneType(
72 data_content_settings_type_, std::string(), &content_settings); 73 data_content_settings_type_, std::string(), &content_settings);
73 74
74 std::vector<std::unique_ptr<Object>> results; 75 std::vector<std::unique_ptr<Object>> results;
75 for (const ContentSettingPatternSource& content_setting : content_settings) { 76 for (const ContentSettingPatternSource& content_setting : content_settings) {
76 GURL requesting_origin(content_setting.primary_pattern.ToString()); 77 GURL requesting_origin(content_setting.primary_pattern.ToString());
77 GURL embedding_origin(content_setting.secondary_pattern.ToString()); 78 GURL embedding_origin(content_setting.secondary_pattern.ToString());
78 if (!requesting_origin.is_valid() || !embedding_origin.is_valid()) 79 if (!requesting_origin.is_valid() || !embedding_origin.is_valid())
79 continue; 80 continue;
80 81
81 std::unique_ptr<base::DictionaryValue> setting = 82 std::unique_ptr<base::DictionaryValue> setting =
82 GetWebsiteSetting(requesting_origin, embedding_origin); 83 GetWebsiteSetting(requesting_origin, embedding_origin);
83 base::ListValue* object_list; 84 base::ListValue* object_list;
84 if (!setting->GetList(kObjectListKey, &object_list)) 85 if (!setting->GetList(kObjectListKey, &object_list))
85 continue; 86 continue;
86 87
87 for (const auto& object : *object_list) { 88 for (auto& object : *object_list) {
88 base::DictionaryValue* object_dict; 89 base::DictionaryValue* object_dict;
89 if (!object->GetAsDictionary(&object_dict) || 90 if (!object.GetAsDictionary(&object_dict) ||
90 !IsValidObject(*object_dict)) { 91 !IsValidObject(*object_dict)) {
91 continue; 92 continue;
92 } 93 }
93 94
94 results.push_back(base::MakeUnique<Object>( 95 results.push_back(base::MakeUnique<Object>(
95 requesting_origin, embedding_origin, object_dict, 96 requesting_origin, embedding_origin, object_dict,
96 content_setting.source, content_setting.incognito)); 97 content_setting.source, content_setting.incognito));
97 } 98 }
98 } 99 }
99 100
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 return value; 149 return value;
149 } 150 }
150 151
151 void ChooserContextBase::SetWebsiteSetting(const GURL& requesting_origin, 152 void ChooserContextBase::SetWebsiteSetting(const GURL& requesting_origin,
152 const GURL& embedding_origin, 153 const GURL& embedding_origin,
153 std::unique_ptr<base::Value> value) { 154 std::unique_ptr<base::Value> value) {
154 host_content_settings_map_->SetWebsiteSettingDefaultScope( 155 host_content_settings_map_->SetWebsiteSettingDefaultScope(
155 requesting_origin, embedding_origin, data_content_settings_type_, 156 requesting_origin, embedding_origin, data_content_settings_type_,
156 std::string(), std::move(value)); 157 std::string(), std::move(value));
157 } 158 }
OLDNEW
« no previous file with comments | « chrome/browser/net/predictor_unittest.cc ('k') | chrome/browser/plugins/plugin_finder.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698