| 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" |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 63 bool ContentSettingsContentSettingClearFunction::RunSync() { | 63 bool ContentSettingsContentSettingClearFunction::RunSync() { |
| 64 ContentSettingsType content_type; | 64 ContentSettingsType content_type; |
| 65 EXTENSION_FUNCTION_VALIDATE(RemoveContentType(args_.get(), &content_type)); | 65 EXTENSION_FUNCTION_VALIDATE(RemoveContentType(args_.get(), &content_type)); |
| 66 | 66 |
| 67 scoped_ptr<Clear::Params> params(Clear::Params::Create(*args_)); | 67 scoped_ptr<Clear::Params> params(Clear::Params::Create(*args_)); |
| 68 EXTENSION_FUNCTION_VALIDATE(params.get()); | 68 EXTENSION_FUNCTION_VALIDATE(params.get()); |
| 69 | 69 |
| 70 ExtensionPrefsScope scope = kExtensionPrefsScopeRegular; | 70 ExtensionPrefsScope scope = kExtensionPrefsScopeRegular; |
| 71 bool incognito = false; | 71 bool incognito = false; |
| 72 if (params->details.scope == | 72 if (params->details.scope == |
| 73 Clear::Params::Details::SCOPE_INCOGNITO_SESSION_ONLY) { | 73 api::content_settings::SCOPE_INCOGNITO_SESSION_ONLY) { |
| 74 scope = kExtensionPrefsScopeIncognitoSessionOnly; | 74 scope = kExtensionPrefsScopeIncognitoSessionOnly; |
| 75 incognito = true; | 75 incognito = true; |
| 76 } | 76 } |
| 77 | 77 |
| 78 if (incognito) { | 78 if (incognito) { |
| 79 // We don't check incognito permissions here, as an extension should be | 79 // We don't check incognito permissions here, as an extension should be |
| 80 // always allowed to clear its own settings. | 80 // always allowed to clear its own settings. |
| 81 } else { | 81 } else { |
| 82 // Incognito profiles can't access regular mode ever, they only exist in | 82 // Incognito profiles can't access regular mode ever, they only exist in |
| 83 // split mode. | 83 // split mode. |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 205 params->details.setting->GetAsString(&setting_str)); | 205 params->details.setting->GetAsString(&setting_str)); |
| 206 ContentSetting setting; | 206 ContentSetting setting; |
| 207 EXTENSION_FUNCTION_VALIDATE( | 207 EXTENSION_FUNCTION_VALIDATE( |
| 208 helpers::StringToContentSetting(setting_str, &setting)); | 208 helpers::StringToContentSetting(setting_str, &setting)); |
| 209 EXTENSION_FUNCTION_VALIDATE(HostContentSettingsMap::IsSettingAllowedForType( | 209 EXTENSION_FUNCTION_VALIDATE(HostContentSettingsMap::IsSettingAllowedForType( |
| 210 GetProfile()->GetPrefs(), setting, content_type)); | 210 GetProfile()->GetPrefs(), setting, content_type)); |
| 211 | 211 |
| 212 ExtensionPrefsScope scope = kExtensionPrefsScopeRegular; | 212 ExtensionPrefsScope scope = kExtensionPrefsScopeRegular; |
| 213 bool incognito = false; | 213 bool incognito = false; |
| 214 if (params->details.scope == | 214 if (params->details.scope == |
| 215 Set::Params::Details::SCOPE_INCOGNITO_SESSION_ONLY) { | 215 api::content_settings::SCOPE_INCOGNITO_SESSION_ONLY) { |
| 216 scope = kExtensionPrefsScopeIncognitoSessionOnly; | 216 scope = kExtensionPrefsScopeIncognitoSessionOnly; |
| 217 incognito = true; | 217 incognito = true; |
| 218 } | 218 } |
| 219 | 219 |
| 220 if (incognito) { | 220 if (incognito) { |
| 221 // Regular profiles can't access incognito unless include_incognito is true. | 221 // Regular profiles can't access incognito unless include_incognito is true. |
| 222 if (!GetProfile()->IsOffTheRecord() && !include_incognito()) { | 222 if (!GetProfile()->IsOffTheRecord() && !include_incognito()) { |
| 223 error_ = pref_keys::kIncognitoErrorMessage; | 223 error_ = pref_keys::kIncognitoErrorMessage; |
| 224 return false; | 224 return false; |
| 225 } | 225 } |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 283 SetResult(list); | 283 SetResult(list); |
| 284 BrowserThread::PostTask( | 284 BrowserThread::PostTask( |
| 285 BrowserThread::UI, FROM_HERE, base::Bind( | 285 BrowserThread::UI, FROM_HERE, base::Bind( |
| 286 &ContentSettingsContentSettingGetResourceIdentifiersFunction:: | 286 &ContentSettingsContentSettingGetResourceIdentifiersFunction:: |
| 287 SendResponse, | 287 SendResponse, |
| 288 this, | 288 this, |
| 289 true)); | 289 true)); |
| 290 } | 290 } |
| 291 | 291 |
| 292 } // namespace extensions | 292 } // namespace extensions |
| OLD | NEW |