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

Side by Side Diff: chrome/browser/content_settings/host_content_settings_map.cc

Issue 9169042: Block plugins for platform apps (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Fix plugin_tests on linux Created 8 years, 10 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 "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
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
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 299 matching lines...) Expand 10 before | Expand all | Expand 10 after
395 402
396 bool HostContentSettingsMap::ShouldAllowAllContent( 403 bool HostContentSettingsMap::ShouldAllowAllContent(
397 const GURL& primary_url, 404 const GURL& primary_url,
398 const GURL& secondary_url, 405 const GURL& secondary_url,
399 ContentSettingsType content_type) { 406 ContentSettingsType content_type) {
400 if (content_type == CONTENT_SETTINGS_TYPE_NOTIFICATIONS || 407 if (content_type == CONTENT_SETTINGS_TYPE_NOTIFICATIONS ||
401 content_type == CONTENT_SETTINGS_TYPE_GEOLOCATION) { 408 content_type == CONTENT_SETTINGS_TYPE_GEOLOCATION) {
402 return false; 409 return false;
403 } 410 }
404 if (primary_url.SchemeIs(chrome::kExtensionScheme)) { 411 if (primary_url.SchemeIs(chrome::kExtensionScheme)) {
405 return content_type != CONTENT_SETTINGS_TYPE_COOKIES || 412 return content_type != CONTENT_SETTINGS_TYPE_PLUGINS &&
406 secondary_url.SchemeIs(chrome::kExtensionScheme); 413 (content_type != CONTENT_SETTINGS_TYPE_COOKIES ||
414 secondary_url.SchemeIs(chrome::kExtensionScheme));
407 } 415 }
408 return primary_url.SchemeIs(chrome::kChromeDevToolsScheme) || 416 return primary_url.SchemeIs(chrome::kChromeDevToolsScheme) ||
409 primary_url.SchemeIs(chrome::kChromeInternalScheme) || 417 primary_url.SchemeIs(chrome::kChromeInternalScheme) ||
410 primary_url.SchemeIs(chrome::kChromeUIScheme); 418 primary_url.SchemeIs(chrome::kChromeUIScheme);
411 } 419 }
412 420
413 base::Value* HostContentSettingsMap::GetWebsiteSetting( 421 base::Value* HostContentSettingsMap::GetWebsiteSetting(
414 const GURL& primary_url, 422 const GURL& primary_url,
415 const GURL& secondary_url, 423 const GURL& secondary_url,
416 ContentSettingsType content_type, 424 ContentSettingsType content_type,
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
452 } 460 }
453 } 461 }
454 462
455 if (info) { 463 if (info) {
456 info->source = content_settings::SETTING_SOURCE_NONE; 464 info->source = content_settings::SETTING_SOURCE_NONE;
457 info->primary_pattern = ContentSettingsPattern(); 465 info->primary_pattern = ContentSettingsPattern();
458 info->secondary_pattern = ContentSettingsPattern(); 466 info->secondary_pattern = ContentSettingsPattern();
459 } 467 }
460 return NULL; 468 return NULL;
461 } 469 }
OLDNEW
« no previous file with comments | « chrome/browser/content_settings/host_content_settings_map.h ('k') | chrome/browser/ui/extensions/shell_window.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698