OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/extension_content_settings_api.h" | 5 #include "chrome/browser/extensions/extension_content_settings_api.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
121 if (details->HasKey(pref_keys::kIncognitoKey)) { | 121 if (details->HasKey(pref_keys::kIncognitoKey)) { |
122 EXTENSION_FUNCTION_VALIDATE( | 122 EXTENSION_FUNCTION_VALIDATE( |
123 details->GetBoolean(pref_keys::kIncognitoKey, &incognito)); | 123 details->GetBoolean(pref_keys::kIncognitoKey, &incognito)); |
124 } | 124 } |
125 if (incognito && !include_incognito()) { | 125 if (incognito && !include_incognito()) { |
126 error_ = pref_keys::kIncognitoErrorMessage; | 126 error_ = pref_keys::kIncognitoErrorMessage; |
127 return false; | 127 return false; |
128 } | 128 } |
129 | 129 |
130 HostContentSettingsMap* map; | 130 HostContentSettingsMap* map; |
| 131 CookieContentSettings* cookie_content_settings; |
131 if (incognito) { | 132 if (incognito) { |
132 if (!profile()->HasOffTheRecordProfile()) { | 133 if (!profile()->HasOffTheRecordProfile()) { |
133 // TODO(bauerb): Allow reading incognito content settings | 134 // TODO(bauerb): Allow reading incognito content settings |
134 // outside of an incognito session. | 135 // outside of an incognito session. |
135 error_ = keys::kIncognitoSessionOnlyError; | 136 error_ = keys::kIncognitoSessionOnlyError; |
136 return false; | 137 return false; |
137 } | 138 } |
138 map = profile()->GetOffTheRecordProfile()->GetHostContentSettingsMap(); | 139 map = profile()->GetOffTheRecordProfile()->GetHostContentSettingsMap(); |
| 140 cookie_content_settings = |
| 141 profile()->GetOffTheRecordProfile()->GetCookieContentSettings(); |
139 } else { | 142 } else { |
140 map = profile()->GetHostContentSettingsMap(); | 143 map = profile()->GetHostContentSettingsMap(); |
| 144 cookie_content_settings = |
| 145 profile()->GetOffTheRecordProfile()->GetCookieContentSettings(); |
141 } | 146 } |
142 | 147 |
143 ContentSetting setting; | 148 ContentSetting setting; |
144 if (content_type == CONTENT_SETTINGS_TYPE_COOKIES) { | 149 if (content_type == CONTENT_SETTINGS_TYPE_COOKIES) { |
145 // TODO(jochen): Do we return the value for setting or for reading cookies? | 150 // TODO(jochen): Do we return the value for setting or for reading cookies? |
146 bool setting_cookie = false; | 151 bool setting_cookie = false; |
147 setting = map->GetCookieContentSetting(primary_url, secondary_url, | 152 if (cookie_content_settings->Allow(primary_url, secondary_url, |
148 setting_cookie); | 153 setting_cookie)) { |
| 154 setting = CONTENT_SETTING_ALLOW; |
| 155 } else { |
| 156 setting = CONTENT_SETTING_BLOCK; |
| 157 } |
149 } else { | 158 } else { |
150 setting = map->GetContentSetting(primary_url, secondary_url, content_type, | 159 setting = map->GetContentSetting(primary_url, secondary_url, content_type, |
151 resource_identifier); | 160 resource_identifier); |
152 } | 161 } |
153 | 162 |
154 DictionaryValue* result = new DictionaryValue(); | 163 DictionaryValue* result = new DictionaryValue(); |
155 result->SetString(keys::kContentSettingKey, | 164 result->SetString(keys::kContentSettingKey, |
156 helpers::ContentSettingToString(setting)); | 165 helpers::ContentSettingToString(setting)); |
157 | 166 |
158 result_.reset(result); | 167 result_.reset(result); |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
298 BrowserThread::PostTask( | 307 BrowserThread::PostTask( |
299 BrowserThread::UI, FROM_HERE, base::Bind( | 308 BrowserThread::UI, FROM_HERE, base::Bind( |
300 &GetResourceIdentifiersFunction::SendResponse, this, true)); | 309 &GetResourceIdentifiersFunction::SendResponse, this, true)); |
301 } | 310 } |
302 | 311 |
303 // static | 312 // static |
304 void GetResourceIdentifiersFunction::SetPluginListForTesting( | 313 void GetResourceIdentifiersFunction::SetPluginListForTesting( |
305 webkit::npapi::PluginList* plugin_list) { | 314 webkit::npapi::PluginList* plugin_list) { |
306 g_plugin_list = plugin_list; | 315 g_plugin_list = plugin_list; |
307 } | 316 } |
OLD | NEW |