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