Chromium Code Reviews| 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/content_settings/content_settings_api.h" | 5 #include "chrome/browser/extensions/api/content_settings/content_settings_api.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 #include <set> | 8 #include <set> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 158 if (content_type == CONTENT_SETTINGS_TYPE_COOKIES) { | 158 if (content_type == CONTENT_SETTINGS_TYPE_COOKIES) { |
| 159 // TODO(jochen): Do we return the value for setting or for reading cookies? | 159 // TODO(jochen): Do we return the value for setting or for reading cookies? |
| 160 bool setting_cookie = false; | 160 bool setting_cookie = false; |
| 161 setting = cookie_settings->GetCookieSetting(primary_url, secondary_url, | 161 setting = cookie_settings->GetCookieSetting(primary_url, secondary_url, |
| 162 setting_cookie, NULL); | 162 setting_cookie, NULL); |
| 163 } else { | 163 } else { |
| 164 setting = map->GetContentSetting(primary_url, secondary_url, content_type, | 164 setting = map->GetContentSetting(primary_url, secondary_url, content_type, |
| 165 resource_identifier); | 165 resource_identifier); |
| 166 } | 166 } |
| 167 | 167 |
| 168 base::DictionaryValue* result = new base::DictionaryValue(); | 168 std::unique_ptr<base::DictionaryValue> result(new base::DictionaryValue()); |
| 169 std::string setting_string = | 169 std::string setting_string = |
| 170 content_settings::ContentSettingToString(setting); | 170 content_settings::ContentSettingToString(setting); |
| 171 DCHECK(!setting_string.empty()); | 171 DCHECK(!setting_string.empty()); |
| 172 result->SetString(keys::kContentSettingKey, setting_string); | 172 result->SetString(keys::kContentSettingKey, setting_string); |
| 173 | 173 |
| 174 SetResult(result); | 174 SetResult(std::move(result)); |
| 175 | 175 |
| 176 return true; | 176 return true; |
| 177 } | 177 } |
| 178 | 178 |
| 179 bool ContentSettingsContentSettingSetFunction::RunSync() { | 179 bool ContentSettingsContentSettingSetFunction::RunSync() { |
| 180 ContentSettingsType content_type; | 180 ContentSettingsType content_type; |
| 181 EXTENSION_FUNCTION_VALIDATE(RemoveContentType(args_.get(), &content_type)); | 181 EXTENSION_FUNCTION_VALIDATE(RemoveContentType(args_.get(), &content_type)); |
| 182 | 182 |
| 183 std::unique_ptr<Set::Params> params(Set::Params::Create(*args_)); | 183 std::unique_ptr<Set::Params> params(Set::Params::Create(*args_)); |
| 184 EXTENSION_FUNCTION_VALIDATE(params.get()); | 184 EXTENSION_FUNCTION_VALIDATE(params.get()); |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 299 base::Bind(&ContentSettingsContentSettingGetResourceIdentifiersFunction:: | 299 base::Bind(&ContentSettingsContentSettingGetResourceIdentifiersFunction:: |
| 300 OnGotPlugins, | 300 OnGotPlugins, |
| 301 this)); | 301 this)); |
| 302 return true; | 302 return true; |
| 303 } | 303 } |
| 304 | 304 |
| 305 void ContentSettingsContentSettingGetResourceIdentifiersFunction::OnGotPlugins( | 305 void ContentSettingsContentSettingGetResourceIdentifiersFunction::OnGotPlugins( |
| 306 const std::vector<content::WebPluginInfo>& plugins) { | 306 const std::vector<content::WebPluginInfo>& plugins) { |
| 307 PluginFinder* finder = PluginFinder::GetInstance(); | 307 PluginFinder* finder = PluginFinder::GetInstance(); |
| 308 std::set<std::string> group_identifiers; | 308 std::set<std::string> group_identifiers; |
| 309 base::ListValue* list = new base::ListValue(); | 309 std::unique_ptr<base::ListValue> list(new base::ListValue()); |
| 310 for (std::vector<content::WebPluginInfo>::const_iterator it = plugins.begin(); | 310 for (std::vector<content::WebPluginInfo>::const_iterator it = plugins.begin(); |
| 311 it != plugins.end(); ++it) { | 311 it != plugins.end(); ++it) { |
| 312 std::unique_ptr<PluginMetadata> plugin_metadata( | 312 std::unique_ptr<PluginMetadata> plugin_metadata( |
| 313 finder->GetPluginMetadata(*it)); | 313 finder->GetPluginMetadata(*it)); |
| 314 const std::string& group_identifier = plugin_metadata->identifier(); | 314 const std::string& group_identifier = plugin_metadata->identifier(); |
| 315 if (group_identifiers.find(group_identifier) != group_identifiers.end()) | 315 if (group_identifiers.find(group_identifier) != group_identifiers.end()) |
| 316 continue; | 316 continue; |
| 317 | 317 |
| 318 group_identifiers.insert(group_identifier); | 318 group_identifiers.insert(group_identifier); |
| 319 base::DictionaryValue* dict = new base::DictionaryValue(); | 319 base::DictionaryValue* dict = new base::DictionaryValue(); |
|
Devlin
2016/05/20 17:56:54
optional: make this a unique ptr so we're one step
| |
| 320 dict->SetString(keys::kIdKey, group_identifier); | 320 dict->SetString(keys::kIdKey, group_identifier); |
| 321 dict->SetString(keys::kDescriptionKey, plugin_metadata->name()); | 321 dict->SetString(keys::kDescriptionKey, plugin_metadata->name()); |
| 322 list->Append(dict); | 322 list->Append(dict); |
| 323 } | 323 } |
| 324 SetResult(list); | 324 SetResult(std::move(list)); |
| 325 BrowserThread::PostTask( | 325 BrowserThread::PostTask( |
| 326 BrowserThread::UI, FROM_HERE, base::Bind( | 326 BrowserThread::UI, FROM_HERE, base::Bind( |
| 327 &ContentSettingsContentSettingGetResourceIdentifiersFunction:: | 327 &ContentSettingsContentSettingGetResourceIdentifiersFunction:: |
| 328 SendResponse, | 328 SendResponse, |
| 329 this, | 329 this, |
| 330 true)); | 330 true)); |
| 331 } | 331 } |
| 332 | 332 |
| 333 } // namespace extensions | 333 } // namespace extensions |
| OLD | NEW |