summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-02-16 23:04:48 +0000
committerpkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-02-16 23:04:48 +0000
commit187b80de1ac0f1ce32985ea268ff737eb614c153 (patch)
tree11de55d6421594ea6b83796d1acf350186dc45cc
parentae4fb919ec10995df58265160bf2d0775874b2bc (diff)
downloadchromium_src-187b80de1ac0f1ce32985ea268ff737eb614c153.zip
chromium_src-187b80de1ac0f1ce32985ea268ff737eb614c153.tar.gz
chromium_src-187b80de1ac0f1ce32985ea268ff737eb614c153.tar.bz2
Cleanup: shorten.
BUG=none TEST=none Review URL: http://codereview.chromium.org/6531001 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@75199 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/content_setting_image_model.cc73
1 files changed, 31 insertions, 42 deletions
diff --git a/chrome/browser/content_setting_image_model.cc b/chrome/browser/content_setting_image_model.cc
index e67f721..d533ec2 100644
--- a/chrome/browser/content_setting_image_model.cc
+++ b/chrome/browser/content_setting_image_model.cc
@@ -98,39 +98,33 @@ ContentSettingBlockedImageModel::ContentSettingBlockedImageModel(
void ContentSettingBlockedImageModel::UpdateFromTabContents(
TabContents* tab_contents) {
- TabSpecificContentSettings* content_settings = tab_contents ?
- tab_contents->GetTabSpecificContentSettings() : NULL;
- const int* icon_ids;
- const int* tooltip_ids;
- const int* explanatory_string_ids;
-
- if (!content_settings) {
- set_visible(false);
+ set_visible(false);
+ if (!tab_contents)
return;
- }
- if (content_settings->IsContentBlocked(get_content_settings_type())) {
- icon_ids = kBlockedIconIDs;
- tooltip_ids = kBlockedTooltipIDs;
- explanatory_string_ids = kBlockedExplanatoryTextIDs;
- } else if (tab_contents->profile()->GetHostContentSettingsMap()->
- GetDefaultContentSetting(get_content_settings_type()) ==
- CONTENT_SETTING_BLOCK &&
- content_settings->IsContentAccessed(get_content_settings_type())) {
- // If a content type is blocked by default and was accessed, display the
- // accessed icon.
+
+ const int* icon_ids = kBlockedIconIDs;
+ const int* tooltip_ids = kBlockedTooltipIDs;
+ const int* explanatory_string_ids = kBlockedExplanatoryTextIDs;
+ // If a content type is blocked by default and was accessed, display the
+ // accessed icon.
+ TabSpecificContentSettings* content_settings =
+ tab_contents->GetTabSpecificContentSettings();
+ if (!content_settings->IsContentBlocked(get_content_settings_type())) {
+ if (!content_settings->IsContentAccessed(get_content_settings_type()) ||
+ (tab_contents->profile()->GetHostContentSettingsMap()->
+ GetDefaultContentSetting(get_content_settings_type()) !=
+ CONTENT_SETTING_BLOCK))
+ return;
icon_ids = kAccessedIconIDs;
tooltip_ids = kAccessedTooltipIDs;
explanatory_string_ids = kAccessedExplanatoryTextIDs;
- } else {
- set_visible(false);
- return;
}
+ set_visible(true);
set_icon(icon_ids[get_content_settings_type()]);
set_explanatory_string_id(
explanatory_string_ids[get_content_settings_type()]);
set_tooltip(
l10n_util::GetStringUTF8(tooltip_ids[get_content_settings_type()]));
- set_visible(true);
}
ContentSettingGeolocationImageModel::ContentSettingGeolocationImageModel()
@@ -139,30 +133,25 @@ ContentSettingGeolocationImageModel::ContentSettingGeolocationImageModel()
void ContentSettingGeolocationImageModel::UpdateFromTabContents(
TabContents* tab_contents) {
- if (!tab_contents) {
- set_visible(false);
+ set_visible(false);
+ if (!tab_contents)
return;
- }
- TabSpecificContentSettings* content_settings =
- tab_contents->GetTabSpecificContentSettings();
- const GeolocationSettingsState& settings_state =
- content_settings->geolocation_settings_state();
- if (settings_state.state_map().empty()) {
- set_visible(false);
+ const GeolocationSettingsState& settings_state = tab_contents->
+ GetTabSpecificContentSettings()->geolocation_settings_state();
+ if (settings_state.state_map().empty())
return;
- }
set_visible(true);
- unsigned int tab_state_flags = 0;
- settings_state.GetDetailedInfo(NULL, &tab_state_flags);
+
// If any embedded site has access the allowed icon takes priority over the
// blocked icon.
- if (tab_state_flags & GeolocationSettingsState::TABSTATE_HAS_ANY_ALLOWED) {
- set_icon(IDR_GEOLOCATION_ALLOWED_LOCATIONBAR_ICON);
- set_tooltip(l10n_util::GetStringUTF8(IDS_GEOLOCATION_ALLOWED_TOOLTIP));
- return;
- }
- set_icon(IDR_GEOLOCATION_DENIED_LOCATIONBAR_ICON);
- set_tooltip(l10n_util::GetStringUTF8(IDS_GEOLOCATION_BLOCKED_TOOLTIP));
+ unsigned int tab_state_flags = 0;
+ settings_state.GetDetailedInfo(NULL, &tab_state_flags);
+ bool allowed =
+ !!(tab_state_flags & GeolocationSettingsState::TABSTATE_HAS_ANY_ALLOWED);
+ set_icon(allowed ? IDR_GEOLOCATION_ALLOWED_LOCATIONBAR_ICON :
+ IDR_GEOLOCATION_DENIED_LOCATIONBAR_ICON);
+ set_tooltip(l10n_util::GetStringUTF8(allowed ?
+ IDS_GEOLOCATION_ALLOWED_TOOLTIP : IDS_GEOLOCATION_BLOCKED_TOOLTIP));
}
ContentSettingNotificationsImageModel::ContentSettingNotificationsImageModel()