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

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

Issue 7831004: Add a method to the content_settings::ProviderInterface to return the content settings Value. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Comments addressed. Created 9 years, 3 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 #include <vector> 10 #include <vector>
(...skipping 425 matching lines...) Expand 10 before | Expand all | Expand 10 after
436 pref_change_registrar_.Add(prefs::kGeolocationContentSettings, this); 436 pref_change_registrar_.Add(prefs::kGeolocationContentSettings, this);
437 pref_change_registrar_.Add(prefs::kDesktopNotificationAllowedOrigins, this); 437 pref_change_registrar_.Add(prefs::kDesktopNotificationAllowedOrigins, this);
438 pref_change_registrar_.Add(prefs::kDesktopNotificationDeniedOrigins, this); 438 pref_change_registrar_.Add(prefs::kDesktopNotificationDeniedOrigins, this);
439 } 439 }
440 440
441 ContentSetting PrefProvider::GetContentSetting( 441 ContentSetting PrefProvider::GetContentSetting(
442 const GURL& primary_url, 442 const GURL& primary_url,
443 const GURL& secondary_url, 443 const GURL& secondary_url,
444 ContentSettingsType content_type, 444 ContentSettingsType content_type,
445 const ResourceIdentifier& resource_identifier) const { 445 const ResourceIdentifier& resource_identifier) const {
446 scoped_ptr<Value> value(GetContentSettingValue(primary_url,
447 secondary_url,
448 content_type,
449 resource_identifier));
450 return value.get() ? ValueToContentSetting(value.get())
451 : CONTENT_SETTING_DEFAULT;
452 }
453
454 Value* PrefProvider::GetContentSettingValue(
455 const GURL& primary_url,
456 const GURL& secondary_url,
457 ContentSettingsType content_type,
458 const ResourceIdentifier& resource_identifier) const {
446 // For a |PrefProvider| used in a |HostContentSettingsMap| of a non incognito 459 // For a |PrefProvider| used in a |HostContentSettingsMap| of a non incognito
447 // profile, this will always return NULL. 460 // profile, this will always return NULL.
448 // TODO(markusheintz): I don't like this. I'd like to have an 461 // TODO(markusheintz): I don't like this. I'd like to have an
449 // IncognitoProviderWrapper that wrapps the pref provider for a host content 462 // IncognitoProviderWrapper that wrapps the pref provider for a host content
450 // settings map of an incognito profile. 463 // settings map of an incognito profile.
451 base::AutoLock auto_lock(lock_); 464 base::AutoLock auto_lock(lock_);
452 Value* incognito_value = incognito_value_map_.GetValue( 465 Value* incognito_value = incognito_value_map_.GetValue(
453 primary_url, 466 primary_url,
454 secondary_url, 467 secondary_url,
455 content_type, 468 content_type,
456 resource_identifier); 469 resource_identifier);
457 if (incognito_value) 470 if (incognito_value)
458 return ValueToContentSetting(incognito_value); 471 return incognito_value->DeepCopy();
459 472
460 Value* value = value_map_.GetValue( 473 Value* value = value_map_.GetValue(
461 primary_url, 474 primary_url,
462 secondary_url, 475 secondary_url,
463 content_type, 476 content_type,
464 resource_identifier); 477 resource_identifier);
465 if (value) 478 return value ? value->DeepCopy() : NULL;
466 return ValueToContentSetting(value);
467
468 return CONTENT_SETTING_DEFAULT;
469 } 479 }
470 480
471 void PrefProvider::GetAllContentSettingsRules( 481 void PrefProvider::GetAllContentSettingsRules(
472 ContentSettingsType content_type, 482 ContentSettingsType content_type,
473 const ResourceIdentifier& resource_identifier, 483 const ResourceIdentifier& resource_identifier,
474 Rules* content_setting_rules) const { 484 Rules* content_setting_rules) const {
475 DCHECK(content_setting_rules); 485 DCHECK(content_setting_rules);
476 content_setting_rules->clear(); 486 content_setting_rules->clear();
477 487
478 const OriginIdentifierValueMap* map_to_return = 488 const OriginIdentifierValueMap* map_to_return =
(...skipping 885 matching lines...) Expand 10 before | Expand all | Expand 10 after
1364 if (settings_dictionary->GetInteger( 1374 if (settings_dictionary->GetInteger(
1365 kTypeNames[CONTENT_SETTINGS_TYPE_GEOLOCATION], &setting_value)) { 1375 kTypeNames[CONTENT_SETTINGS_TYPE_GEOLOCATION], &setting_value)) {
1366 UpdateObsoleteGeolocationPref(pattern_pair.first, 1376 UpdateObsoleteGeolocationPref(pattern_pair.first,
1367 pattern_pair.second, 1377 pattern_pair.second,
1368 ContentSetting(setting_value)); 1378 ContentSetting(setting_value));
1369 } 1379 }
1370 } 1380 }
1371 } 1381 }
1372 1382
1373 } // namespace content_settings 1383 } // namespace content_settings
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698