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 <memory> |
7 #include <set> | 8 #include <set> |
8 #include <vector> | 9 #include <vector> |
9 | 10 |
10 #include "base/bind.h" | 11 #include "base/bind.h" |
11 #include "base/command_line.h" | 12 #include "base/command_line.h" |
12 #include "base/memory/scoped_ptr.h" | |
13 #include "base/strings/stringprintf.h" | 13 #include "base/strings/stringprintf.h" |
14 #include "base/values.h" | 14 #include "base/values.h" |
15 #include "chrome/browser/content_settings/cookie_settings_factory.h" | 15 #include "chrome/browser/content_settings/cookie_settings_factory.h" |
16 #include "chrome/browser/content_settings/host_content_settings_map_factory.h" | 16 #include "chrome/browser/content_settings/host_content_settings_map_factory.h" |
17 #include "chrome/browser/extensions/api/content_settings/content_settings_api_co
nstants.h" | 17 #include "chrome/browser/extensions/api/content_settings/content_settings_api_co
nstants.h" |
18 #include "chrome/browser/extensions/api/content_settings/content_settings_helper
s.h" | 18 #include "chrome/browser/extensions/api/content_settings/content_settings_helper
s.h" |
19 #include "chrome/browser/extensions/api/content_settings/content_settings_servic
e.h" | 19 #include "chrome/browser/extensions/api/content_settings/content_settings_servic
e.h" |
20 #include "chrome/browser/extensions/api/content_settings/content_settings_store.
h" | 20 #include "chrome/browser/extensions/api/content_settings/content_settings_store.
h" |
21 #include "chrome/browser/extensions/api/preference/preference_api_constants.h" | 21 #include "chrome/browser/extensions/api/preference/preference_api_constants.h" |
22 #include "chrome/browser/extensions/api/preference/preference_helpers.h" | 22 #include "chrome/browser/extensions/api/preference/preference_helpers.h" |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
63 | 63 |
64 namespace extensions { | 64 namespace extensions { |
65 | 65 |
66 namespace helpers = content_settings_helpers; | 66 namespace helpers = content_settings_helpers; |
67 namespace keys = content_settings_api_constants; | 67 namespace keys = content_settings_api_constants; |
68 | 68 |
69 bool ContentSettingsContentSettingClearFunction::RunSync() { | 69 bool ContentSettingsContentSettingClearFunction::RunSync() { |
70 ContentSettingsType content_type; | 70 ContentSettingsType content_type; |
71 EXTENSION_FUNCTION_VALIDATE(RemoveContentType(args_.get(), &content_type)); | 71 EXTENSION_FUNCTION_VALIDATE(RemoveContentType(args_.get(), &content_type)); |
72 | 72 |
73 scoped_ptr<Clear::Params> params(Clear::Params::Create(*args_)); | 73 std::unique_ptr<Clear::Params> params(Clear::Params::Create(*args_)); |
74 EXTENSION_FUNCTION_VALIDATE(params.get()); | 74 EXTENSION_FUNCTION_VALIDATE(params.get()); |
75 | 75 |
76 ExtensionPrefsScope scope = kExtensionPrefsScopeRegular; | 76 ExtensionPrefsScope scope = kExtensionPrefsScopeRegular; |
77 bool incognito = false; | 77 bool incognito = false; |
78 if (params->details.scope == | 78 if (params->details.scope == |
79 api::content_settings::SCOPE_INCOGNITO_SESSION_ONLY) { | 79 api::content_settings::SCOPE_INCOGNITO_SESSION_ONLY) { |
80 scope = kExtensionPrefsScopeIncognitoSessionOnly; | 80 scope = kExtensionPrefsScopeIncognitoSessionOnly; |
81 incognito = true; | 81 incognito = true; |
82 } | 82 } |
83 | 83 |
(...skipping 13 matching lines...) Expand all Loading... |
97 ContentSettingsService::Get(GetProfile())->content_settings_store(); | 97 ContentSettingsService::Get(GetProfile())->content_settings_store(); |
98 store->ClearContentSettingsForExtension(extension_id(), scope); | 98 store->ClearContentSettingsForExtension(extension_id(), scope); |
99 | 99 |
100 return true; | 100 return true; |
101 } | 101 } |
102 | 102 |
103 bool ContentSettingsContentSettingGetFunction::RunSync() { | 103 bool ContentSettingsContentSettingGetFunction::RunSync() { |
104 ContentSettingsType content_type; | 104 ContentSettingsType content_type; |
105 EXTENSION_FUNCTION_VALIDATE(RemoveContentType(args_.get(), &content_type)); | 105 EXTENSION_FUNCTION_VALIDATE(RemoveContentType(args_.get(), &content_type)); |
106 | 106 |
107 scoped_ptr<Get::Params> params(Get::Params::Create(*args_)); | 107 std::unique_ptr<Get::Params> params(Get::Params::Create(*args_)); |
108 EXTENSION_FUNCTION_VALIDATE(params.get()); | 108 EXTENSION_FUNCTION_VALIDATE(params.get()); |
109 | 109 |
110 GURL primary_url(params->details.primary_url); | 110 GURL primary_url(params->details.primary_url); |
111 if (!primary_url.is_valid()) { | 111 if (!primary_url.is_valid()) { |
112 error_ = ErrorUtils::FormatErrorMessage(keys::kInvalidUrlError, | 112 error_ = ErrorUtils::FormatErrorMessage(keys::kInvalidUrlError, |
113 params->details.primary_url); | 113 params->details.primary_url); |
114 return false; | 114 return false; |
115 } | 115 } |
116 | 116 |
117 GURL secondary_url(primary_url); | 117 GURL secondary_url(primary_url); |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
173 | 173 |
174 SetResult(result); | 174 SetResult(result); |
175 | 175 |
176 return true; | 176 return true; |
177 } | 177 } |
178 | 178 |
179 bool ContentSettingsContentSettingSetFunction::RunSync() { | 179 bool ContentSettingsContentSettingSetFunction::RunSync() { |
180 ContentSettingsType content_type; | 180 ContentSettingsType content_type; |
181 EXTENSION_FUNCTION_VALIDATE(RemoveContentType(args_.get(), &content_type)); | 181 EXTENSION_FUNCTION_VALIDATE(RemoveContentType(args_.get(), &content_type)); |
182 | 182 |
183 scoped_ptr<Set::Params> params(Set::Params::Create(*args_)); | 183 std::unique_ptr<Set::Params> params(Set::Params::Create(*args_)); |
184 EXTENSION_FUNCTION_VALIDATE(params.get()); | 184 EXTENSION_FUNCTION_VALIDATE(params.get()); |
185 | 185 |
186 std::string primary_error; | 186 std::string primary_error; |
187 ContentSettingsPattern primary_pattern = | 187 ContentSettingsPattern primary_pattern = |
188 helpers::ParseExtensionPattern(params->details.primary_pattern, | 188 helpers::ParseExtensionPattern(params->details.primary_pattern, |
189 &primary_error); | 189 &primary_error); |
190 if (!primary_pattern.IsValid()) { | 190 if (!primary_pattern.IsValid()) { |
191 error_ = primary_error; | 191 error_ = primary_error; |
192 return false; | 192 return false; |
193 } | 193 } |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
302 return true; | 302 return true; |
303 } | 303 } |
304 | 304 |
305 void ContentSettingsContentSettingGetResourceIdentifiersFunction::OnGotPlugins( | 305 void ContentSettingsContentSettingGetResourceIdentifiersFunction::OnGotPlugins( |
306 const std::vector<content::WebPluginInfo>& plugins) { | 306 const std::vector<content::WebPluginInfo>& plugins) { |
307 PluginFinder* finder = PluginFinder::GetInstance(); | 307 PluginFinder* finder = PluginFinder::GetInstance(); |
308 std::set<std::string> group_identifiers; | 308 std::set<std::string> group_identifiers; |
309 base::ListValue* list = new base::ListValue(); | 309 base::ListValue* list = new base::ListValue(); |
310 for (std::vector<content::WebPluginInfo>::const_iterator it = plugins.begin(); | 310 for (std::vector<content::WebPluginInfo>::const_iterator it = plugins.begin(); |
311 it != plugins.end(); ++it) { | 311 it != plugins.end(); ++it) { |
312 scoped_ptr<PluginMetadata> plugin_metadata(finder->GetPluginMetadata(*it)); | 312 std::unique_ptr<PluginMetadata> plugin_metadata( |
| 313 finder->GetPluginMetadata(*it)); |
313 const std::string& group_identifier = plugin_metadata->identifier(); | 314 const std::string& group_identifier = plugin_metadata->identifier(); |
314 if (group_identifiers.find(group_identifier) != group_identifiers.end()) | 315 if (group_identifiers.find(group_identifier) != group_identifiers.end()) |
315 continue; | 316 continue; |
316 | 317 |
317 group_identifiers.insert(group_identifier); | 318 group_identifiers.insert(group_identifier); |
318 base::DictionaryValue* dict = new base::DictionaryValue(); | 319 base::DictionaryValue* dict = new base::DictionaryValue(); |
319 dict->SetString(keys::kIdKey, group_identifier); | 320 dict->SetString(keys::kIdKey, group_identifier); |
320 dict->SetString(keys::kDescriptionKey, plugin_metadata->name()); | 321 dict->SetString(keys::kDescriptionKey, plugin_metadata->name()); |
321 list->Append(dict); | 322 list->Append(dict); |
322 } | 323 } |
323 SetResult(list); | 324 SetResult(list); |
324 BrowserThread::PostTask( | 325 BrowserThread::PostTask( |
325 BrowserThread::UI, FROM_HERE, base::Bind( | 326 BrowserThread::UI, FROM_HERE, base::Bind( |
326 &ContentSettingsContentSettingGetResourceIdentifiersFunction:: | 327 &ContentSettingsContentSettingGetResourceIdentifiersFunction:: |
327 SendResponse, | 328 SendResponse, |
328 this, | 329 this, |
329 true)); | 330 true)); |
330 } | 331 } |
331 | 332 |
332 } // namespace extensions | 333 } // namespace extensions |
OLD | NEW |