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/ui/content_settings/content_setting_bubble_model.h" | 5 #include "chrome/browser/ui/content_settings/content_setting_bubble_model.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/lazy_instance.h" | |
8 #include "base/prefs/pref_service.h" | 9 #include "base/prefs/pref_service.h" |
10 #include "base/stl_util.h" | |
9 #include "base/strings/utf_string_conversions.h" | 11 #include "base/strings/utf_string_conversions.h" |
10 #include "chrome/browser/chrome_notification_types.h" | 12 #include "chrome/browser/chrome_notification_types.h" |
11 #include "chrome/browser/content_settings/chrome_content_settings_utils.h" | 13 #include "chrome/browser/content_settings/chrome_content_settings_utils.h" |
12 #include "chrome/browser/content_settings/cookie_settings_factory.h" | 14 #include "chrome/browser/content_settings/cookie_settings_factory.h" |
13 #include "chrome/browser/content_settings/tab_specific_content_settings.h" | 15 #include "chrome/browser/content_settings/tab_specific_content_settings.h" |
14 #include "chrome/browser/custom_handlers/protocol_handler_registry.h" | 16 #include "chrome/browser/custom_handlers/protocol_handler_registry.h" |
15 #include "chrome/browser/custom_handlers/protocol_handler_registry_factory.h" | 17 #include "chrome/browser/custom_handlers/protocol_handler_registry_factory.h" |
16 #include "chrome/browser/infobars/infobar_service.h" | 18 #include "chrome/browser/infobars/infobar_service.h" |
17 #include "chrome/browser/media/media_capture_devices_dispatcher.h" | 19 #include "chrome/browser/media/media_capture_devices_dispatcher.h" |
18 #include "chrome/browser/plugins/chrome_plugin_service_filter.h" | 20 #include "chrome/browser/plugins/chrome_plugin_service_filter.h" |
(...skipping 29 matching lines...) Expand all Loading... | |
48 using content::WebContents; | 50 using content::WebContents; |
49 using content_settings::SettingInfo; | 51 using content_settings::SettingInfo; |
50 using content_settings::SettingSource; | 52 using content_settings::SettingSource; |
51 using content_settings::SETTING_SOURCE_USER; | 53 using content_settings::SETTING_SOURCE_USER; |
52 using content_settings::SETTING_SOURCE_NONE; | 54 using content_settings::SETTING_SOURCE_NONE; |
53 | 55 |
54 namespace { | 56 namespace { |
55 | 57 |
56 const int kAllowButtonIndex = 0; | 58 const int kAllowButtonIndex = 0; |
57 | 59 |
60 // static | |
61 const ContentSettingsType kSupportedBubbleTypes[] = { | |
62 CONTENT_SETTINGS_TYPE_COOKIES, | |
63 CONTENT_SETTINGS_TYPE_IMAGES, | |
64 CONTENT_SETTINGS_TYPE_JAVASCRIPT, | |
65 CONTENT_SETTINGS_TYPE_PPAPI_BROKER, | |
66 CONTENT_SETTINGS_TYPE_PLUGINS, | |
67 CONTENT_SETTINGS_TYPE_POPUPS, | |
68 CONTENT_SETTINGS_TYPE_GEOLOCATION, | |
69 CONTENT_SETTINGS_TYPE_MIXEDSCRIPT, | |
70 CONTENT_SETTINGS_TYPE_PROTOCOL_HANDLERS, | |
71 CONTENT_SETTINGS_TYPE_MEDIASTREAM, | |
72 CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC, | |
73 CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA, | |
74 CONTENT_SETTINGS_TYPE_AUTOMATIC_DOWNLOADS, | |
75 CONTENT_SETTINGS_TYPE_MIDI_SYSEX, | |
76 }; | |
77 | |
58 // These states must match the order of appearance of the radio buttons | 78 // These states must match the order of appearance of the radio buttons |
59 // in the XIB file for the Mac port. | 79 // in the XIB file for the Mac port. |
60 enum RPHState { | 80 enum RPHState { |
61 RPH_ALLOW = 0, | 81 RPH_ALLOW = 0, |
62 RPH_BLOCK, | 82 RPH_BLOCK, |
63 RPH_IGNORE, | 83 RPH_IGNORE, |
64 }; | 84 }; |
65 | 85 |
66 struct ContentSettingsTypeIdEntry { | 86 struct ContentSettingsTypeIdEntry { |
67 ContentSettingsType type; | 87 ContentSettingsType type; |
(...skipping 1188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1256 | 1276 |
1257 for (const std::pair<GURL, ContentSetting>& map_entry : state_map) { | 1277 for (const std::pair<GURL, ContentSetting>& map_entry : state_map) { |
1258 settings_map->SetContentSetting( | 1278 settings_map->SetContentSetting( |
1259 ContentSettingsPattern::FromURLNoWildcard(map_entry.first), | 1279 ContentSettingsPattern::FromURLNoWildcard(map_entry.first), |
1260 ContentSettingsPattern::FromURLNoWildcard(embedder_url), | 1280 ContentSettingsPattern::FromURLNoWildcard(embedder_url), |
1261 CONTENT_SETTINGS_TYPE_MIDI_SYSEX, std::string(), | 1281 CONTENT_SETTINGS_TYPE_MIDI_SYSEX, std::string(), |
1262 CONTENT_SETTING_DEFAULT); | 1282 CONTENT_SETTING_DEFAULT); |
1263 } | 1283 } |
1264 } | 1284 } |
1265 | 1285 |
1286 base::LazyInstance<std::set<ContentSettingsType>> g_supported_bubble_types = | |
tapted
2015/09/03 06:36:38
either:
anonymous namespace + base::LazyInstance<
raymes
2015/09/07 04:29:27
Ah you're right - I had this before but changed it
| |
1287 LAZY_INSTANCE_INITIALIZER; | |
1288 | |
1289 // static | |
1290 const std::set<ContentSettingsType>& | |
1291 ContentSettingBubbleModel::GetSupportedBubbleTypes() { | |
1292 std::set<ContentSettingsType>& types = g_supported_bubble_types.Get(); | |
1293 if (types.empty()) { | |
1294 types.insert(kSupportedBubbleTypes, | |
1295 kSupportedBubbleTypes + arraysize(kSupportedBubbleTypes)); | |
1296 } | |
1297 return types; | |
1298 } | |
1299 | |
1266 // static | 1300 // static |
1267 ContentSettingBubbleModel* | 1301 ContentSettingBubbleModel* |
1268 ContentSettingBubbleModel::CreateContentSettingBubbleModel( | 1302 ContentSettingBubbleModel::CreateContentSettingBubbleModel( |
1269 Delegate* delegate, | 1303 Delegate* delegate, |
1270 WebContents* web_contents, | 1304 WebContents* web_contents, |
1271 Profile* profile, | 1305 Profile* profile, |
1272 ContentSettingsType content_type) { | 1306 ContentSettingsType content_type) { |
1307 DCHECK(ContainsKey(GetSupportedBubbleTypes(), content_type)); | |
tapted
2015/09/03 06:36:38
I've never really understood ContainsKey.... if yo
raymes
2015/09/07 04:29:27
I agree with you - I used to do that but I've had
| |
1273 if (content_type == CONTENT_SETTINGS_TYPE_COOKIES) { | 1308 if (content_type == CONTENT_SETTINGS_TYPE_COOKIES) { |
1274 return new ContentSettingCookiesBubbleModel(delegate, web_contents, | 1309 return new ContentSettingCookiesBubbleModel(delegate, web_contents, |
1275 profile); | 1310 profile); |
1276 } | 1311 } |
1277 if (content_type == CONTENT_SETTINGS_TYPE_POPUPS) { | 1312 if (content_type == CONTENT_SETTINGS_TYPE_POPUPS) { |
1278 return new ContentSettingPopupBubbleModel(delegate, web_contents, profile); | 1313 return new ContentSettingPopupBubbleModel(delegate, web_contents, profile); |
1279 } | 1314 } |
1280 if (content_type == CONTENT_SETTINGS_TYPE_GEOLOCATION) { | 1315 if (content_type == CONTENT_SETTINGS_TYPE_GEOLOCATION) { |
1281 return new ContentSettingDomainListBubbleModel(delegate, web_contents, | 1316 return new ContentSettingDomainListBubbleModel(delegate, web_contents, |
1282 profile, content_type); | 1317 profile, content_type); |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1349 if (type == content::NOTIFICATION_WEB_CONTENTS_DESTROYED) { | 1384 if (type == content::NOTIFICATION_WEB_CONTENTS_DESTROYED) { |
1350 DCHECK_EQ(web_contents_, | 1385 DCHECK_EQ(web_contents_, |
1351 content::Source<WebContents>(source).ptr()); | 1386 content::Source<WebContents>(source).ptr()); |
1352 web_contents_ = NULL; | 1387 web_contents_ = NULL; |
1353 } else { | 1388 } else { |
1354 DCHECK_EQ(chrome::NOTIFICATION_PROFILE_DESTROYED, type); | 1389 DCHECK_EQ(chrome::NOTIFICATION_PROFILE_DESTROYED, type); |
1355 DCHECK_EQ(profile_, content::Source<Profile>(source).ptr()); | 1390 DCHECK_EQ(profile_, content::Source<Profile>(source).ptr()); |
1356 profile_ = NULL; | 1391 profile_ = NULL; |
1357 } | 1392 } |
1358 } | 1393 } |
OLD | NEW |