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/extension_content_settings_api.h" | 5 #include "chrome/browser/extensions/api/content_settings/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/extensions/api/content_settings/content_settings_api_co
nstants.h" |
| 13 #include "chrome/browser/extensions/api/content_settings/content_settings_helper
s.h" |
| 14 #include "chrome/browser/extensions/api/content_settings/content_settings_store.
h" |
12 #include "chrome/browser/content_settings/cookie_settings.h" | 15 #include "chrome/browser/content_settings/cookie_settings.h" |
13 #include "chrome/browser/content_settings/host_content_settings_map.h" | 16 #include "chrome/browser/content_settings/host_content_settings_map.h" |
14 #include "chrome/browser/extensions/extension_content_settings_api_constants.h" | |
15 #include "chrome/browser/extensions/extension_content_settings_helpers.h" | |
16 #include "chrome/browser/extensions/extension_content_settings_store.h" | |
17 #include "chrome/browser/extensions/extension_preference_api_constants.h" | 17 #include "chrome/browser/extensions/extension_preference_api_constants.h" |
18 #include "chrome/browser/extensions/extension_preference_helpers.h" | 18 #include "chrome/browser/extensions/extension_preference_helpers.h" |
19 #include "chrome/browser/extensions/extension_service.h" | 19 #include "chrome/browser/extensions/extension_service.h" |
20 #include "chrome/browser/profiles/profile.h" | 20 #include "chrome/browser/profiles/profile.h" |
21 #include "chrome/common/chrome_switches.h" | 21 #include "chrome/common/chrome_switches.h" |
22 #include "chrome/common/extensions/extension_error_utils.h" | 22 #include "chrome/common/extensions/extension_error_utils.h" |
23 #include "content/public/browser/plugin_service.h" | 23 #include "content/public/browser/plugin_service.h" |
24 #include "webkit/plugins/npapi/plugin_group.h" | 24 #include "webkit/plugins/npapi/plugin_group.h" |
25 | 25 |
26 using content::BrowserThread; | 26 using content::BrowserThread; |
27 using content::PluginService; | 27 using content::PluginService; |
28 | 28 |
29 namespace helpers = extension_content_settings_helpers; | |
30 namespace keys = extension_content_settings_api_constants; | |
31 namespace pref_helpers = extension_preference_helpers; | 29 namespace pref_helpers = extension_preference_helpers; |
32 namespace pref_keys = extension_preference_api_constants; | 30 namespace pref_keys = extension_preference_api_constants; |
33 | 31 |
34 namespace { | 32 namespace { |
35 | 33 |
36 const std::vector<webkit::npapi::PluginGroup>* g_testing_plugin_groups_; | 34 const std::vector<webkit::npapi::PluginGroup>* g_testing_plugin_groups_; |
37 | 35 |
38 } // namespace | 36 } // namespace |
39 | 37 |
| 38 namespace extensions { |
| 39 |
| 40 namespace helpers = content_settings_helpers; |
| 41 namespace keys = content_settings_api_constants; |
| 42 |
40 bool ClearContentSettingsFunction::RunImpl() { | 43 bool ClearContentSettingsFunction::RunImpl() { |
41 std::string content_type_str; | 44 std::string content_type_str; |
42 EXTENSION_FUNCTION_VALIDATE(args_->GetString(0, &content_type_str)); | 45 EXTENSION_FUNCTION_VALIDATE(args_->GetString(0, &content_type_str)); |
43 ContentSettingsType content_type = | 46 ContentSettingsType content_type = |
44 helpers::StringToContentSettingsType(content_type_str); | 47 helpers::StringToContentSettingsType(content_type_str); |
45 EXTENSION_FUNCTION_VALIDATE(content_type != CONTENT_SETTINGS_TYPE_DEFAULT); | 48 EXTENSION_FUNCTION_VALIDATE(content_type != CONTENT_SETTINGS_TYPE_DEFAULT); |
46 | 49 |
47 DictionaryValue* details = NULL; | 50 DictionaryValue* details = NULL; |
48 EXTENSION_FUNCTION_VALIDATE(args_->GetDictionary(1, &details)); | 51 EXTENSION_FUNCTION_VALIDATE(args_->GetDictionary(1, &details)); |
49 | 52 |
(...skipping 15 matching lines...) Expand all Loading... |
65 // always allowed to clear its own settings. | 68 // always allowed to clear its own settings. |
66 } else { | 69 } else { |
67 // Incognito profiles can't access regular mode ever, they only exist in | 70 // Incognito profiles can't access regular mode ever, they only exist in |
68 // split mode. | 71 // split mode. |
69 if (profile()->IsOffTheRecord()) { | 72 if (profile()->IsOffTheRecord()) { |
70 error_ = keys::kIncognitoContextError; | 73 error_ = keys::kIncognitoContextError; |
71 return false; | 74 return false; |
72 } | 75 } |
73 } | 76 } |
74 | 77 |
75 ExtensionContentSettingsStore* store = | 78 ContentSettingsStore* store = |
76 profile_->GetExtensionService()->GetExtensionContentSettingsStore(); | 79 profile_->GetExtensionService()->GetContentSettingsStore(); |
77 store->ClearContentSettingsForExtension(extension_id(), scope); | 80 store->ClearContentSettingsForExtension(extension_id(), scope); |
78 | 81 |
79 return true; | 82 return true; |
80 } | 83 } |
81 | 84 |
82 bool GetContentSettingFunction::RunImpl() { | 85 bool GetContentSettingFunction::RunImpl() { |
83 std::string content_type_str; | 86 std::string content_type_str; |
84 EXTENSION_FUNCTION_VALIDATE(args_->GetString(0, &content_type_str)); | 87 EXTENSION_FUNCTION_VALIDATE(args_->GetString(0, &content_type_str)); |
85 ContentSettingsType content_type = | 88 ContentSettingsType content_type = |
86 helpers::StringToContentSettingsType(content_type_str); | 89 helpers::StringToContentSettingsType(content_type_str); |
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
248 return false; | 251 return false; |
249 } | 252 } |
250 } | 253 } |
251 | 254 |
252 if (scope == kExtensionPrefsScopeIncognitoSessionOnly && | 255 if (scope == kExtensionPrefsScopeIncognitoSessionOnly && |
253 !profile_->HasOffTheRecordProfile()) { | 256 !profile_->HasOffTheRecordProfile()) { |
254 error_ = pref_keys::kIncognitoSessionOnlyErrorMessage; | 257 error_ = pref_keys::kIncognitoSessionOnlyErrorMessage; |
255 return false; | 258 return false; |
256 } | 259 } |
257 | 260 |
258 ExtensionContentSettingsStore* store = | 261 ContentSettingsStore* store = |
259 profile_->GetExtensionService()->GetExtensionContentSettingsStore(); | 262 profile_->GetExtensionService()->GetContentSettingsStore(); |
260 store->SetExtensionContentSetting(extension_id(), primary_pattern, | 263 store->SetExtensionContentSetting(extension_id(), primary_pattern, |
261 secondary_pattern, content_type, | 264 secondary_pattern, content_type, |
262 resource_identifier, setting, scope); | 265 resource_identifier, setting, scope); |
263 return true; | 266 return true; |
264 } | 267 } |
265 | 268 |
266 bool GetResourceIdentifiersFunction::RunImpl() { | 269 bool GetResourceIdentifiersFunction::RunImpl() { |
267 std::string content_type_str; | 270 std::string content_type_str; |
268 EXTENSION_FUNCTION_VALIDATE(args_->GetString(0, &content_type_str)); | 271 EXTENSION_FUNCTION_VALIDATE(args_->GetString(0, &content_type_str)); |
269 ContentSettingsType content_type = | 272 ContentSettingsType content_type = |
(...skipping 29 matching lines...) Expand all Loading... |
299 BrowserThread::PostTask( | 302 BrowserThread::PostTask( |
300 BrowserThread::UI, FROM_HERE, base::Bind( | 303 BrowserThread::UI, FROM_HERE, base::Bind( |
301 &GetResourceIdentifiersFunction::SendResponse, this, true)); | 304 &GetResourceIdentifiersFunction::SendResponse, this, true)); |
302 } | 305 } |
303 | 306 |
304 // static | 307 // static |
305 void GetResourceIdentifiersFunction::SetPluginGroupsForTesting( | 308 void GetResourceIdentifiersFunction::SetPluginGroupsForTesting( |
306 const std::vector<webkit::npapi::PluginGroup>* plugin_groups) { | 309 const std::vector<webkit::npapi::PluginGroup>* plugin_groups) { |
307 g_testing_plugin_groups_ = plugin_groups; | 310 g_testing_plugin_groups_ = plugin_groups; |
308 } | 311 } |
| 312 |
| 313 } // namespace extensions |
OLD | NEW |