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

Side by Side Diff: components/content_settings/core/browser/host_content_settings_map.cc

Issue 1442083002: Stop inheriting push notification permissions from regular to incognito (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address review comments Created 5 years 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
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 "components/content_settings/core/browser/host_content_settings_map.h" 5 #include "components/content_settings/core/browser/host_content_settings_map.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/basictypes.h" 9 #include "base/basictypes.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 150
151 // Iterate through the list of providers and return the first non-NULL value 151 // Iterate through the list of providers and return the first non-NULL value
152 // that matches |primary_url| and |secondary_url|. 152 // that matches |primary_url| and |secondary_url|.
153 for (ConstProviderIterator provider = content_settings_providers_.begin(); 153 for (ConstProviderIterator provider = content_settings_providers_.begin();
154 provider != content_settings_providers_.end(); 154 provider != content_settings_providers_.end();
155 ++provider) { 155 ++provider) {
156 if (provider->first == PREF_PROVIDER) 156 if (provider->first == PREF_PROVIDER)
157 continue; 157 continue;
158 ContentSetting default_setting = 158 ContentSetting default_setting =
159 GetDefaultContentSettingFromProvider(content_type, provider->second); 159 GetDefaultContentSettingFromProvider(content_type, provider->second);
160 if (is_off_the_record_) {
161 default_setting = CoerceSettingInheritedToIncognito(content_type,
162 default_setting);
163 }
160 if (default_setting != CONTENT_SETTING_DEFAULT) { 164 if (default_setting != CONTENT_SETTING_DEFAULT) {
161 if (provider_id) 165 if (provider_id)
162 *provider_id = kProviderNamesSourceMap[provider->first].provider_name; 166 *provider_id = kProviderNamesSourceMap[provider->first].provider_name;
163 return default_setting; 167 return default_setting;
164 } 168 }
165 } 169 }
166 170
167 return CONTENT_SETTING_DEFAULT; 171 return CONTENT_SETTING_DEFAULT;
168 } 172 }
169 173
(...skipping 477 matching lines...) Expand 10 before | Expand all | Expand 10 after
647 primary_pattern = &info->primary_pattern; 651 primary_pattern = &info->primary_pattern;
648 secondary_pattern = &info->secondary_pattern; 652 secondary_pattern = &info->secondary_pattern;
649 } 653 }
650 654
651 // The list of |content_settings_providers_| is ordered according to their 655 // The list of |content_settings_providers_| is ordered according to their
652 // precedence. 656 // precedence.
653 for (ConstProviderIterator provider = content_settings_providers_.begin(); 657 for (ConstProviderIterator provider = content_settings_providers_.begin();
654 provider != content_settings_providers_.end(); 658 provider != content_settings_providers_.end();
655 ++provider) { 659 ++provider) {
656 660
657 scoped_ptr<base::Value> value( 661 scoped_ptr<base::Value> value =
658 content_settings::GetContentSettingValueAndPatterns(provider->second, 662 content_settings::GetContentSettingValueAndPatterns(provider->second,
659 primary_url, 663 primary_url,
660 secondary_url, 664 secondary_url,
661 content_type, 665 content_type,
662 resource_identifier, 666 resource_identifier,
663 is_off_the_record_, 667 is_off_the_record_,
664 primary_pattern, 668 primary_pattern,
665 secondary_pattern)); 669 secondary_pattern);
666 if (value) { 670 if (value) {
667 if (info) 671 if (info)
668 info->source = kProviderNamesSourceMap[provider->first].provider_source; 672 info->source = kProviderNamesSourceMap[provider->first].provider_source;
669 return value.Pass(); 673 return value.Pass();
670 } 674 }
671 } 675 }
672 676
673 if (info) { 677 if (info) {
674 info->source = content_settings::SETTING_SOURCE_NONE; 678 info->source = content_settings::SETTING_SOURCE_NONE;
675 info->primary_pattern = ContentSettingsPattern(); 679 info->primary_pattern = ContentSettingsPattern();
676 info->secondary_pattern = ContentSettingsPattern(); 680 info->secondary_pattern = ContentSettingsPattern();
677 } 681 }
678 return scoped_ptr<base::Value>(); 682 return scoped_ptr<base::Value>();
679 } 683 }
684
685 // static
686 ContentSetting HostContentSettingsMap::CoerceSettingInheritedToIncognito(
687 ContentSettingsType content_type,
688 ContentSetting setting) {
689 if (setting != CONTENT_SETTING_ALLOW)
690 return setting;
691 const content_settings::ContentSettingsInfo* info =
692 content_settings::ContentSettingsRegistry::GetInstance()
693 ->Get(content_type);
694 if (info->incognito_behavior() !=
695 content_settings::ContentSettingsInfo::INHERIT_IN_INCOGNITO_EXCEPT_ALLOW)
696 return setting;
697 DCHECK(info->IsSettingValid(CONTENT_SETTING_ASK));
698 return CONTENT_SETTING_ASK;
699 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698