| 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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 53 return *content_type != CONTENT_SETTINGS_TYPE_DEFAULT; | 53 return *content_type != CONTENT_SETTINGS_TYPE_DEFAULT; |
| 54 } | 54 } |
| 55 | 55 |
| 56 } // namespace | 56 } // namespace |
| 57 | 57 |
| 58 namespace extensions { | 58 namespace extensions { |
| 59 | 59 |
| 60 namespace helpers = content_settings_helpers; | 60 namespace helpers = content_settings_helpers; |
| 61 namespace keys = content_settings_api_constants; | 61 namespace keys = content_settings_api_constants; |
| 62 | 62 |
| 63 bool ContentSettingsContentSettingClearFunction::RunImpl() { | 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 Clear::Params::Details::SCOPE_INCOGNITO_SESSION_ONLY) { |
| (...skipping 13 matching lines...) Expand all Loading... |
| 87 } | 87 } |
| 88 } | 88 } |
| 89 | 89 |
| 90 ContentSettingsStore* store = | 90 ContentSettingsStore* store = |
| 91 ContentSettingsService::Get(GetProfile())->content_settings_store(); | 91 ContentSettingsService::Get(GetProfile())->content_settings_store(); |
| 92 store->ClearContentSettingsForExtension(extension_id(), scope); | 92 store->ClearContentSettingsForExtension(extension_id(), scope); |
| 93 | 93 |
| 94 return true; | 94 return true; |
| 95 } | 95 } |
| 96 | 96 |
| 97 bool ContentSettingsContentSettingGetFunction::RunImpl() { | 97 bool ContentSettingsContentSettingGetFunction::RunSync() { |
| 98 ContentSettingsType content_type; | 98 ContentSettingsType content_type; |
| 99 EXTENSION_FUNCTION_VALIDATE(RemoveContentType(args_.get(), &content_type)); | 99 EXTENSION_FUNCTION_VALIDATE(RemoveContentType(args_.get(), &content_type)); |
| 100 | 100 |
| 101 scoped_ptr<Get::Params> params(Get::Params::Create(*args_)); | 101 scoped_ptr<Get::Params> params(Get::Params::Create(*args_)); |
| 102 EXTENSION_FUNCTION_VALIDATE(params.get()); | 102 EXTENSION_FUNCTION_VALIDATE(params.get()); |
| 103 | 103 |
| 104 GURL primary_url(params->details.primary_url); | 104 GURL primary_url(params->details.primary_url); |
| 105 if (!primary_url.is_valid()) { | 105 if (!primary_url.is_valid()) { |
| 106 error_ = ErrorUtils::FormatErrorMessage(keys::kInvalidUrlError, | 106 error_ = ErrorUtils::FormatErrorMessage(keys::kInvalidUrlError, |
| 107 params->details.primary_url); | 107 params->details.primary_url); |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 161 | 161 |
| 162 base::DictionaryValue* result = new base::DictionaryValue(); | 162 base::DictionaryValue* result = new base::DictionaryValue(); |
| 163 result->SetString(keys::kContentSettingKey, | 163 result->SetString(keys::kContentSettingKey, |
| 164 helpers::ContentSettingToString(setting)); | 164 helpers::ContentSettingToString(setting)); |
| 165 | 165 |
| 166 SetResult(result); | 166 SetResult(result); |
| 167 | 167 |
| 168 return true; | 168 return true; |
| 169 } | 169 } |
| 170 | 170 |
| 171 bool ContentSettingsContentSettingSetFunction::RunImpl() { | 171 bool ContentSettingsContentSettingSetFunction::RunSync() { |
| 172 ContentSettingsType content_type; | 172 ContentSettingsType content_type; |
| 173 EXTENSION_FUNCTION_VALIDATE(RemoveContentType(args_.get(), &content_type)); | 173 EXTENSION_FUNCTION_VALIDATE(RemoveContentType(args_.get(), &content_type)); |
| 174 | 174 |
| 175 scoped_ptr<Set::Params> params(Set::Params::Create(*args_)); | 175 scoped_ptr<Set::Params> params(Set::Params::Create(*args_)); |
| 176 EXTENSION_FUNCTION_VALIDATE(params.get()); | 176 EXTENSION_FUNCTION_VALIDATE(params.get()); |
| 177 | 177 |
| 178 std::string primary_error; | 178 std::string primary_error; |
| 179 ContentSettingsPattern primary_pattern = | 179 ContentSettingsPattern primary_pattern = |
| 180 helpers::ParseExtensionPattern(params->details.primary_pattern, | 180 helpers::ParseExtensionPattern(params->details.primary_pattern, |
| 181 &primary_error); | 181 &primary_error); |
| (...skipping 101 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 |