Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(772)

Side by Side Diff: chrome/browser/extensions/api/content_settings/content_settings_api.cc

Issue 16915006: Convert most of extensions and some other random stuff to using the base namespace for Values. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 24 matching lines...) Expand all
35 namespace Clear = extensions::api::content_settings::ContentSetting::Clear; 35 namespace Clear = extensions::api::content_settings::ContentSetting::Clear;
36 namespace Get = extensions::api::content_settings::ContentSetting::Get; 36 namespace Get = extensions::api::content_settings::ContentSetting::Get;
37 namespace Set = extensions::api::content_settings::ContentSetting::Set; 37 namespace Set = extensions::api::content_settings::ContentSetting::Set;
38 namespace pref_helpers = extensions::preference_helpers; 38 namespace pref_helpers = extensions::preference_helpers;
39 namespace pref_keys = extensions::preference_api_constants; 39 namespace pref_keys = extensions::preference_api_constants;
40 40
41 namespace { 41 namespace {
42 42
43 const std::vector<webkit::WebPluginInfo>* g_testing_plugins_; 43 const std::vector<webkit::WebPluginInfo>* g_testing_plugins_;
44 44
45 bool RemoveContentType(ListValue* args, ContentSettingsType* content_type) { 45 bool RemoveContentType(base::ListValue* args,
46 ContentSettingsType* content_type) {
46 std::string content_type_str; 47 std::string content_type_str;
47 if (!args->GetString(0, &content_type_str)) 48 if (!args->GetString(0, &content_type_str))
48 return false; 49 return false;
49 // We remove the ContentSettingsType parameter since this is added by the 50 // We remove the ContentSettingsType parameter since this is added by the
50 // renderer, and is not part of the JSON schema. 51 // renderer, and is not part of the JSON schema.
51 args->Remove(0, NULL); 52 args->Remove(0, NULL);
52 *content_type = 53 *content_type =
53 extensions::content_settings_helpers::StringToContentSettingsType( 54 extensions::content_settings_helpers::StringToContentSettingsType(
54 content_type_str); 55 content_type_str);
55 return *content_type != CONTENT_SETTINGS_TYPE_DEFAULT; 56 return *content_type != CONTENT_SETTINGS_TYPE_DEFAULT;
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 if (content_type == CONTENT_SETTINGS_TYPE_COOKIES) { 154 if (content_type == CONTENT_SETTINGS_TYPE_COOKIES) {
154 // TODO(jochen): Do we return the value for setting or for reading cookies? 155 // TODO(jochen): Do we return the value for setting or for reading cookies?
155 bool setting_cookie = false; 156 bool setting_cookie = false;
156 setting = cookie_settings->GetCookieSetting(primary_url, secondary_url, 157 setting = cookie_settings->GetCookieSetting(primary_url, secondary_url,
157 setting_cookie, NULL); 158 setting_cookie, NULL);
158 } else { 159 } else {
159 setting = map->GetContentSetting(primary_url, secondary_url, content_type, 160 setting = map->GetContentSetting(primary_url, secondary_url, content_type,
160 resource_identifier); 161 resource_identifier);
161 } 162 }
162 163
163 DictionaryValue* result = new DictionaryValue(); 164 base::DictionaryValue* result = new base::DictionaryValue();
164 result->SetString(keys::kContentSettingKey, 165 result->SetString(keys::kContentSettingKey,
165 helpers::ContentSettingToString(setting)); 166 helpers::ContentSettingToString(setting));
166 167
167 SetResult(result); 168 SetResult(result);
168 169
169 return true; 170 return true;
170 } 171 }
171 172
172 bool ContentSettingsContentSettingSetFunction::RunImpl() { 173 bool ContentSettingsContentSettingSetFunction::RunImpl() {
173 ContentSettingsType content_type; 174 ContentSettingsType content_type;
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
267 } else { 268 } else {
268 OnGotPlugins(*g_testing_plugins_); 269 OnGotPlugins(*g_testing_plugins_);
269 } 270 }
270 return true; 271 return true;
271 } 272 }
272 273
273 void ContentSettingsContentSettingGetResourceIdentifiersFunction::OnGotPlugins( 274 void ContentSettingsContentSettingGetResourceIdentifiersFunction::OnGotPlugins(
274 const std::vector<webkit::WebPluginInfo>& plugins) { 275 const std::vector<webkit::WebPluginInfo>& plugins) {
275 PluginFinder* finder = PluginFinder::GetInstance(); 276 PluginFinder* finder = PluginFinder::GetInstance();
276 std::set<std::string> group_identifiers; 277 std::set<std::string> group_identifiers;
277 ListValue* list = new ListValue(); 278 base::ListValue* list = new base::ListValue();
278 for (std::vector<webkit::WebPluginInfo>::const_iterator it = plugins.begin(); 279 for (std::vector<webkit::WebPluginInfo>::const_iterator it = plugins.begin();
279 it != plugins.end(); ++it) { 280 it != plugins.end(); ++it) {
280 scoped_ptr<PluginMetadata> plugin_metadata(finder->GetPluginMetadata(*it)); 281 scoped_ptr<PluginMetadata> plugin_metadata(finder->GetPluginMetadata(*it));
281 const std::string& group_identifier = plugin_metadata->identifier(); 282 const std::string& group_identifier = plugin_metadata->identifier();
282 if (group_identifiers.find(group_identifier) != group_identifiers.end()) 283 if (group_identifiers.find(group_identifier) != group_identifiers.end())
283 continue; 284 continue;
284 285
285 group_identifiers.insert(group_identifier); 286 group_identifiers.insert(group_identifier);
286 DictionaryValue* dict = new DictionaryValue(); 287 base::DictionaryValue* dict = new base::DictionaryValue();
287 dict->SetString(keys::kIdKey, group_identifier); 288 dict->SetString(keys::kIdKey, group_identifier);
288 dict->SetString(keys::kDescriptionKey, plugin_metadata->name()); 289 dict->SetString(keys::kDescriptionKey, plugin_metadata->name());
289 list->Append(dict); 290 list->Append(dict);
290 } 291 }
291 SetResult(list); 292 SetResult(list);
292 BrowserThread::PostTask( 293 BrowserThread::PostTask(
293 BrowserThread::UI, FROM_HERE, base::Bind( 294 BrowserThread::UI, FROM_HERE, base::Bind(
294 &ContentSettingsContentSettingGetResourceIdentifiersFunction:: 295 &ContentSettingsContentSettingGetResourceIdentifiersFunction::
295 SendResponse, 296 SendResponse,
296 this, 297 this,
297 true)); 298 true));
298 } 299 }
299 300
300 // static 301 // static
301 void ContentSettingsContentSettingGetResourceIdentifiersFunction:: 302 void ContentSettingsContentSettingGetResourceIdentifiersFunction::
302 SetPluginsForTesting(const std::vector<webkit::WebPluginInfo>* plugins) { 303 SetPluginsForTesting(const std::vector<webkit::WebPluginInfo>* plugins) {
303 g_testing_plugins_ = plugins; 304 g_testing_plugins_ = plugins;
304 } 305 }
305 306
306 } // namespace extensions 307 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698