OLD | NEW |
---|---|
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/host_content_settings_map.h" | 5 #include "chrome/browser/content_settings/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" |
11 #include "base/stl_util.h" | 11 #include "base/stl_util.h" |
12 #include "base/string_util.h" | 12 #include "base/string_util.h" |
13 #include "base/utf_string_conversions.h" | 13 #include "base/utf_string_conversions.h" |
14 #include "chrome/browser/content_settings/content_settings_default_provider.h" | 14 #include "chrome/browser/content_settings/content_settings_default_provider.h" |
15 #include "chrome/browser/content_settings/content_settings_details.h" | 15 #include "chrome/browser/content_settings/content_settings_details.h" |
16 #include "chrome/browser/content_settings/content_settings_extension_provider.h" | 16 #include "chrome/browser/content_settings/content_settings_extension_provider.h" |
17 #include "chrome/browser/content_settings/content_settings_observable_provider.h " | 17 #include "chrome/browser/content_settings/content_settings_observable_provider.h " |
18 #include "chrome/browser/content_settings/content_settings_platform_app_provider .h" | |
18 #include "chrome/browser/content_settings/content_settings_policy_provider.h" | 19 #include "chrome/browser/content_settings/content_settings_policy_provider.h" |
19 #include "chrome/browser/content_settings/content_settings_pref_provider.h" | 20 #include "chrome/browser/content_settings/content_settings_pref_provider.h" |
20 #include "chrome/browser/content_settings/content_settings_provider.h" | 21 #include "chrome/browser/content_settings/content_settings_provider.h" |
21 #include "chrome/browser/content_settings/content_settings_rule.h" | 22 #include "chrome/browser/content_settings/content_settings_rule.h" |
22 #include "chrome/browser/content_settings/content_settings_utils.h" | 23 #include "chrome/browser/content_settings/content_settings_utils.h" |
23 #include "chrome/browser/extensions/extension_service.h" | 24 #include "chrome/browser/extensions/extension_service.h" |
24 #include "chrome/browser/prefs/pref_service.h" | 25 #include "chrome/browser/prefs/pref_service.h" |
25 #include "chrome/common/chrome_notification_types.h" | 26 #include "chrome/common/chrome_notification_types.h" |
26 #include "chrome/common/chrome_switches.h" | 27 #include "chrome/common/chrome_switches.h" |
27 #include "chrome/common/content_settings_pattern.h" | 28 #include "chrome/common/content_settings_pattern.h" |
(...skipping 11 matching lines...) Expand all Loading... | |
39 using content::BrowserThread; | 40 using content::BrowserThread; |
40 using content::UserMetricsAction; | 41 using content::UserMetricsAction; |
41 | 42 |
42 namespace { | 43 namespace { |
43 | 44 |
44 typedef std::vector<content_settings::Rule> Rules; | 45 typedef std::vector<content_settings::Rule> Rules; |
45 | 46 |
46 typedef std::pair<std::string, std::string> StringPair; | 47 typedef std::pair<std::string, std::string> StringPair; |
47 | 48 |
48 const char* kProviderNames[] = { | 49 const char* kProviderNames[] = { |
50 "platform_app", | |
49 "policy", | 51 "policy", |
50 "extension", | 52 "extension", |
51 "preference", | 53 "preference", |
52 "default" | 54 "default" |
53 }; | 55 }; |
54 | 56 |
55 content_settings::SettingSource kProviderSourceMap[] = { | 57 content_settings::SettingSource kProviderSourceMap[] = { |
58 content_settings::SETTING_SOURCE_EXTENSION, | |
56 content_settings::SETTING_SOURCE_POLICY, | 59 content_settings::SETTING_SOURCE_POLICY, |
57 content_settings::SETTING_SOURCE_EXTENSION, | 60 content_settings::SETTING_SOURCE_EXTENSION, |
58 content_settings::SETTING_SOURCE_USER, | 61 content_settings::SETTING_SOURCE_USER, |
59 content_settings::SETTING_SOURCE_USER, | 62 content_settings::SETTING_SOURCE_USER, |
60 }; | 63 }; |
61 COMPILE_ASSERT(arraysize(kProviderSourceMap) == | 64 COMPILE_ASSERT(arraysize(kProviderSourceMap) == |
62 HostContentSettingsMap::NUM_PROVIDER_TYPES, | 65 HostContentSettingsMap::NUM_PROVIDER_TYPES, |
63 kProviderSourceMap_has_incorrect_size); | 66 kProviderSourceMap_has_incorrect_size); |
64 | 67 |
65 bool ContentTypeHasCompoundValue(ContentSettingsType type) { | 68 bool ContentTypeHasCompoundValue(ContentSettingsType type) { |
(...skipping 10 matching lines...) Expand all Loading... | |
76 } | 79 } |
77 | 80 |
78 } // namespace | 81 } // namespace |
79 | 82 |
80 HostContentSettingsMap::HostContentSettingsMap( | 83 HostContentSettingsMap::HostContentSettingsMap( |
81 PrefService* prefs, | 84 PrefService* prefs, |
82 ExtensionService* extension_service, | 85 ExtensionService* extension_service, |
83 bool incognito) | 86 bool incognito) |
84 : prefs_(prefs), | 87 : prefs_(prefs), |
85 is_off_the_record_(incognito) { | 88 is_off_the_record_(incognito) { |
89 content_settings::PlatformAppProvider* platform_app_provider = | |
90 new content_settings::PlatformAppProvider(); | |
91 content_settings_providers_[PLATFORM_APP_PROVIDER] = platform_app_provider; | |
92 | |
86 content_settings::ObservableProvider* policy_provider = | 93 content_settings::ObservableProvider* policy_provider = |
87 new content_settings::PolicyProvider(prefs_); | 94 new content_settings::PolicyProvider(prefs_); |
88 policy_provider->AddObserver(this); | 95 policy_provider->AddObserver(this); |
89 content_settings_providers_[POLICY_PROVIDER] = policy_provider; | 96 content_settings_providers_[POLICY_PROVIDER] = policy_provider; |
90 | 97 |
91 if (extension_service) { | 98 if (extension_service) { |
92 // |extension_service| can be NULL in unit tests. | 99 // |extension_service| can be NULL in unit tests. |
93 content_settings::ObservableProvider* extension_provider = | 100 content_settings::ObservableProvider* extension_provider = |
94 new content_settings::ExtensionProvider( | 101 new content_settings::ExtensionProvider( |
95 extension_service->GetExtensionContentSettingsStore(), | 102 extension_service->GetExtensionContentSettingsStore(), |
(...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
399 | 406 |
400 bool HostContentSettingsMap::ShouldAllowAllContent( | 407 bool HostContentSettingsMap::ShouldAllowAllContent( |
401 const GURL& primary_url, | 408 const GURL& primary_url, |
402 const GURL& secondary_url, | 409 const GURL& secondary_url, |
403 ContentSettingsType content_type) { | 410 ContentSettingsType content_type) { |
404 if (content_type == CONTENT_SETTINGS_TYPE_NOTIFICATIONS || | 411 if (content_type == CONTENT_SETTINGS_TYPE_NOTIFICATIONS || |
405 content_type == CONTENT_SETTINGS_TYPE_GEOLOCATION) { | 412 content_type == CONTENT_SETTINGS_TYPE_GEOLOCATION) { |
406 return false; | 413 return false; |
407 } | 414 } |
408 if (primary_url.SchemeIs(chrome::kExtensionScheme)) { | 415 if (primary_url.SchemeIs(chrome::kExtensionScheme)) { |
409 return content_type != CONTENT_SETTINGS_TYPE_COOKIES || | 416 return content_type != CONTENT_SETTINGS_TYPE_PLUGINS && |
benwells
2012/01/27 04:03:52
Mihai: do you know if its OK to stop whitelisting
Mihai Parparita -not on Chrome
2012/01/28 00:17:02
I don't know the full story for this restriction (
| |
410 secondary_url.SchemeIs(chrome::kExtensionScheme); | 417 (content_type != CONTENT_SETTINGS_TYPE_COOKIES || |
418 secondary_url.SchemeIs(chrome::kExtensionScheme)); | |
411 } | 419 } |
412 return primary_url.SchemeIs(chrome::kChromeDevToolsScheme) || | 420 return primary_url.SchemeIs(chrome::kChromeDevToolsScheme) || |
413 primary_url.SchemeIs(chrome::kChromeInternalScheme) || | 421 primary_url.SchemeIs(chrome::kChromeInternalScheme) || |
414 primary_url.SchemeIs(chrome::kChromeUIScheme); | 422 primary_url.SchemeIs(chrome::kChromeUIScheme); |
415 } | 423 } |
416 | 424 |
417 base::Value* HostContentSettingsMap::GetWebsiteSetting( | 425 base::Value* HostContentSettingsMap::GetWebsiteSetting( |
418 const GURL& primary_url, | 426 const GURL& primary_url, |
419 const GURL& secondary_url, | 427 const GURL& secondary_url, |
420 ContentSettingsType content_type, | 428 ContentSettingsType content_type, |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
456 } | 464 } |
457 } | 465 } |
458 | 466 |
459 if (info) { | 467 if (info) { |
460 info->source = content_settings::SETTING_SOURCE_NONE; | 468 info->source = content_settings::SETTING_SOURCE_NONE; |
461 info->primary_pattern = ContentSettingsPattern(); | 469 info->primary_pattern = ContentSettingsPattern(); |
462 info->secondary_pattern = ContentSettingsPattern(); | 470 info->secondary_pattern = ContentSettingsPattern(); |
463 } | 471 } |
464 return NULL; | 472 return NULL; |
465 } | 473 } |
OLD | NEW |