OLD | NEW |
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/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_custom_extension_prov
ider.h" | 14 #include "chrome/browser/content_settings/content_settings_custom_extension_prov
ider.h" |
15 #include "chrome/browser/content_settings/content_settings_default_provider.h" | 15 #include "chrome/browser/content_settings/content_settings_default_provider.h" |
16 #include "chrome/browser/content_settings/content_settings_details.h" | 16 #include "chrome/browser/content_settings/content_settings_details.h" |
17 #include "chrome/browser/content_settings/content_settings_internal_extension_pr
ovider.h" | 17 #include "chrome/browser/content_settings/content_settings_internal_extension_pr
ovider.h" |
18 #include "chrome/browser/content_settings/content_settings_observable_provider.h
" | 18 #include "chrome/browser/content_settings/content_settings_observable_provider.h
" |
19 #include "chrome/browser/content_settings/content_settings_policy_provider.h" | 19 #include "chrome/browser/content_settings/content_settings_policy_provider.h" |
20 #include "chrome/browser/content_settings/content_settings_pref_provider.h" | 20 #include "chrome/browser/content_settings/content_settings_pref_provider.h" |
21 #include "chrome/browser/content_settings/content_settings_provider.h" | 21 #include "chrome/browser/content_settings/content_settings_provider.h" |
22 #include "chrome/browser/content_settings/content_settings_rule.h" | 22 #include "chrome/browser/content_settings/content_settings_rule.h" |
23 #include "chrome/browser/content_settings/content_settings_utils.h" | 23 #include "chrome/browser/content_settings/content_settings_utils.h" |
24 #include "chrome/browser/extensions/extension_service.h" | 24 #include "chrome/browser/extensions/extension_service.h" |
25 #include "chrome/browser/intents/web_intents_util.h" | |
26 #include "chrome/browser/prefs/pref_registry_syncable.h" | 25 #include "chrome/browser/prefs/pref_registry_syncable.h" |
27 #include "chrome/browser/prefs/pref_service.h" | 26 #include "chrome/browser/prefs/pref_service.h" |
28 #include "chrome/common/chrome_notification_types.h" | 27 #include "chrome/common/chrome_notification_types.h" |
29 #include "chrome/common/chrome_switches.h" | 28 #include "chrome/common/chrome_switches.h" |
30 #include "chrome/common/content_settings_pattern.h" | 29 #include "chrome/common/content_settings_pattern.h" |
31 #include "chrome/common/pref_names.h" | 30 #include "chrome/common/pref_names.h" |
32 #include "chrome/common/url_constants.h" | 31 #include "chrome/common/url_constants.h" |
33 #include "content/public/browser/browser_thread.h" | 32 #include "content/public/browser/browser_thread.h" |
34 #include "content/public/browser/notification_service.h" | 33 #include "content/public/browser/notification_service.h" |
35 #include "content/public/browser/notification_source.h" | 34 #include "content/public/browser/notification_source.h" |
(...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
328 PrefService* prefs, const base::Value* value, ContentSettingsType type) { | 327 PrefService* prefs, const base::Value* value, ContentSettingsType type) { |
329 return ContentTypeHasCompoundValue(type) || IsSettingAllowedForType( | 328 return ContentTypeHasCompoundValue(type) || IsSettingAllowedForType( |
330 prefs, content_settings::ValueToContentSetting(value), type); | 329 prefs, content_settings::ValueToContentSetting(value), type); |
331 } | 330 } |
332 | 331 |
333 // static | 332 // static |
334 bool HostContentSettingsMap::IsSettingAllowedForType( | 333 bool HostContentSettingsMap::IsSettingAllowedForType( |
335 PrefService* prefs, | 334 PrefService* prefs, |
336 ContentSetting setting, | 335 ContentSetting setting, |
337 ContentSettingsType content_type) { | 336 ContentSettingsType content_type) { |
338 // Intents content settings are hidden behind a switch for now. | |
339 if (content_type == CONTENT_SETTINGS_TYPE_INTENTS) { | |
340 if (!web_intents::IsWebIntentsEnabled(prefs)) | |
341 return false; | |
342 } | |
343 | |
344 // We don't yet support stored content settings for mixed scripting. | 337 // We don't yet support stored content settings for mixed scripting. |
345 if (content_type == CONTENT_SETTINGS_TYPE_MIXEDSCRIPT) | 338 if (content_type == CONTENT_SETTINGS_TYPE_MIXEDSCRIPT) |
346 return false; | 339 return false; |
347 | 340 |
348 // BLOCK semantics are not implemented for fullscreen. | 341 // BLOCK semantics are not implemented for fullscreen. |
349 if (content_type == CONTENT_SETTINGS_TYPE_FULLSCREEN && | 342 if (content_type == CONTENT_SETTINGS_TYPE_FULLSCREEN && |
350 setting == CONTENT_SETTING_BLOCK) { | 343 setting == CONTENT_SETTING_BLOCK) { |
351 return false; | 344 return false; |
352 } | 345 } |
353 | 346 |
354 // We don't support ALLOW for media default setting. | 347 // We don't support ALLOW for media default setting. |
355 if (content_type == CONTENT_SETTINGS_TYPE_MEDIASTREAM && | 348 if (content_type == CONTENT_SETTINGS_TYPE_MEDIASTREAM && |
356 setting == CONTENT_SETTING_ALLOW) { | 349 setting == CONTENT_SETTING_ALLOW) { |
357 return false; | 350 return false; |
358 } | 351 } |
359 | 352 |
360 // DEFAULT, ALLOW and BLOCK are always allowed. | 353 // DEFAULT, ALLOW and BLOCK are always allowed. |
361 if (setting == CONTENT_SETTING_DEFAULT || | 354 if (setting == CONTENT_SETTING_DEFAULT || |
362 setting == CONTENT_SETTING_ALLOW || | 355 setting == CONTENT_SETTING_ALLOW || |
363 setting == CONTENT_SETTING_BLOCK) { | 356 setting == CONTENT_SETTING_BLOCK) { |
364 return true; | 357 return true; |
365 } | 358 } |
366 switch (content_type) { | 359 switch (content_type) { |
367 case CONTENT_SETTINGS_TYPE_COOKIES: | 360 case CONTENT_SETTINGS_TYPE_COOKIES: |
368 return setting == CONTENT_SETTING_SESSION_ONLY; | 361 return setting == CONTENT_SETTING_SESSION_ONLY; |
369 case CONTENT_SETTINGS_TYPE_PLUGINS: | 362 case CONTENT_SETTINGS_TYPE_PLUGINS: |
370 case CONTENT_SETTINGS_TYPE_GEOLOCATION: | 363 case CONTENT_SETTINGS_TYPE_GEOLOCATION: |
371 case CONTENT_SETTINGS_TYPE_NOTIFICATIONS: | 364 case CONTENT_SETTINGS_TYPE_NOTIFICATIONS: |
372 case CONTENT_SETTINGS_TYPE_INTENTS: | |
373 case CONTENT_SETTINGS_TYPE_MOUSELOCK: | 365 case CONTENT_SETTINGS_TYPE_MOUSELOCK: |
374 case CONTENT_SETTINGS_TYPE_MEDIASTREAM: | 366 case CONTENT_SETTINGS_TYPE_MEDIASTREAM: |
375 case CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC: | 367 case CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC: |
376 case CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA: | 368 case CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA: |
377 case CONTENT_SETTINGS_TYPE_PPAPI_BROKER: | 369 case CONTENT_SETTINGS_TYPE_PPAPI_BROKER: |
378 return setting == CONTENT_SETTING_ASK; | 370 return setting == CONTENT_SETTING_ASK; |
379 default: | 371 default: |
380 return false; | 372 return false; |
381 } | 373 } |
382 } | 374 } |
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
583 HostContentSettingsMap::GetProviderTypeFromSource( | 575 HostContentSettingsMap::GetProviderTypeFromSource( |
584 const std::string& source) { | 576 const std::string& source) { |
585 for (size_t i = 0; i < arraysize(kProviderNames); ++i) { | 577 for (size_t i = 0; i < arraysize(kProviderNames); ++i) { |
586 if (source == kProviderNames[i]) | 578 if (source == kProviderNames[i]) |
587 return static_cast<ProviderType>(i); | 579 return static_cast<ProviderType>(i); |
588 } | 580 } |
589 | 581 |
590 NOTREACHED(); | 582 NOTREACHED(); |
591 return DEFAULT_PROVIDER; | 583 return DEFAULT_PROVIDER; |
592 } | 584 } |
OLD | NEW |