| 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 <utility> | 9 #include <utility> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 46 | 46 |
| 47 namespace { | 47 namespace { |
| 48 | 48 |
| 49 bool RemoveContentType(base::ListValue* args, | 49 bool RemoveContentType(base::ListValue* args, |
| 50 ContentSettingsType* content_type) { | 50 ContentSettingsType* content_type) { |
| 51 std::string content_type_str; | 51 std::string content_type_str; |
| 52 if (!args->GetString(0, &content_type_str)) | 52 if (!args->GetString(0, &content_type_str)) |
| 53 return false; | 53 return false; |
| 54 // We remove the ContentSettingsType parameter since this is added by the | 54 // We remove the ContentSettingsType parameter since this is added by the |
| 55 // renderer, and is not part of the JSON schema. | 55 // renderer, and is not part of the JSON schema. |
| 56 args->Remove(0, NULL); | 56 args->Remove(0, nullptr); |
| 57 *content_type = | 57 *content_type = |
| 58 extensions::content_settings_helpers::StringToContentSettingsType( | 58 extensions::content_settings_helpers::StringToContentSettingsType( |
| 59 content_type_str); | 59 content_type_str); |
| 60 return *content_type != CONTENT_SETTINGS_TYPE_DEFAULT; | 60 return *content_type != CONTENT_SETTINGS_TYPE_DEFAULT; |
| 61 } | 61 } |
| 62 | 62 |
| 63 } // namespace | 63 } // namespace |
| 64 | 64 |
| 65 namespace extensions { | 65 namespace extensions { |
| 66 | 66 |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 147 CookieSettingsFactory::GetForProfile(profile->GetOffTheRecordProfile()) | 147 CookieSettingsFactory::GetForProfile(profile->GetOffTheRecordProfile()) |
| 148 .get(); | 148 .get(); |
| 149 } else { | 149 } else { |
| 150 map = HostContentSettingsMapFactory::GetForProfile(profile); | 150 map = HostContentSettingsMapFactory::GetForProfile(profile); |
| 151 cookie_settings = CookieSettingsFactory::GetForProfile(profile).get(); | 151 cookie_settings = CookieSettingsFactory::GetForProfile(profile).get(); |
| 152 } | 152 } |
| 153 | 153 |
| 154 ContentSetting setting; | 154 ContentSetting setting; |
| 155 if (content_type == CONTENT_SETTINGS_TYPE_COOKIES) { | 155 if (content_type == CONTENT_SETTINGS_TYPE_COOKIES) { |
| 156 // TODO(jochen): Do we return the value for setting or for reading cookies? | 156 // TODO(jochen): Do we return the value for setting or for reading cookies? |
| 157 bool setting_cookie = false; | 157 cookie_settings->GetCookieSetting(primary_url, secondary_url, nullptr, |
| 158 setting = cookie_settings->GetCookieSetting(primary_url, secondary_url, | 158 nullptr /* reading_setting */, &setting); |
| 159 setting_cookie, NULL); | |
| 160 } else { | 159 } else { |
| 161 setting = map->GetContentSetting(primary_url, secondary_url, content_type, | 160 setting = map->GetContentSetting(primary_url, secondary_url, content_type, |
| 162 resource_identifier); | 161 resource_identifier); |
| 163 } | 162 } |
| 164 | 163 |
| 165 std::unique_ptr<base::DictionaryValue> result(new base::DictionaryValue()); | 164 std::unique_ptr<base::DictionaryValue> result(new base::DictionaryValue()); |
| 166 std::string setting_string = | 165 std::string setting_string = |
| 167 content_settings::ContentSettingToString(setting); | 166 content_settings::ContentSettingToString(setting); |
| 168 DCHECK(!setting_string.empty()); | 167 DCHECK(!setting_string.empty()); |
| 169 result->SetString(keys::kContentSettingKey, setting_string); | 168 result->SetString(keys::kContentSettingKey, setting_string); |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 310 SetResult(std::move(list)); | 309 SetResult(std::move(list)); |
| 311 BrowserThread::PostTask( | 310 BrowserThread::PostTask( |
| 312 BrowserThread::UI, FROM_HERE, base::Bind( | 311 BrowserThread::UI, FROM_HERE, base::Bind( |
| 313 &ContentSettingsContentSettingGetResourceIdentifiersFunction:: | 312 &ContentSettingsContentSettingGetResourceIdentifiersFunction:: |
| 314 SendResponse, | 313 SendResponse, |
| 315 this, | 314 this, |
| 316 true)); | 315 true)); |
| 317 } | 316 } |
| 318 | 317 |
| 319 } // namespace extensions | 318 } // namespace extensions |
| OLD | NEW |