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

Side by Side Diff: chrome/browser/ui/content_settings/content_setting_bubble_model.cc

Issue 1312053006: Remove CONTENT_SETTINGS_NUM_TYPES (part 2) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@website-settings-registry-4
Patch Set: Created 5 years, 3 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/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/macros.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
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_AUTOMATIC_DOWNLOADS,
73 CONTENT_SETTINGS_TYPE_MIDI_SYSEX,
74 };
75
58 // These states must match the order of appearance of the radio buttons 76 // These states must match the order of appearance of the radio buttons
59 // in the XIB file for the Mac port. 77 // in the XIB file for the Mac port.
60 enum RPHState { 78 enum RPHState {
61 RPH_ALLOW = 0, 79 RPH_ALLOW = 0,
62 RPH_BLOCK, 80 RPH_BLOCK,
63 RPH_IGNORE, 81 RPH_IGNORE,
64 }; 82 };
65 83
66 struct ContentSettingsTypeIdEntry { 84 struct ContentSettingsTypeIdEntry {
67 ContentSettingsType type; 85 ContentSettingsType type;
(...skipping 1189 matching lines...) Expand 10 before | Expand all | Expand 10 after
1257 for (const std::pair<GURL, ContentSetting>& map_entry : state_map) { 1275 for (const std::pair<GURL, ContentSetting>& map_entry : state_map) {
1258 settings_map->SetContentSetting( 1276 settings_map->SetContentSetting(
1259 ContentSettingsPattern::FromURLNoWildcard(map_entry.first), 1277 ContentSettingsPattern::FromURLNoWildcard(map_entry.first),
1260 ContentSettingsPattern::FromURLNoWildcard(embedder_url), 1278 ContentSettingsPattern::FromURLNoWildcard(embedder_url),
1261 CONTENT_SETTINGS_TYPE_MIDI_SYSEX, std::string(), 1279 CONTENT_SETTINGS_TYPE_MIDI_SYSEX, std::string(),
1262 CONTENT_SETTING_DEFAULT); 1280 CONTENT_SETTING_DEFAULT);
1263 } 1281 }
1264 } 1282 }
1265 1283
1266 // static 1284 // static
1285 const std::set<ContentSettingsType>&
1286 ContentSettingBubbleModel::GetSupportedBubbleTypes() {
1287 CR_DEFINE_STATIC_LOCAL(
1288 const std::set<ContentSettingsType>, supported_bubble_types,
1289 (kSupportedBubbleTypes,
1290 kSupportedBubbleTypes + arraysize(kSupportedBubbleTypes)));
1291 return supported_bubble_types;
1292 }
1293
1294 // static
1267 ContentSettingBubbleModel* 1295 ContentSettingBubbleModel*
1268 ContentSettingBubbleModel::CreateContentSettingBubbleModel( 1296 ContentSettingBubbleModel::CreateContentSettingBubbleModel(
1269 Delegate* delegate, 1297 Delegate* delegate,
1270 WebContents* web_contents, 1298 WebContents* web_contents,
1271 Profile* profile, 1299 Profile* profile,
1272 ContentSettingsType content_type) { 1300 ContentSettingsType content_type) {
1301 DCHECK(ContainsKey(GetSupportedBubbleTypes(), content_type));
1273 if (content_type == CONTENT_SETTINGS_TYPE_COOKIES) { 1302 if (content_type == CONTENT_SETTINGS_TYPE_COOKIES) {
1274 return new ContentSettingCookiesBubbleModel(delegate, web_contents, 1303 return new ContentSettingCookiesBubbleModel(delegate, web_contents,
1275 profile); 1304 profile);
1276 } 1305 }
1277 if (content_type == CONTENT_SETTINGS_TYPE_POPUPS) { 1306 if (content_type == CONTENT_SETTINGS_TYPE_POPUPS) {
1278 return new ContentSettingPopupBubbleModel(delegate, web_contents, profile); 1307 return new ContentSettingPopupBubbleModel(delegate, web_contents, profile);
1279 } 1308 }
1280 if (content_type == CONTENT_SETTINGS_TYPE_GEOLOCATION) { 1309 if (content_type == CONTENT_SETTINGS_TYPE_GEOLOCATION) {
1281 return new ContentSettingDomainListBubbleModel(delegate, web_contents, 1310 return new ContentSettingDomainListBubbleModel(delegate, web_contents,
1282 profile, content_type); 1311 profile, content_type);
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
1349 if (type == content::NOTIFICATION_WEB_CONTENTS_DESTROYED) { 1378 if (type == content::NOTIFICATION_WEB_CONTENTS_DESTROYED) {
1350 DCHECK_EQ(web_contents_, 1379 DCHECK_EQ(web_contents_,
1351 content::Source<WebContents>(source).ptr()); 1380 content::Source<WebContents>(source).ptr());
1352 web_contents_ = NULL; 1381 web_contents_ = NULL;
1353 } else { 1382 } else {
1354 DCHECK_EQ(chrome::NOTIFICATION_PROFILE_DESTROYED, type); 1383 DCHECK_EQ(chrome::NOTIFICATION_PROFILE_DESTROYED, type);
1355 DCHECK_EQ(profile_, content::Source<Profile>(source).ptr()); 1384 DCHECK_EQ(profile_, content::Source<Profile>(source).ptr());
1356 profile_ = NULL; 1385 profile_ = NULL;
1357 } 1386 }
1358 } 1387 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698