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