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

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

Issue 2561673003: Handle per-tab AUTOMATIC_DOWNLOADS setting in DownloadRequestLimiter. (Closed)
Patch Set: Fix whitespace Created 3 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/ui/content_settings/content_setting_bubble_model.h" 5 #include "chrome/browser/ui/content_settings/content_setting_bubble_model.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/feature_list.h" 10 #include "base/feature_list.h"
11 #include "base/macros.h" 11 #include "base/macros.h"
12 #include "base/stl_util.h" 12 #include "base/stl_util.h"
13 #include "base/strings/utf_string_conversions.h" 13 #include "base/strings/utf_string_conversions.h"
14 #include "chrome/browser/browser_process.h" 14 #include "chrome/browser/browser_process.h"
15 #include "chrome/browser/chrome_notification_types.h" 15 #include "chrome/browser/chrome_notification_types.h"
16 #include "chrome/browser/content_settings/chrome_content_settings_utils.h" 16 #include "chrome/browser/content_settings/chrome_content_settings_utils.h"
17 #include "chrome/browser/content_settings/cookie_settings_factory.h" 17 #include "chrome/browser/content_settings/cookie_settings_factory.h"
18 #include "chrome/browser/content_settings/host_content_settings_map_factory.h" 18 #include "chrome/browser/content_settings/host_content_settings_map_factory.h"
19 #include "chrome/browser/custom_handlers/protocol_handler_registry.h" 19 #include "chrome/browser/custom_handlers/protocol_handler_registry.h"
20 #include "chrome/browser/custom_handlers/protocol_handler_registry_factory.h" 20 #include "chrome/browser/custom_handlers/protocol_handler_registry_factory.h"
21 #include "chrome/browser/download/download_request_limiter.h"
21 #include "chrome/browser/infobars/infobar_service.h" 22 #include "chrome/browser/infobars/infobar_service.h"
22 #include "chrome/browser/media/webrtc/media_capture_devices_dispatcher.h" 23 #include "chrome/browser/media/webrtc/media_capture_devices_dispatcher.h"
23 #include "chrome/browser/permissions/permission_uma_util.h" 24 #include "chrome/browser/permissions/permission_uma_util.h"
24 #include "chrome/browser/permissions/permission_util.h" 25 #include "chrome/browser/permissions/permission_util.h"
25 #include "chrome/browser/plugins/chrome_plugin_service_filter.h" 26 #include "chrome/browser/plugins/chrome_plugin_service_filter.h"
26 #include "chrome/browser/plugins/plugin_utils.h" 27 #include "chrome/browser/plugins/plugin_utils.h"
27 #include "chrome/browser/profiles/profile.h" 28 #include "chrome/browser/profiles/profile.h"
28 #include "chrome/browser/ui/blocked_content/popup_blocker_tab_helper.h" 29 #include "chrome/browser/ui/blocked_content/popup_blocker_tab_helper.h"
29 #include "chrome/browser/ui/collected_cookies_infobar_delegate.h" 30 #include "chrome/browser/ui/collected_cookies_infobar_delegate.h"
30 #include "chrome/browser/ui/content_settings/content_setting_bubble_model_delega te.h" 31 #include "chrome/browser/ui/content_settings/content_setting_bubble_model_delega te.h"
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 static const ContentSettingsTypeIdEntry kBlockedTitleIDs[] = { 138 static const ContentSettingsTypeIdEntry kBlockedTitleIDs[] = {
138 {CONTENT_SETTINGS_TYPE_COOKIES, IDS_BLOCKED_COOKIES_TITLE}, 139 {CONTENT_SETTINGS_TYPE_COOKIES, IDS_BLOCKED_COOKIES_TITLE},
139 {CONTENT_SETTINGS_TYPE_IMAGES, IDS_BLOCKED_IMAGES_TITLE}, 140 {CONTENT_SETTINGS_TYPE_IMAGES, IDS_BLOCKED_IMAGES_TITLE},
140 {CONTENT_SETTINGS_TYPE_JAVASCRIPT, IDS_BLOCKED_JAVASCRIPT_TITLE}, 141 {CONTENT_SETTINGS_TYPE_JAVASCRIPT, IDS_BLOCKED_JAVASCRIPT_TITLE},
141 {CONTENT_SETTINGS_TYPE_PLUGINS, IDS_BLOCKED_PLUGINS_TITLE}, 142 {CONTENT_SETTINGS_TYPE_PLUGINS, IDS_BLOCKED_PLUGINS_TITLE},
142 {CONTENT_SETTINGS_TYPE_POPUPS, IDS_BLOCKED_POPUPS_TITLE}, 143 {CONTENT_SETTINGS_TYPE_POPUPS, IDS_BLOCKED_POPUPS_TITLE},
143 {CONTENT_SETTINGS_TYPE_MIXEDSCRIPT, 144 {CONTENT_SETTINGS_TYPE_MIXEDSCRIPT,
144 IDS_BLOCKED_DISPLAYING_INSECURE_CONTENT}, 145 IDS_BLOCKED_DISPLAYING_INSECURE_CONTENT},
145 {CONTENT_SETTINGS_TYPE_PPAPI_BROKER, 146 {CONTENT_SETTINGS_TYPE_PPAPI_BROKER,
146 IDS_BLOCKED_PPAPI_BROKER_TITLE}, 147 IDS_BLOCKED_PPAPI_BROKER_TITLE},
147 {CONTENT_SETTINGS_TYPE_AUTOMATIC_DOWNLOADS, IDS_BLOCKED_DOWNLOAD_TITLE},
148 }; 148 };
149 // Fields as for kBlockedTitleIDs, above. 149 // Fields as for kBlockedTitleIDs, above.
150 static const ContentSettingsTypeIdEntry kAccessedTitleIDs[] = { 150 static const ContentSettingsTypeIdEntry kAccessedTitleIDs[] = {
151 {CONTENT_SETTINGS_TYPE_COOKIES, IDS_ACCESSED_COOKIES_TITLE}, 151 {CONTENT_SETTINGS_TYPE_COOKIES, IDS_ACCESSED_COOKIES_TITLE},
152 {CONTENT_SETTINGS_TYPE_PPAPI_BROKER, IDS_ALLOWED_PPAPI_BROKER_TITLE}, 152 {CONTENT_SETTINGS_TYPE_PPAPI_BROKER, IDS_ALLOWED_PPAPI_BROKER_TITLE},
153 {CONTENT_SETTINGS_TYPE_AUTOMATIC_DOWNLOADS, IDS_ALLOWED_DOWNLOAD_TITLE},
154 }; 153 };
155 const ContentSettingsTypeIdEntry* title_ids = kBlockedTitleIDs; 154 const ContentSettingsTypeIdEntry* title_ids = kBlockedTitleIDs;
156 size_t num_title_ids = arraysize(kBlockedTitleIDs); 155 size_t num_title_ids = arraysize(kBlockedTitleIDs);
157 if (content_settings && content_settings->IsContentAllowed(content_type()) && 156 if (content_settings && content_settings->IsContentAllowed(content_type()) &&
158 !content_settings->IsContentBlocked(content_type())) { 157 !content_settings->IsContentBlocked(content_type())) {
159 title_ids = kAccessedTitleIDs; 158 title_ids = kAccessedTitleIDs;
160 num_title_ids = arraysize(kAccessedTitleIDs); 159 num_title_ids = arraysize(kAccessedTitleIDs);
161 } 160 }
162 int title_id = GetIdForContentType(title_ids, num_title_ids, content_type()); 161 int title_id = GetIdForContentType(title_ids, num_title_ids, content_type());
163 if (title_id) 162 if (title_id)
164 set_title(l10n_util::GetStringUTF16(title_id)); 163 set_title(l10n_util::GetStringUTF16(title_id));
165 } 164 }
166 165
167 void ContentSettingSimpleBubbleModel::SetManageText() { 166 void ContentSettingSimpleBubbleModel::SetManageText() {
168 static const ContentSettingsTypeIdEntry kLinkIDs[] = { 167 static const ContentSettingsTypeIdEntry kLinkIDs[] = {
169 {CONTENT_SETTINGS_TYPE_COOKIES, IDS_BLOCKED_COOKIES_LINK}, 168 {CONTENT_SETTINGS_TYPE_COOKIES, IDS_BLOCKED_COOKIES_LINK},
170 {CONTENT_SETTINGS_TYPE_IMAGES, IDS_BLOCKED_IMAGES_LINK}, 169 {CONTENT_SETTINGS_TYPE_IMAGES, IDS_BLOCKED_IMAGES_LINK},
171 {CONTENT_SETTINGS_TYPE_JAVASCRIPT, IDS_BLOCKED_JAVASCRIPT_LINK}, 170 {CONTENT_SETTINGS_TYPE_JAVASCRIPT, IDS_BLOCKED_JAVASCRIPT_LINK},
172 {CONTENT_SETTINGS_TYPE_PLUGINS, IDS_BLOCKED_PLUGINS_LINK}, 171 {CONTENT_SETTINGS_TYPE_PLUGINS, IDS_BLOCKED_PLUGINS_LINK},
173 {CONTENT_SETTINGS_TYPE_POPUPS, IDS_BLOCKED_POPUPS_LINK}, 172 {CONTENT_SETTINGS_TYPE_POPUPS, IDS_BLOCKED_POPUPS_LINK},
174 {CONTENT_SETTINGS_TYPE_GEOLOCATION, IDS_GEOLOCATION_BUBBLE_MANAGE_LINK}, 173 {CONTENT_SETTINGS_TYPE_GEOLOCATION, IDS_GEOLOCATION_BUBBLE_MANAGE_LINK},
175 {CONTENT_SETTINGS_TYPE_MIXEDSCRIPT, IDS_LEARN_MORE}, 174 {CONTENT_SETTINGS_TYPE_MIXEDSCRIPT, IDS_LEARN_MORE},
176 {CONTENT_SETTINGS_TYPE_PROTOCOL_HANDLERS, IDS_HANDLERS_BUBBLE_MANAGE_LINK}, 175 {CONTENT_SETTINGS_TYPE_PROTOCOL_HANDLERS, IDS_HANDLERS_BUBBLE_MANAGE_LINK},
177 {CONTENT_SETTINGS_TYPE_PPAPI_BROKER, IDS_PPAPI_BROKER_BUBBLE_MANAGE_LINK}, 176 {CONTENT_SETTINGS_TYPE_PPAPI_BROKER, IDS_PPAPI_BROKER_BUBBLE_MANAGE_LINK},
178 {CONTENT_SETTINGS_TYPE_AUTOMATIC_DOWNLOADS, IDS_BLOCKED_DOWNLOADS_LINK},
179 {CONTENT_SETTINGS_TYPE_MIDI_SYSEX, IDS_MIDI_SYSEX_BUBBLE_MANAGE_LINK}, 177 {CONTENT_SETTINGS_TYPE_MIDI_SYSEX, IDS_MIDI_SYSEX_BUBBLE_MANAGE_LINK},
180 }; 178 };
181 set_manage_text(l10n_util::GetStringUTF8( 179 set_manage_text(l10n_util::GetStringUTF8(
182 GetIdForContentType(kLinkIDs, arraysize(kLinkIDs), content_type()))); 180 GetIdForContentType(kLinkIDs, arraysize(kLinkIDs), content_type())));
183 } 181 }
184 182
185 void ContentSettingSimpleBubbleModel::OnManageLinkClicked() { 183 void ContentSettingSimpleBubbleModel::OnManageLinkClicked() {
186 if (delegate()) 184 if (delegate())
187 delegate()->ShowContentSettingsPage(content_type()); 185 delegate()->ShowContentSettingsPage(content_type());
188 186
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
281 RadioGroup radio_group; 279 RadioGroup radio_group;
282 radio_group.url = url; 280 radio_group.url = url;
283 281
284 static const ContentSettingsTypeIdEntry kBlockedAllowIDs[] = { 282 static const ContentSettingsTypeIdEntry kBlockedAllowIDs[] = {
285 {CONTENT_SETTINGS_TYPE_COOKIES, IDS_BLOCKED_COOKIES_UNBLOCK}, 283 {CONTENT_SETTINGS_TYPE_COOKIES, IDS_BLOCKED_COOKIES_UNBLOCK},
286 {CONTENT_SETTINGS_TYPE_IMAGES, IDS_BLOCKED_IMAGES_UNBLOCK}, 284 {CONTENT_SETTINGS_TYPE_IMAGES, IDS_BLOCKED_IMAGES_UNBLOCK},
287 {CONTENT_SETTINGS_TYPE_JAVASCRIPT, IDS_BLOCKED_JAVASCRIPT_UNBLOCK}, 285 {CONTENT_SETTINGS_TYPE_JAVASCRIPT, IDS_BLOCKED_JAVASCRIPT_UNBLOCK},
288 {CONTENT_SETTINGS_TYPE_PLUGINS, IDS_BLOCKED_PLUGINS_UNBLOCK_ALL}, 286 {CONTENT_SETTINGS_TYPE_PLUGINS, IDS_BLOCKED_PLUGINS_UNBLOCK_ALL},
289 {CONTENT_SETTINGS_TYPE_POPUPS, IDS_BLOCKED_POPUPS_UNBLOCK}, 287 {CONTENT_SETTINGS_TYPE_POPUPS, IDS_BLOCKED_POPUPS_UNBLOCK},
290 {CONTENT_SETTINGS_TYPE_PPAPI_BROKER, IDS_BLOCKED_PPAPI_BROKER_UNBLOCK}, 288 {CONTENT_SETTINGS_TYPE_PPAPI_BROKER, IDS_BLOCKED_PPAPI_BROKER_UNBLOCK},
291 {CONTENT_SETTINGS_TYPE_AUTOMATIC_DOWNLOADS, IDS_BLOCKED_DOWNLOAD_UNBLOCK},
292 }; 289 };
293 // Fields as for kBlockedAllowIDs, above. 290 // Fields as for kBlockedAllowIDs, above.
294 static const ContentSettingsTypeIdEntry kAllowedAllowIDs[] = { 291 static const ContentSettingsTypeIdEntry kAllowedAllowIDs[] = {
295 {CONTENT_SETTINGS_TYPE_COOKIES, IDS_ALLOWED_COOKIES_NO_ACTION}, 292 {CONTENT_SETTINGS_TYPE_COOKIES, IDS_ALLOWED_COOKIES_NO_ACTION},
296 {CONTENT_SETTINGS_TYPE_PPAPI_BROKER, IDS_ALLOWED_PPAPI_BROKER_NO_ACTION}, 293 {CONTENT_SETTINGS_TYPE_PPAPI_BROKER, IDS_ALLOWED_PPAPI_BROKER_NO_ACTION},
297 {CONTENT_SETTINGS_TYPE_AUTOMATIC_DOWNLOADS, IDS_ALLOWED_DOWNLOAD_NO_ACTION},
298 }; 294 };
299 295
300 std::string radio_allow_label; 296 std::string radio_allow_label;
301 if (allowed) { 297 if (allowed) {
302 int resource_id = GetIdForContentType(kAllowedAllowIDs, 298 int resource_id = GetIdForContentType(kAllowedAllowIDs,
303 arraysize(kAllowedAllowIDs), 299 arraysize(kAllowedAllowIDs),
304 content_type()); 300 content_type());
305 radio_allow_label = l10n_util::GetStringUTF8(resource_id); 301 radio_allow_label = l10n_util::GetStringUTF8(resource_id);
306 } else { 302 } else {
307 radio_allow_label = l10n_util::GetStringFUTF8( 303 radio_allow_label = l10n_util::GetStringFUTF8(
308 GetIdForContentType(kBlockedAllowIDs, arraysize(kBlockedAllowIDs), 304 GetIdForContentType(kBlockedAllowIDs, arraysize(kBlockedAllowIDs),
309 content_type()), 305 content_type()),
310 display_host); 306 display_host);
311 } 307 }
312 308
313 static const ContentSettingsTypeIdEntry kBlockedBlockIDs[] = { 309 static const ContentSettingsTypeIdEntry kBlockedBlockIDs[] = {
314 {CONTENT_SETTINGS_TYPE_COOKIES, IDS_BLOCKED_COOKIES_NO_ACTION}, 310 {CONTENT_SETTINGS_TYPE_COOKIES, IDS_BLOCKED_COOKIES_NO_ACTION},
315 {CONTENT_SETTINGS_TYPE_IMAGES, IDS_BLOCKED_IMAGES_NO_ACTION}, 311 {CONTENT_SETTINGS_TYPE_IMAGES, IDS_BLOCKED_IMAGES_NO_ACTION},
316 {CONTENT_SETTINGS_TYPE_JAVASCRIPT, IDS_BLOCKED_JAVASCRIPT_NO_ACTION}, 312 {CONTENT_SETTINGS_TYPE_JAVASCRIPT, IDS_BLOCKED_JAVASCRIPT_NO_ACTION},
317 {CONTENT_SETTINGS_TYPE_PLUGINS, IDS_BLOCKED_PLUGINS_NO_ACTION}, 313 {CONTENT_SETTINGS_TYPE_PLUGINS, IDS_BLOCKED_PLUGINS_NO_ACTION},
318 {CONTENT_SETTINGS_TYPE_POPUPS, IDS_BLOCKED_POPUPS_NO_ACTION}, 314 {CONTENT_SETTINGS_TYPE_POPUPS, IDS_BLOCKED_POPUPS_NO_ACTION},
319 {CONTENT_SETTINGS_TYPE_PPAPI_BROKER, IDS_BLOCKED_PPAPI_BROKER_NO_ACTION}, 315 {CONTENT_SETTINGS_TYPE_PPAPI_BROKER, IDS_BLOCKED_PPAPI_BROKER_NO_ACTION},
320 {CONTENT_SETTINGS_TYPE_AUTOMATIC_DOWNLOADS, IDS_BLOCKED_DOWNLOAD_NO_ACTION},
321 }; 316 };
322 static const ContentSettingsTypeIdEntry kAllowedBlockIDs[] = { 317 static const ContentSettingsTypeIdEntry kAllowedBlockIDs[] = {
323 {CONTENT_SETTINGS_TYPE_COOKIES, IDS_ALLOWED_COOKIES_BLOCK}, 318 {CONTENT_SETTINGS_TYPE_COOKIES, IDS_ALLOWED_COOKIES_BLOCK},
324 {CONTENT_SETTINGS_TYPE_PPAPI_BROKER, IDS_ALLOWED_PPAPI_BROKER_BLOCK}, 319 {CONTENT_SETTINGS_TYPE_PPAPI_BROKER, IDS_ALLOWED_PPAPI_BROKER_BLOCK},
325 {CONTENT_SETTINGS_TYPE_AUTOMATIC_DOWNLOADS, IDS_ALLOWED_DOWNLOAD_BLOCK},
326 }; 320 };
327 321
328 std::string radio_block_label; 322 std::string radio_block_label;
329 if (allowed) { 323 if (allowed) {
330 int resource_id = GetIdForContentType(kAllowedBlockIDs, 324 int resource_id = GetIdForContentType(kAllowedBlockIDs,
331 arraysize(kAllowedBlockIDs), 325 arraysize(kAllowedBlockIDs),
332 content_type()); 326 content_type());
333 radio_block_label = l10n_util::GetStringFUTF8(resource_id, display_host); 327 radio_block_label = l10n_util::GetStringFUTF8(resource_id, display_host);
334 } else { 328 } else {
335 radio_block_label = l10n_util::GetStringUTF8( 329 radio_block_label = l10n_util::GetStringUTF8(
(...skipping 1000 matching lines...) Expand 10 before | Expand all | Expand 10 after
1336 for (const std::pair<GURL, ContentSetting>& map_entry : state_map) { 1330 for (const std::pair<GURL, ContentSetting>& map_entry : state_map) {
1337 PermissionUtil::ScopedRevocationReporter( 1331 PermissionUtil::ScopedRevocationReporter(
1338 profile(), map_entry.first, embedder_url, 1332 profile(), map_entry.first, embedder_url,
1339 CONTENT_SETTINGS_TYPE_MIDI_SYSEX, PermissionSourceUI::PAGE_ACTION); 1333 CONTENT_SETTINGS_TYPE_MIDI_SYSEX, PermissionSourceUI::PAGE_ACTION);
1340 map->SetContentSettingDefaultScope(map_entry.first, embedder_url, 1334 map->SetContentSettingDefaultScope(map_entry.first, embedder_url,
1341 CONTENT_SETTINGS_TYPE_MIDI_SYSEX, 1335 CONTENT_SETTINGS_TYPE_MIDI_SYSEX,
1342 std::string(), CONTENT_SETTING_DEFAULT); 1336 std::string(), CONTENT_SETTING_DEFAULT);
1343 } 1337 }
1344 } 1338 }
1345 1339
1340 // ContentSettingDownloadsBubbleModel ------------------------------------------
1341
1342 ContentSettingDownloadsBubbleModel::ContentSettingDownloadsBubbleModel(
1343 Delegate* delegate,
1344 WebContents* web_contents,
1345 Profile* profile)
1346 : ContentSettingBubbleModel(delegate, web_contents, profile) {
1347 SetTitle();
1348 SetManageText();
1349 SetRadioGroup();
1350 }
1351
1352 ContentSettingDownloadsBubbleModel::~ContentSettingDownloadsBubbleModel() {
1353 if (profile() &&
1354 selected_item_ != bubble_content().radio_group.default_item) {
1355 ContentSetting setting = selected_item_ == kAllowButtonIndex
1356 ? CONTENT_SETTING_ALLOW
1357 : CONTENT_SETTING_BLOCK;
1358 auto* map = HostContentSettingsMapFactory::GetForProfile(profile());
1359 map->SetNarrowestContentSetting(
1360 bubble_content().radio_group.url, bubble_content().radio_group.url,
1361 CONTENT_SETTINGS_TYPE_AUTOMATIC_DOWNLOADS, setting);
1362 }
1363 }
1364
1365 ContentSettingDownloadsBubbleModel*
1366 ContentSettingDownloadsBubbleModel::AsDownloadsBubbleModel() {
1367 return this;
1368 }
1369
1370 // Initialize the radio group by setting the appropriate labels for the
1371 // content type and setting the default value based on the content setting.
1372 void ContentSettingDownloadsBubbleModel::SetRadioGroup() {
1373 GURL url = web_contents()->GetURL();
1374 base::string16 display_host = url_formatter::FormatUrlForSecurityDisplay(url);
1375 if (display_host.empty())
1376 display_host = base::ASCIIToUTF16(url.spec());
1377
1378 RadioGroup radio_group;
1379 radio_group.url = url;
1380 switch (g_browser_process->download_request_limiter()->GetDownloadStatus(
1381 web_contents())) {
1382 case DownloadRequestLimiter::ALLOW_ALL_DOWNLOADS:
1383 radio_group.radio_items.push_back(
1384 l10n_util::GetStringUTF8(IDS_ALLOWED_DOWNLOAD_NO_ACTION));
1385 radio_group.radio_items.push_back(
1386 l10n_util::GetStringFUTF8(IDS_ALLOWED_DOWNLOAD_BLOCK, display_host));
1387 radio_group.default_item = kAllowButtonIndex;
1388 break;
1389 case DownloadRequestLimiter::DOWNLOADS_NOT_ALLOWED:
1390 radio_group.radio_items.push_back(l10n_util::GetStringFUTF8(
1391 IDS_BLOCKED_DOWNLOAD_UNBLOCK, display_host));
1392 radio_group.radio_items.push_back(
1393 l10n_util::GetStringUTF8(IDS_BLOCKED_DOWNLOAD_NO_ACTION));
1394 radio_group.default_item = 1;
1395 break;
1396 default:
1397 NOTREACHED();
1398 return;
1399 }
1400 set_radio_group(radio_group);
1401 selected_item_ = radio_group.default_item;
1402
1403 SettingInfo info;
1404 HostContentSettingsMap* map =
1405 HostContentSettingsMapFactory::GetForProfile(profile());
1406 map->GetWebsiteSetting(url, url, CONTENT_SETTINGS_TYPE_AUTOMATIC_DOWNLOADS,
1407 std::string(), &info);
1408
1409 // Prevent creation of content settings for illegal urls like about:blank
1410 bool is_valid = map->CanSetNarrowestContentSetting(
1411 url, url, CONTENT_SETTINGS_TYPE_AUTOMATIC_DOWNLOADS);
1412
1413 set_radio_group_enabled(is_valid && info.source == SETTING_SOURCE_USER);
1414 }
1415
1416 void ContentSettingDownloadsBubbleModel::OnRadioClicked(int radio_index) {
1417 selected_item_ = radio_index;
1418 }
1419
1420 void ContentSettingDownloadsBubbleModel::SetTitle() {
1421 if (!web_contents())
1422 return;
1423 switch (g_browser_process->download_request_limiter()->GetDownloadStatus(
1424 web_contents())) {
1425 case DownloadRequestLimiter::ALLOW_ALL_DOWNLOADS:
1426 set_title(l10n_util::GetStringUTF16(IDS_ALLOWED_DOWNLOAD_TITLE));
1427 return;
1428 case DownloadRequestLimiter::DOWNLOADS_NOT_ALLOWED:
1429 set_title(l10n_util::GetStringUTF16(IDS_BLOCKED_DOWNLOAD_TITLE));
1430 return;
1431 default:
1432 // No title otherwise.
1433 return;
1434 }
1435 }
1436
1437 void ContentSettingDownloadsBubbleModel::SetManageText() {
1438 set_manage_text(l10n_util::GetStringUTF8(IDS_BLOCKED_DOWNLOADS_LINK));
1439 }
1440
1441 void ContentSettingDownloadsBubbleModel::OnManageLinkClicked() {
1442 if (delegate())
1443 delegate()->ShowContentSettingsPage(
1444 CONTENT_SETTINGS_TYPE_AUTOMATIC_DOWNLOADS);
1445 }
1446
1346 // ContentSettingBubbleModel --------------------------------------------------- 1447 // ContentSettingBubbleModel ---------------------------------------------------
1347 1448
1348 // static 1449 // static
1349 ContentSettingBubbleModel* 1450 ContentSettingBubbleModel*
1350 ContentSettingBubbleModel::CreateContentSettingBubbleModel( 1451 ContentSettingBubbleModel::CreateContentSettingBubbleModel(
1351 Delegate* delegate, 1452 Delegate* delegate,
1352 WebContents* web_contents, 1453 WebContents* web_contents,
1353 Profile* profile, 1454 Profile* profile,
1354 ContentSettingsType content_type) { 1455 ContentSettingsType content_type) {
1355 if (content_type == CONTENT_SETTINGS_TYPE_COOKIES) { 1456 if (content_type == CONTENT_SETTINGS_TYPE_COOKIES) {
(...skipping 19 matching lines...) Expand all
1375 ProtocolHandlerRegistryFactory::GetForBrowserContext(profile); 1476 ProtocolHandlerRegistryFactory::GetForBrowserContext(profile);
1376 return new ContentSettingRPHBubbleModel(delegate, web_contents, profile, 1477 return new ContentSettingRPHBubbleModel(delegate, web_contents, profile,
1377 registry); 1478 registry);
1378 } 1479 }
1379 if (content_type == CONTENT_SETTINGS_TYPE_MIDI_SYSEX) { 1480 if (content_type == CONTENT_SETTINGS_TYPE_MIDI_SYSEX) {
1380 return new ContentSettingMidiSysExBubbleModel(delegate, web_contents, 1481 return new ContentSettingMidiSysExBubbleModel(delegate, web_contents,
1381 profile); 1482 profile);
1382 } 1483 }
1383 if (content_type == CONTENT_SETTINGS_TYPE_IMAGES || 1484 if (content_type == CONTENT_SETTINGS_TYPE_IMAGES ||
1384 content_type == CONTENT_SETTINGS_TYPE_JAVASCRIPT || 1485 content_type == CONTENT_SETTINGS_TYPE_JAVASCRIPT ||
1385 content_type == CONTENT_SETTINGS_TYPE_PPAPI_BROKER || 1486 content_type == CONTENT_SETTINGS_TYPE_PPAPI_BROKER) {
1386 content_type == CONTENT_SETTINGS_TYPE_AUTOMATIC_DOWNLOADS) {
1387 return new ContentSettingSingleRadioGroup(delegate, web_contents, profile, 1487 return new ContentSettingSingleRadioGroup(delegate, web_contents, profile,
1388 content_type); 1488 content_type);
1389 } 1489 }
1490 if (content_type == CONTENT_SETTINGS_TYPE_AUTOMATIC_DOWNLOADS) {
1491 return new ContentSettingDownloadsBubbleModel(delegate, web_contents,
1492 profile);
1493 }
1390 NOTREACHED() << "No bubble for the content type " << content_type << "."; 1494 NOTREACHED() << "No bubble for the content type " << content_type << ".";
1391 return nullptr; 1495 return nullptr;
1392 } 1496 }
1393 1497
1394 ContentSettingBubbleModel::ContentSettingBubbleModel(Delegate* delegate, 1498 ContentSettingBubbleModel::ContentSettingBubbleModel(Delegate* delegate,
1395 WebContents* web_contents, 1499 WebContents* web_contents,
1396 Profile* profile) 1500 Profile* profile)
1397 : web_contents_(web_contents), 1501 : web_contents_(web_contents),
1398 profile_(profile), 1502 profile_(profile),
1399 delegate_(delegate), 1503 delegate_(delegate),
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
1456 ContentSettingMediaStreamBubbleModel* 1560 ContentSettingMediaStreamBubbleModel*
1457 ContentSettingBubbleModel::AsMediaStreamBubbleModel() { 1561 ContentSettingBubbleModel::AsMediaStreamBubbleModel() {
1458 // In general, bubble models might not inherit from the media bubble model. 1562 // In general, bubble models might not inherit from the media bubble model.
1459 return nullptr; 1563 return nullptr;
1460 } 1564 }
1461 1565
1462 ContentSettingSubresourceFilterBubbleModel* 1566 ContentSettingSubresourceFilterBubbleModel*
1463 ContentSettingBubbleModel::AsSubresourceFilterBubbleModel() { 1567 ContentSettingBubbleModel::AsSubresourceFilterBubbleModel() {
1464 return nullptr; 1568 return nullptr;
1465 } 1569 }
1570
1571 ContentSettingDownloadsBubbleModel*
1572 ContentSettingBubbleModel::AsDownloadsBubbleModel() {
1573 return nullptr;
1574 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698