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

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

Issue 2886433002: [Android] Adding content settings provider for notification channels (Closed)
Patch Set: Responding to more comments Created 3 years, 7 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
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 <stddef.h> 7 #include <stddef.h>
8 8
9 #include <utility> 9 #include <utility>
10 10
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 struct ProviderNamesSourceMapEntry { 48 struct ProviderNamesSourceMapEntry {
49 const char* provider_name; 49 const char* provider_name;
50 content_settings::SettingSource provider_source; 50 content_settings::SettingSource provider_source;
51 }; 51 };
52 52
53 const ProviderNamesSourceMapEntry kProviderNamesSourceMap[] = { 53 const ProviderNamesSourceMapEntry kProviderNamesSourceMap[] = {
54 {"platform_app", content_settings::SETTING_SOURCE_EXTENSION}, 54 {"platform_app", content_settings::SETTING_SOURCE_EXTENSION},
55 {"policy", content_settings::SETTING_SOURCE_POLICY}, 55 {"policy", content_settings::SETTING_SOURCE_POLICY},
56 {"supervised_user", content_settings::SETTING_SOURCE_SUPERVISED}, 56 {"supervised_user", content_settings::SETTING_SOURCE_SUPERVISED},
57 {"extension", content_settings::SETTING_SOURCE_EXTENSION}, 57 {"extension", content_settings::SETTING_SOURCE_EXTENSION},
58 {"notification_android", content_settings::SETTING_SOURCE_USER},
58 {"preference", content_settings::SETTING_SOURCE_USER}, 59 {"preference", content_settings::SETTING_SOURCE_USER},
59 {"default", content_settings::SETTING_SOURCE_USER}, 60 {"default", content_settings::SETTING_SOURCE_USER},
60 }; 61 };
61 62
62 // Enum describing the status of domain to origin migration of content settings. 63 // Enum describing the status of domain to origin migration of content settings.
63 // Migration will be done twice: once upon construction of the 64 // Migration will be done twice: once upon construction of the
64 // HostContentSettingsMap (before syncing any content settings) and once after 65 // HostContentSettingsMap (before syncing any content settings) and once after
65 // sync has finished. We always migrate before sync to ensure that settings will 66 // sync has finished. We always migrate before sync to ensure that settings will
66 // get migrated even if a user doesn't have sync enabled. We migrate after sync 67 // get migrated even if a user doesn't have sync enabled. We migrate after sync
67 // to ensure that any sync'd settings will be migrated. Once these events have 68 // to ensure that any sync'd settings will be migrated. Once these events have
(...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after
377 } 378 }
378 379
379 void HostContentSettingsMap::SetWebsiteSettingCustomScope( 380 void HostContentSettingsMap::SetWebsiteSettingCustomScope(
380 const ContentSettingsPattern& primary_pattern, 381 const ContentSettingsPattern& primary_pattern,
381 const ContentSettingsPattern& secondary_pattern, 382 const ContentSettingsPattern& secondary_pattern,
382 ContentSettingsType content_type, 383 ContentSettingsType content_type,
383 const std::string& resource_identifier, 384 const std::string& resource_identifier,
384 std::unique_ptr<base::Value> value) { 385 std::unique_ptr<base::Value> value) {
385 DCHECK(SupportsResourceIdentifier(content_type) || 386 DCHECK(SupportsResourceIdentifier(content_type) ||
386 resource_identifier.empty()); 387 resource_identifier.empty());
388 #if defined(OS_ANDROID)
389 // Disallow wildcard notification content setting updates on Android.
390 DCHECK(content_type != CONTENT_SETTINGS_TYPE_NOTIFICATIONS ||
391 GURL(primary_pattern.ToString()).is_valid());
392 // Disallow notification content setting updates that are not
393 // ALLOW/BLOCK/DEFAULT on Android.
394 DCHECK(content_type != CONTENT_SETTINGS_TYPE_NOTIFICATIONS ||
395 content_settings::ValueToContentSetting(value.get()) ==
396 CONTENT_SETTING_ALLOW ||
397 content_settings::ValueToContentSetting(value.get()) ==
398 CONTENT_SETTING_BLOCK ||
399 content_settings::ValueToContentSetting(value.get()) ==
400 CONTENT_SETTING_DEFAULT);
raymes 2017/05/18 00:39:37 nit: let's leave this DCHECK of here for now. The
awdf 2017/05/19 17:59:57 Acknowledged.
401 #endif
402
387 UsedContentSettingsProviders(); 403 UsedContentSettingsProviders();
388 404
389 for (const auto& provider_pair : content_settings_providers_) { 405 for (const auto& provider_pair : content_settings_providers_) {
390 if (provider_pair.second->SetWebsiteSetting( 406 if (provider_pair.second->SetWebsiteSetting(
391 primary_pattern, secondary_pattern, content_type, 407 primary_pattern, secondary_pattern, content_type,
392 resource_identifier, value.get())) { 408 resource_identifier, value.get())) {
393 // If successful then ownership is passed to the provider. 409 // If successful then ownership is passed to the provider.
394 ignore_result(value.release()); 410 ignore_result(value.release());
395 return; 411 return;
396 } 412 }
(...skipping 506 matching lines...) Expand 10 before | Expand all | Expand 10 after
903 return base::WrapUnique(rule.value.get()->DeepCopy()); 919 return base::WrapUnique(rule.value.get()->DeepCopy());
904 } 920 }
905 } 921 }
906 } 922 }
907 return std::unique_ptr<base::Value>(); 923 return std::unique_ptr<base::Value>();
908 } 924 }
909 925
910 void HostContentSettingsMap::SetClockForTesting( 926 void HostContentSettingsMap::SetClockForTesting(
911 std::unique_ptr<base::Clock> clock) { 927 std::unique_ptr<base::Clock> clock) {
912 pref_provider_->SetClockForTesting(std::move(clock)); 928 pref_provider_->SetClockForTesting(std::move(clock));
913 } 929 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698