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

Side by Side Diff: chrome/browser/extensions/api/content_settings/content_settings_api.cc

Issue 2502743003: Allow getting both reading/setting cookie settings at one time (Closed)
Patch Set: rdevlin review Created 4 years, 1 month 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 | « no previous file | chrome/browser/net/chrome_network_delegate.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 (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
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
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
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
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/net/chrome_network_delegate.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698