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" |
11 #include "base/values.h" | 11 #include "base/values.h" |
| 12 #include "chrome/browser/content_settings/cookie_settings.h" |
12 #include "chrome/browser/content_settings/host_content_settings_map.h" | 13 #include "chrome/browser/content_settings/host_content_settings_map.h" |
13 #include "chrome/browser/extensions/extension_content_settings_api_constants.h" | 14 #include "chrome/browser/extensions/extension_content_settings_api_constants.h" |
14 #include "chrome/browser/extensions/extension_content_settings_helpers.h" | 15 #include "chrome/browser/extensions/extension_content_settings_helpers.h" |
15 #include "chrome/browser/extensions/extension_content_settings_store.h" | 16 #include "chrome/browser/extensions/extension_content_settings_store.h" |
16 #include "chrome/browser/extensions/extension_preference_api_constants.h" | 17 #include "chrome/browser/extensions/extension_preference_api_constants.h" |
17 #include "chrome/browser/extensions/extension_preference_helpers.h" | 18 #include "chrome/browser/extensions/extension_preference_helpers.h" |
18 #include "chrome/browser/extensions/extension_service.h" | 19 #include "chrome/browser/extensions/extension_service.h" |
19 #include "chrome/browser/profiles/profile.h" | 20 #include "chrome/browser/profiles/profile.h" |
20 #include "chrome/common/chrome_switches.h" | 21 #include "chrome/common/chrome_switches.h" |
21 #include "chrome/common/extensions/extension_error_utils.h" | 22 #include "chrome/common/extensions/extension_error_utils.h" |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
121 if (details->HasKey(pref_keys::kIncognitoKey)) { | 122 if (details->HasKey(pref_keys::kIncognitoKey)) { |
122 EXTENSION_FUNCTION_VALIDATE( | 123 EXTENSION_FUNCTION_VALIDATE( |
123 details->GetBoolean(pref_keys::kIncognitoKey, &incognito)); | 124 details->GetBoolean(pref_keys::kIncognitoKey, &incognito)); |
124 } | 125 } |
125 if (incognito && !include_incognito()) { | 126 if (incognito && !include_incognito()) { |
126 error_ = pref_keys::kIncognitoErrorMessage; | 127 error_ = pref_keys::kIncognitoErrorMessage; |
127 return false; | 128 return false; |
128 } | 129 } |
129 | 130 |
130 HostContentSettingsMap* map; | 131 HostContentSettingsMap* map; |
| 132 CookieSettings* cookie_settings; |
131 if (incognito) { | 133 if (incognito) { |
132 if (!profile()->HasOffTheRecordProfile()) { | 134 if (!profile()->HasOffTheRecordProfile()) { |
133 // TODO(bauerb): Allow reading incognito content settings | 135 // TODO(bauerb): Allow reading incognito content settings |
134 // outside of an incognito session. | 136 // outside of an incognito session. |
135 error_ = keys::kIncognitoSessionOnlyError; | 137 error_ = keys::kIncognitoSessionOnlyError; |
136 return false; | 138 return false; |
137 } | 139 } |
138 map = profile()->GetOffTheRecordProfile()->GetHostContentSettingsMap(); | 140 map = profile()->GetOffTheRecordProfile()->GetHostContentSettingsMap(); |
| 141 cookie_settings = CookieSettings::GetForProfile( |
| 142 profile()->GetOffTheRecordProfile()); |
139 } else { | 143 } else { |
140 map = profile()->GetHostContentSettingsMap(); | 144 map = profile()->GetHostContentSettingsMap(); |
| 145 cookie_settings = CookieSettings::GetForProfile(profile()); |
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 setting = cookie_settings->GetCookieSetting(primary_url, secondary_url, |
148 setting_cookie); | 153 setting_cookie); |
149 } else { | 154 } else { |
150 setting = map->GetContentSetting(primary_url, secondary_url, content_type, | 155 setting = map->GetContentSetting(primary_url, secondary_url, content_type, |
151 resource_identifier); | 156 resource_identifier); |
152 } | 157 } |
153 | 158 |
154 DictionaryValue* result = new DictionaryValue(); | 159 DictionaryValue* result = new DictionaryValue(); |
155 result->SetString(keys::kContentSettingKey, | 160 result->SetString(keys::kContentSettingKey, |
156 helpers::ContentSettingToString(setting)); | 161 helpers::ContentSettingToString(setting)); |
157 | 162 |
158 result_.reset(result); | 163 result_.reset(result); |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
291 BrowserThread::PostTask( | 296 BrowserThread::PostTask( |
292 BrowserThread::UI, FROM_HERE, base::Bind( | 297 BrowserThread::UI, FROM_HERE, base::Bind( |
293 &GetResourceIdentifiersFunction::SendResponse, this, true)); | 298 &GetResourceIdentifiersFunction::SendResponse, this, true)); |
294 } | 299 } |
295 | 300 |
296 // static | 301 // static |
297 void GetResourceIdentifiersFunction::SetPluginGroupsForTesting( | 302 void GetResourceIdentifiersFunction::SetPluginGroupsForTesting( |
298 const std::vector<webkit::npapi::PluginGroup>* plugin_groups) { | 303 const std::vector<webkit::npapi::PluginGroup>* plugin_groups) { |
299 g_testing_plugin_groups_ = plugin_groups; | 304 g_testing_plugin_groups_ = plugin_groups; |
300 } | 305 } |
OLD | NEW |