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/prefs/pref_service.h" | 8 #include "base/prefs/pref_service.h" |
9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
10 #include "chrome/browser/chrome_notification_types.h" | 10 #include "chrome/browser/chrome_notification_types.h" |
(...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
354 // default) we indicate the blocked state in the UI and allow the user to | 354 // default) we indicate the blocked state in the UI and allow the user to |
355 // whitelist. | 355 // whitelist. |
356 radio_group.default_item = 1; | 356 radio_group.default_item = 1; |
357 } else if (setting == CONTENT_SETTING_ALLOW) { | 357 } else if (setting == CONTENT_SETTING_ALLOW) { |
358 radio_group.default_item = kAllowButtonIndex; | 358 radio_group.default_item = kAllowButtonIndex; |
359 // |block_setting_| is already set to |CONTENT_SETTING_BLOCK|. | 359 // |block_setting_| is already set to |CONTENT_SETTING_BLOCK|. |
360 } else { | 360 } else { |
361 radio_group.default_item = 1; | 361 radio_group.default_item = 1; |
362 block_setting_ = setting; | 362 block_setting_ = setting; |
363 } | 363 } |
364 | |
365 set_managed_setting(setting_source != SETTING_SOURCE_USER); | |
364 if (setting_source != SETTING_SOURCE_USER) { | 366 if (setting_source != SETTING_SOURCE_USER) { |
365 set_radio_group_enabled(false); | 367 set_radio_group_enabled(false); |
366 } else { | 368 } else { |
367 set_radio_group_enabled(true); | 369 set_radio_group_enabled(true); |
368 } | 370 } |
369 selected_item_ = radio_group.default_item; | 371 selected_item_ = radio_group.default_item; |
370 set_radio_group(radio_group); | 372 set_radio_group(radio_group); |
371 } | 373 } |
372 | 374 |
373 void ContentSettingSingleRadioGroup::AddException(ContentSetting setting) { | 375 void ContentSettingSingleRadioGroup::AddException(ContentSetting setting) { |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
442 }; | 444 }; |
443 | 445 |
444 ContentSettingPluginBubbleModel::ContentSettingPluginBubbleModel( | 446 ContentSettingPluginBubbleModel::ContentSettingPluginBubbleModel( |
445 Delegate* delegate, | 447 Delegate* delegate, |
446 WebContents* web_contents, | 448 WebContents* web_contents, |
447 Profile* profile, | 449 Profile* profile, |
448 ContentSettingsType content_type) | 450 ContentSettingsType content_type) |
449 : ContentSettingSingleRadioGroup( | 451 : ContentSettingSingleRadioGroup( |
450 delegate, web_contents, profile, content_type) { | 452 delegate, web_contents, profile, content_type) { |
451 DCHECK_EQ(content_type, CONTENT_SETTINGS_TYPE_PLUGINS); | 453 DCHECK_EQ(content_type, CONTENT_SETTINGS_TYPE_PLUGINS); |
452 set_custom_link_enabled(web_contents && | 454 // Disable the "Run all plugins this time" link if the setting is managed and |
453 TabSpecificContentSettings::FromWebContents( | 455 // can't be controlled by the user or if the user already clicked on the link |
454 web_contents)->load_plugins_link_enabled()); | 456 // and ran all plugins. |
457 if (managed_setting()) { | |
458 set_custom_link_enabled(false); | |
Bernhard Bauer
2014/01/07 18:08:00
There is a way to combine these logical expression
markusheintz_
2014/01/07 18:42:22
Done.
| |
459 } else { | |
460 set_custom_link_enabled(web_contents && | |
461 TabSpecificContentSettings::FromWebContents( | |
462 web_contents)->load_plugins_link_enabled()); | |
463 } | |
455 } | 464 } |
456 | 465 |
457 ContentSettingPluginBubbleModel::~ContentSettingPluginBubbleModel() { | 466 ContentSettingPluginBubbleModel::~ContentSettingPluginBubbleModel() { |
458 if (settings_changed()) { | 467 if (settings_changed()) { |
459 // If the user elected to allow all plugins then run plugins at this time. | 468 // If the user elected to allow all plugins then run plugins at this time. |
460 if (selected_item() == kAllowButtonIndex) | 469 if (selected_item() == kAllowButtonIndex) |
461 OnCustomLinkClicked(); | 470 OnCustomLinkClicked(); |
462 } | 471 } |
463 } | 472 } |
464 | 473 |
(...skipping 791 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1256 return new ContentSettingSingleRadioGroup(delegate, web_contents, profile, | 1265 return new ContentSettingSingleRadioGroup(delegate, web_contents, profile, |
1257 content_type); | 1266 content_type); |
1258 } | 1267 } |
1259 | 1268 |
1260 ContentSettingBubbleModel::ContentSettingBubbleModel( | 1269 ContentSettingBubbleModel::ContentSettingBubbleModel( |
1261 WebContents* web_contents, | 1270 WebContents* web_contents, |
1262 Profile* profile, | 1271 Profile* profile, |
1263 ContentSettingsType content_type) | 1272 ContentSettingsType content_type) |
1264 : web_contents_(web_contents), | 1273 : web_contents_(web_contents), |
1265 profile_(profile), | 1274 profile_(profile), |
1266 content_type_(content_type) { | 1275 content_type_(content_type), |
1276 managed_setting_(false) { | |
1267 registrar_.Add(this, content::NOTIFICATION_WEB_CONTENTS_DESTROYED, | 1277 registrar_.Add(this, content::NOTIFICATION_WEB_CONTENTS_DESTROYED, |
1268 content::Source<WebContents>(web_contents)); | 1278 content::Source<WebContents>(web_contents)); |
1269 registrar_.Add(this, chrome::NOTIFICATION_PROFILE_DESTROYED, | 1279 registrar_.Add(this, chrome::NOTIFICATION_PROFILE_DESTROYED, |
1270 content::Source<Profile>(profile_)); | 1280 content::Source<Profile>(profile_)); |
1271 } | 1281 } |
1272 | 1282 |
1273 ContentSettingBubbleModel::~ContentSettingBubbleModel() { | 1283 ContentSettingBubbleModel::~ContentSettingBubbleModel() { |
1274 } | 1284 } |
1275 | 1285 |
1276 ContentSettingBubbleModel::RadioGroup::RadioGroup() : default_item(0) {} | 1286 ContentSettingBubbleModel::RadioGroup::RadioGroup() : default_item(0) {} |
(...skipping 22 matching lines...) Expand all Loading... | |
1299 if (type == content::NOTIFICATION_WEB_CONTENTS_DESTROYED) { | 1309 if (type == content::NOTIFICATION_WEB_CONTENTS_DESTROYED) { |
1300 DCHECK_EQ(web_contents_, | 1310 DCHECK_EQ(web_contents_, |
1301 content::Source<WebContents>(source).ptr()); | 1311 content::Source<WebContents>(source).ptr()); |
1302 web_contents_ = NULL; | 1312 web_contents_ = NULL; |
1303 } else { | 1313 } else { |
1304 DCHECK_EQ(chrome::NOTIFICATION_PROFILE_DESTROYED, type); | 1314 DCHECK_EQ(chrome::NOTIFICATION_PROFILE_DESTROYED, type); |
1305 DCHECK_EQ(profile_, content::Source<Profile>(source).ptr()); | 1315 DCHECK_EQ(profile_, content::Source<Profile>(source).ptr()); |
1306 profile_ = NULL; | 1316 profile_ = NULL; |
1307 } | 1317 } |
1308 } | 1318 } |
OLD | NEW |