| 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/api/content_settings/content_settings_api.h" | 5 #include "chrome/browser/extensions/api/content_settings/content_settings_api.h" |
| 6 | 6 |
| 7 #include <set> | 7 #include <set> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| 11 #include "base/command_line.h" | 11 #include "base/command_line.h" |
| 12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
| 13 #include "base/values.h" | 13 #include "base/values.h" |
| 14 #include "chrome/browser/content_settings/cookie_settings.h" | 14 #include "chrome/browser/content_settings/cookie_settings.h" |
| 15 #include "chrome/browser/content_settings/host_content_settings_map.h" | 15 #include "chrome/browser/content_settings/host_content_settings_map.h" |
| 16 #include "chrome/browser/extensions/api/content_settings/content_settings_api_co
nstants.h" | 16 #include "chrome/browser/extensions/api/content_settings/content_settings_api_co
nstants.h" |
| 17 #include "chrome/browser/extensions/api/content_settings/content_settings_helper
s.h" | 17 #include "chrome/browser/extensions/api/content_settings/content_settings_helper
s.h" |
| 18 #include "chrome/browser/extensions/api/content_settings/content_settings_store.
h" | 18 #include "chrome/browser/extensions/api/content_settings/content_settings_store.
h" |
| 19 #include "chrome/browser/extensions/api/preference/preference_api_constants.h" | 19 #include "chrome/browser/extensions/api/preference/preference_api_constants.h" |
| 20 #include "chrome/browser/extensions/api/preference/preference_helpers.h" | 20 #include "chrome/browser/extensions/api/preference/preference_helpers.h" |
| 21 #include "chrome/browser/extensions/extension_service.h" | 21 #include "chrome/browser/extensions/extension_service.h" |
| 22 #include "chrome/browser/extensions/extension_system.h" |
| 22 #include "chrome/browser/plugins/plugin_finder.h" | 23 #include "chrome/browser/plugins/plugin_finder.h" |
| 23 #include "chrome/browser/plugins/plugin_installer.h" | 24 #include "chrome/browser/plugins/plugin_installer.h" |
| 24 #include "chrome/browser/prefs/pref_service.h" | 25 #include "chrome/browser/prefs/pref_service.h" |
| 25 #include "chrome/browser/profiles/profile.h" | 26 #include "chrome/browser/profiles/profile.h" |
| 26 #include "chrome/common/chrome_switches.h" | 27 #include "chrome/common/chrome_switches.h" |
| 27 #include "chrome/common/extensions/api/content_settings.h" | 28 #include "chrome/common/extensions/api/content_settings.h" |
| 28 #include "content/public/browser/plugin_service.h" | 29 #include "content/public/browser/plugin_service.h" |
| 29 #include "extensions/common/error_utils.h" | 30 #include "extensions/common/error_utils.h" |
| 30 | 31 |
| 31 using content::BrowserThread; | 32 using content::BrowserThread; |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 81 // always allowed to clear its own settings. | 82 // always allowed to clear its own settings. |
| 82 } else { | 83 } else { |
| 83 // Incognito profiles can't access regular mode ever, they only exist in | 84 // Incognito profiles can't access regular mode ever, they only exist in |
| 84 // split mode. | 85 // split mode. |
| 85 if (profile()->IsOffTheRecord()) { | 86 if (profile()->IsOffTheRecord()) { |
| 86 error_ = keys::kIncognitoContextError; | 87 error_ = keys::kIncognitoContextError; |
| 87 return false; | 88 return false; |
| 88 } | 89 } |
| 89 } | 90 } |
| 90 | 91 |
| 91 ContentSettingsStore* store = | 92 ContentSettingsStore* store = extensions::ExtensionSystem::Get(profile_)-> |
| 92 profile_->GetExtensionService()->GetContentSettingsStore(); | 93 extension_service()->GetContentSettingsStore(); |
| 93 store->ClearContentSettingsForExtension(extension_id(), scope); | 94 store->ClearContentSettingsForExtension(extension_id(), scope); |
| 94 | 95 |
| 95 return true; | 96 return true; |
| 96 } | 97 } |
| 97 | 98 |
| 98 bool GetContentSettingFunction::RunImpl() { | 99 bool GetContentSettingFunction::RunImpl() { |
| 99 ContentSettingsType content_type; | 100 ContentSettingsType content_type; |
| 100 EXTENSION_FUNCTION_VALIDATE(RemoveContentType(args_.get(), &content_type)); | 101 EXTENSION_FUNCTION_VALIDATE(RemoveContentType(args_.get(), &content_type)); |
| 101 | 102 |
| 102 scoped_ptr<Get::Params> params(Get::Params::Create(*args_)); | 103 scoped_ptr<Get::Params> params(Get::Params::Create(*args_)); |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 234 return false; | 235 return false; |
| 235 } | 236 } |
| 236 } | 237 } |
| 237 | 238 |
| 238 if (scope == kExtensionPrefsScopeIncognitoSessionOnly && | 239 if (scope == kExtensionPrefsScopeIncognitoSessionOnly && |
| 239 !profile_->HasOffTheRecordProfile()) { | 240 !profile_->HasOffTheRecordProfile()) { |
| 240 error_ = pref_keys::kIncognitoSessionOnlyErrorMessage; | 241 error_ = pref_keys::kIncognitoSessionOnlyErrorMessage; |
| 241 return false; | 242 return false; |
| 242 } | 243 } |
| 243 | 244 |
| 244 ContentSettingsStore* store = | 245 ContentSettingsStore* store = extensions::ExtensionSystem::Get(profile_)-> |
| 245 profile_->GetExtensionService()->GetContentSettingsStore(); | 246 extension_service()->GetContentSettingsStore(); |
| 246 store->SetExtensionContentSetting(extension_id(), primary_pattern, | 247 store->SetExtensionContentSetting(extension_id(), primary_pattern, |
| 247 secondary_pattern, content_type, | 248 secondary_pattern, content_type, |
| 248 resource_identifier, setting, scope); | 249 resource_identifier, setting, scope); |
| 249 return true; | 250 return true; |
| 250 } | 251 } |
| 251 | 252 |
| 252 bool GetResourceIdentifiersFunction::RunImpl() { | 253 bool GetResourceIdentifiersFunction::RunImpl() { |
| 253 ContentSettingsType content_type; | 254 ContentSettingsType content_type; |
| 254 EXTENSION_FUNCTION_VALIDATE(RemoveContentType(args_.get(), &content_type)); | 255 EXTENSION_FUNCTION_VALIDATE(RemoveContentType(args_.get(), &content_type)); |
| 255 | 256 |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 291 &GetResourceIdentifiersFunction::SendResponse, this, true)); | 292 &GetResourceIdentifiersFunction::SendResponse, this, true)); |
| 292 } | 293 } |
| 293 | 294 |
| 294 // static | 295 // static |
| 295 void GetResourceIdentifiersFunction::SetPluginsForTesting( | 296 void GetResourceIdentifiersFunction::SetPluginsForTesting( |
| 296 const std::vector<webkit::WebPluginInfo>* plugins) { | 297 const std::vector<webkit::WebPluginInfo>* plugins) { |
| 297 g_testing_plugins_ = plugins; | 298 g_testing_plugins_ = plugins; |
| 298 } | 299 } |
| 299 | 300 |
| 300 } // namespace extensions | 301 } // namespace extensions |
| OLD | NEW |