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

Side by Side Diff: chrome/browser/content_settings/content_settings_pref_provider.cc

Issue 385263004: Get rid of some uses of CreateIntegerValue (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 6 years, 5 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/content_settings/content_settings_pref_provider.h" 5 #include "chrome/browser/content_settings/content_settings_pref_provider.h"
6 6
7 #include <map> 7 #include <map>
8 #include <string> 8 #include <string>
9 #include <utility> 9 #include <utility>
10 10
(...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after
332 332
333 std::string audio_device, video_device; 333 std::string audio_device, video_device;
334 value_dict->GetString(kAudioKey, &audio_device); 334 value_dict->GetString(kAudioKey, &audio_device);
335 value_dict->GetString(kVideoKey, &video_device); 335 value_dict->GetString(kVideoKey, &video_device);
336 // Add the exception to the new microphone content setting. 336 // Add the exception to the new microphone content setting.
337 if (!audio_device.empty()) { 337 if (!audio_device.empty()) {
338 SetWebsiteSetting(it->primary_pattern, 338 SetWebsiteSetting(it->primary_pattern,
339 it->secondary_pattern, 339 it->secondary_pattern,
340 CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC, 340 CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC,
341 std::string(), 341 std::string(),
342 base::Value::CreateIntegerValue(CONTENT_SETTING_ALLOW)); 342 new base::FundamentalValue(CONTENT_SETTING_ALLOW));
343 } 343 }
344 // Add the exception to the new camera content setting. 344 // Add the exception to the new camera content setting.
345 if (!video_device.empty()) { 345 if (!video_device.empty()) {
346 SetWebsiteSetting(it->primary_pattern, 346 SetWebsiteSetting(it->primary_pattern,
347 it->secondary_pattern, 347 it->secondary_pattern,
348 CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA, 348 CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA,
349 std::string(), 349 std::string(),
350 base::Value::CreateIntegerValue(CONTENT_SETTING_ALLOW)); 350 new base::FundamentalValue(CONTENT_SETTING_ALLOW));
351 } 351 }
352 352
353 // Remove the old exception in CONTENT_SETTINGS_TYPE_MEDIASTREAM. 353 // Remove the old exception in CONTENT_SETTINGS_TYPE_MEDIASTREAM.
354 SetWebsiteSetting(it->primary_pattern, 354 SetWebsiteSetting(it->primary_pattern,
355 it->secondary_pattern, 355 it->secondary_pattern,
356 CONTENT_SETTINGS_TYPE_MEDIASTREAM, 356 CONTENT_SETTINGS_TYPE_MEDIASTREAM,
357 std::string(), 357 std::string(),
358 NULL); 358 NULL);
359 } 359 }
360 } 360 }
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
426 j.Advance()) { 426 j.Advance()) {
427 const std::string& resource_identifier(j.key()); 427 const std::string& resource_identifier(j.key());
428 int setting = CONTENT_SETTING_DEFAULT; 428 int setting = CONTENT_SETTING_DEFAULT;
429 bool is_integer = j.value().GetAsInteger(&setting); 429 bool is_integer = j.value().GetAsInteger(&setting);
430 DCHECK(is_integer); 430 DCHECK(is_integer);
431 DCHECK_NE(CONTENT_SETTING_DEFAULT, setting); 431 DCHECK_NE(CONTENT_SETTING_DEFAULT, setting);
432 value_map_.SetValue(pattern_pair.first, 432 value_map_.SetValue(pattern_pair.first,
433 pattern_pair.second, 433 pattern_pair.second,
434 content_type, 434 content_type,
435 resource_identifier, 435 resource_identifier,
436 base::Value::CreateIntegerValue(setting)); 436 new base::FundamentalValue(setting));
437 } 437 }
438 } 438 }
439 } 439 }
440 base::Value* value = NULL; 440 base::Value* value = NULL;
441 if (HostContentSettingsMap::ContentTypeHasCompoundValue(content_type)) { 441 if (HostContentSettingsMap::ContentTypeHasCompoundValue(content_type)) {
442 const base::DictionaryValue* setting = NULL; 442 const base::DictionaryValue* setting = NULL;
443 // TODO(xians): Handle the non-dictionary types. 443 // TODO(xians): Handle the non-dictionary types.
444 if (settings_dictionary->GetDictionaryWithoutPathExpansion( 444 if (settings_dictionary->GetDictionaryWithoutPathExpansion(
445 GetTypeName(ContentSettingsType(i)), &setting)) { 445 GetTypeName(ContentSettingsType(i)), &setting)) {
446 DCHECK(!setting->empty()); 446 DCHECK(!setting->empty());
447 value = setting->DeepCopy(); 447 value = setting->DeepCopy();
448 } 448 }
449 } else { 449 } else {
450 int setting = CONTENT_SETTING_DEFAULT; 450 int setting = CONTENT_SETTING_DEFAULT;
451 if (settings_dictionary->GetIntegerWithoutPathExpansion( 451 if (settings_dictionary->GetIntegerWithoutPathExpansion(
452 GetTypeName(ContentSettingsType(i)), &setting)) { 452 GetTypeName(ContentSettingsType(i)), &setting)) {
453 DCHECK_NE(CONTENT_SETTING_DEFAULT, setting); 453 DCHECK_NE(CONTENT_SETTING_DEFAULT, setting);
454 setting = FixObsoleteCookiePromptMode(content_type, 454 setting = FixObsoleteCookiePromptMode(content_type,
455 ContentSetting(setting)); 455 ContentSetting(setting));
456 value = base::Value::CreateIntegerValue(setting); 456 value = new base::FundamentalValue(setting);
457 } 457 }
458 } 458 }
459 459
460 // |value_map_| will take the ownership of |value|. 460 // |value_map_| will take the ownership of |value|.
461 if (value != NULL) { 461 if (value != NULL) {
462 value_map_.SetValue(pattern_pair.first, 462 value_map_.SetValue(pattern_pair.first,
463 pattern_pair.second, 463 pattern_pair.second,
464 content_type, 464 content_type,
465 ResourceIdentifier(), 465 ResourceIdentifier(),
466 value); 466 value);
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
655 lock_.Acquire(); 655 lock_.Acquire();
656 lock_.Release(); 656 lock_.Release();
657 #endif 657 #endif
658 } 658 }
659 659
660 void PrefProvider::SetClockForTesting(scoped_ptr<base::Clock> clock) { 660 void PrefProvider::SetClockForTesting(scoped_ptr<base::Clock> clock) {
661 clock_ = clock.Pass(); 661 clock_ = clock.Pass();
662 } 662 }
663 663
664 } // namespace content_settings 664 } // namespace content_settings
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698