OLD | NEW |
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 Loading... |
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( | 61 base::DictionaryValue::From(std::move(object)); |
62 base::MakeUnique<base::Value>(std::move(object))); | |
63 if (object_dict && IsValidObject(*object_dict)) | 62 if (object_dict && IsValidObject(*object_dict)) |
64 results.push_back(std::move(object_dict)); | 63 results.push_back(std::move(object_dict)); |
65 } | 64 } |
66 return results; | 65 return results; |
67 } | 66 } |
68 | 67 |
69 std::vector<std::unique_ptr<ChooserContextBase::Object>> | 68 std::vector<std::unique_ptr<ChooserContextBase::Object>> |
70 ChooserContextBase::GetAllGrantedObjects() { | 69 ChooserContextBase::GetAllGrantedObjects() { |
71 ContentSettingsForOneType content_settings; | 70 ContentSettingsForOneType content_settings; |
72 host_content_settings_map_->GetSettingsForOneType( | 71 host_content_settings_map_->GetSettingsForOneType( |
73 data_content_settings_type_, std::string(), &content_settings); | 72 data_content_settings_type_, std::string(), &content_settings); |
74 | 73 |
75 std::vector<std::unique_ptr<Object>> results; | 74 std::vector<std::unique_ptr<Object>> results; |
76 for (const ContentSettingPatternSource& content_setting : content_settings) { | 75 for (const ContentSettingPatternSource& content_setting : content_settings) { |
77 GURL requesting_origin(content_setting.primary_pattern.ToString()); | 76 GURL requesting_origin(content_setting.primary_pattern.ToString()); |
78 GURL embedding_origin(content_setting.secondary_pattern.ToString()); | 77 GURL embedding_origin(content_setting.secondary_pattern.ToString()); |
79 if (!requesting_origin.is_valid() || !embedding_origin.is_valid()) | 78 if (!requesting_origin.is_valid() || !embedding_origin.is_valid()) |
80 continue; | 79 continue; |
81 | 80 |
82 std::unique_ptr<base::DictionaryValue> setting = | 81 std::unique_ptr<base::DictionaryValue> setting = |
83 GetWebsiteSetting(requesting_origin, embedding_origin); | 82 GetWebsiteSetting(requesting_origin, embedding_origin); |
84 base::ListValue* object_list; | 83 base::ListValue* object_list; |
85 if (!setting->GetList(kObjectListKey, &object_list)) | 84 if (!setting->GetList(kObjectListKey, &object_list)) |
86 continue; | 85 continue; |
87 | 86 |
88 for (auto& object : *object_list) { | 87 for (const auto& object : *object_list) { |
89 base::DictionaryValue* object_dict; | 88 base::DictionaryValue* object_dict; |
90 if (!object.GetAsDictionary(&object_dict) || | 89 if (!object->GetAsDictionary(&object_dict) || |
91 !IsValidObject(*object_dict)) { | 90 !IsValidObject(*object_dict)) { |
92 continue; | 91 continue; |
93 } | 92 } |
94 | 93 |
95 results.push_back(base::MakeUnique<Object>( | 94 results.push_back(base::MakeUnique<Object>( |
96 requesting_origin, embedding_origin, object_dict, | 95 requesting_origin, embedding_origin, object_dict, |
97 content_setting.source, content_setting.incognito)); | 96 content_setting.source, content_setting.incognito)); |
98 } | 97 } |
99 } | 98 } |
100 | 99 |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
149 return value; | 148 return value; |
150 } | 149 } |
151 | 150 |
152 void ChooserContextBase::SetWebsiteSetting(const GURL& requesting_origin, | 151 void ChooserContextBase::SetWebsiteSetting(const GURL& requesting_origin, |
153 const GURL& embedding_origin, | 152 const GURL& embedding_origin, |
154 std::unique_ptr<base::Value> value) { | 153 std::unique_ptr<base::Value> value) { |
155 host_content_settings_map_->SetWebsiteSettingDefaultScope( | 154 host_content_settings_map_->SetWebsiteSettingDefaultScope( |
156 requesting_origin, embedding_origin, data_content_settings_type_, | 155 requesting_origin, embedding_origin, data_content_settings_type_, |
157 std::string(), std::move(value)); | 156 std::string(), std::move(value)); |
158 } | 157 } |
OLD | NEW |