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_image_model.h" | 5 #include "chrome/browser/ui/content_settings/content_setting_image_model.h" |
6 | 6 |
7 #include "chrome/browser/content_settings/host_content_settings_map.h" | 7 #include "chrome/browser/content_settings/host_content_settings_map.h" |
8 #include "chrome/browser/content_settings/tab_specific_content_settings.h" | 8 #include "chrome/browser/content_settings/tab_specific_content_settings.h" |
9 #include "chrome/browser/prerender/prerender_manager.h" | 9 #include "chrome/browser/prerender/prerender_manager.h" |
10 #include "chrome/browser/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
82 if (!web_contents) | 82 if (!web_contents) |
83 return; | 83 return; |
84 | 84 |
85 static const ContentSettingsTypeIdEntry kBlockedIconIDs[] = { | 85 static const ContentSettingsTypeIdEntry kBlockedIconIDs[] = { |
86 {CONTENT_SETTINGS_TYPE_COOKIES, IDR_BLOCKED_COOKIES}, | 86 {CONTENT_SETTINGS_TYPE_COOKIES, IDR_BLOCKED_COOKIES}, |
87 {CONTENT_SETTINGS_TYPE_IMAGES, IDR_BLOCKED_IMAGES}, | 87 {CONTENT_SETTINGS_TYPE_IMAGES, IDR_BLOCKED_IMAGES}, |
88 {CONTENT_SETTINGS_TYPE_JAVASCRIPT, IDR_BLOCKED_JAVASCRIPT}, | 88 {CONTENT_SETTINGS_TYPE_JAVASCRIPT, IDR_BLOCKED_JAVASCRIPT}, |
89 {CONTENT_SETTINGS_TYPE_PLUGINS, IDR_BLOCKED_PLUGINS}, | 89 {CONTENT_SETTINGS_TYPE_PLUGINS, IDR_BLOCKED_PLUGINS}, |
90 {CONTENT_SETTINGS_TYPE_POPUPS, IDR_BLOCKED_POPUPS}, | 90 {CONTENT_SETTINGS_TYPE_POPUPS, IDR_BLOCKED_POPUPS}, |
91 {CONTENT_SETTINGS_TYPE_MIXEDSCRIPT, IDR_BLOCKED_MIXED_CONTENT}, | 91 {CONTENT_SETTINGS_TYPE_MIXEDSCRIPT, IDR_BLOCKED_MIXED_CONTENT}, |
| 92 {CONTENT_SETTINGS_TYPE_PPAPI_BROKER, IDR_BLOCKED_PPAPI_BROKER}, |
92 }; | 93 }; |
93 static const ContentSettingsTypeIdEntry kBlockedTooltipIDs[] = { | 94 static const ContentSettingsTypeIdEntry kBlockedTooltipIDs[] = { |
94 {CONTENT_SETTINGS_TYPE_COOKIES, IDS_BLOCKED_COOKIES_TITLE}, | 95 {CONTENT_SETTINGS_TYPE_COOKIES, IDS_BLOCKED_COOKIES_TITLE}, |
95 {CONTENT_SETTINGS_TYPE_IMAGES, IDS_BLOCKED_IMAGES_TITLE}, | 96 {CONTENT_SETTINGS_TYPE_IMAGES, IDS_BLOCKED_IMAGES_TITLE}, |
96 {CONTENT_SETTINGS_TYPE_JAVASCRIPT, IDS_BLOCKED_JAVASCRIPT_TITLE}, | 97 {CONTENT_SETTINGS_TYPE_JAVASCRIPT, IDS_BLOCKED_JAVASCRIPT_TITLE}, |
97 {CONTENT_SETTINGS_TYPE_PLUGINS, IDS_BLOCKED_PLUGINS_MESSAGE}, | 98 {CONTENT_SETTINGS_TYPE_PLUGINS, IDS_BLOCKED_PLUGINS_MESSAGE}, |
98 {CONTENT_SETTINGS_TYPE_POPUPS, IDS_BLOCKED_POPUPS_TOOLTIP}, | 99 {CONTENT_SETTINGS_TYPE_POPUPS, IDS_BLOCKED_POPUPS_TOOLTIP}, |
99 {CONTENT_SETTINGS_TYPE_MIXEDSCRIPT, | 100 {CONTENT_SETTINGS_TYPE_MIXEDSCRIPT, |
100 IDS_BLOCKED_DISPLAYING_INSECURE_CONTENT}, | 101 IDS_BLOCKED_DISPLAYING_INSECURE_CONTENT}, |
| 102 {CONTENT_SETTINGS_TYPE_PPAPI_BROKER, IDS_BLOCKED_PPAPI_BROKER_TITLE}, |
101 }; | 103 }; |
102 static const ContentSettingsTypeIdEntry kBlockedExplanatoryTextIDs[] = { | 104 static const ContentSettingsTypeIdEntry kBlockedExplanatoryTextIDs[] = { |
103 {CONTENT_SETTINGS_TYPE_POPUPS, IDS_BLOCKED_POPUPS_EXPLANATORY_TEXT}, | 105 {CONTENT_SETTINGS_TYPE_POPUPS, IDS_BLOCKED_POPUPS_EXPLANATORY_TEXT}, |
104 }; | 106 }; |
105 | 107 |
106 ContentSettingsType type = get_content_settings_type(); | 108 ContentSettingsType type = get_content_settings_type(); |
107 int icon_id = GetIdForContentType( | 109 int icon_id = GetIdForContentType( |
108 kBlockedIconIDs, arraysize(kBlockedIconIDs), type); | 110 kBlockedIconIDs, arraysize(kBlockedIconIDs), type); |
109 int tooltip_id = GetIdForContentType( | 111 int tooltip_id = GetIdForContentType( |
110 kBlockedTooltipIDs, arraysize(kBlockedTooltipIDs), type); | 112 kBlockedTooltipIDs, arraysize(kBlockedTooltipIDs), type); |
111 int explanation_id = GetIdForContentType( | 113 int explanation_id = GetIdForContentType( |
112 kBlockedExplanatoryTextIDs, arraysize(kBlockedExplanatoryTextIDs), type); | 114 kBlockedExplanatoryTextIDs, arraysize(kBlockedExplanatoryTextIDs), type); |
113 | 115 |
114 // If a content type is blocked by default and was accessed, display the | 116 // If a content type is blocked by default and was accessed, display the |
115 // accessed icon. | 117 // accessed icon. |
116 TabSpecificContentSettings* content_settings = | 118 TabSpecificContentSettings* content_settings = |
117 TabSpecificContentSettings::FromWebContents(web_contents); | 119 TabSpecificContentSettings::FromWebContents(web_contents); |
118 if (!content_settings) | 120 if (!content_settings) |
119 return; | 121 return; |
120 Profile* profile = | 122 Profile* profile = |
121 Profile::FromBrowserContext(web_contents->GetBrowserContext()); | 123 Profile::FromBrowserContext(web_contents->GetBrowserContext()); |
122 if (!content_settings->IsContentBlocked(get_content_settings_type())) { | 124 if (!content_settings->IsContentBlocked(get_content_settings_type())) { |
123 if (!content_settings->IsContentAccessed(get_content_settings_type()) || | 125 if (!content_settings->IsContentAccessed(get_content_settings_type())) |
| 126 return; |
| 127 |
| 128 // For cookies, only show the accessed bubble if cookies are blocked by |
| 129 // default. |
| 130 if (get_content_settings_type() == CONTENT_SETTINGS_TYPE_COOKIES && |
124 (profile->GetHostContentSettingsMap()-> | 131 (profile->GetHostContentSettingsMap()-> |
125 GetDefaultContentSetting(get_content_settings_type(), NULL) != | 132 GetDefaultContentSetting(CONTENT_SETTINGS_TYPE_COOKIES, NULL) != |
126 CONTENT_SETTING_BLOCK)) | 133 CONTENT_SETTING_BLOCK)) |
127 return; | 134 return; |
| 135 |
128 static const ContentSettingsTypeIdEntry kAccessedIconIDs[] = { | 136 static const ContentSettingsTypeIdEntry kAccessedIconIDs[] = { |
129 {CONTENT_SETTINGS_TYPE_COOKIES, IDR_ACCESSED_COOKIES}, | 137 {CONTENT_SETTINGS_TYPE_COOKIES, IDR_ACCESSED_COOKIES}, |
| 138 {CONTENT_SETTINGS_TYPE_PPAPI_BROKER, IDR_BLOCKED_PPAPI_BROKER}, |
130 }; | 139 }; |
131 static const ContentSettingsTypeIdEntry kAccessedTooltipIDs[] = { | 140 static const ContentSettingsTypeIdEntry kAccessedTooltipIDs[] = { |
132 {CONTENT_SETTINGS_TYPE_COOKIES, IDS_ACCESSED_COOKIES_TITLE}, | 141 {CONTENT_SETTINGS_TYPE_COOKIES, IDS_ACCESSED_COOKIES_TITLE}, |
| 142 {CONTENT_SETTINGS_TYPE_PPAPI_BROKER, IDS_ALLOWED_PPAPI_BROKER_TITLE}, |
133 }; | 143 }; |
134 icon_id = GetIdForContentType( | 144 icon_id = GetIdForContentType( |
135 kAccessedIconIDs, arraysize(kAccessedIconIDs), type); | 145 kAccessedIconIDs, arraysize(kAccessedIconIDs), type); |
136 tooltip_id = GetIdForContentType( | 146 tooltip_id = GetIdForContentType( |
137 kAccessedTooltipIDs, arraysize(kAccessedTooltipIDs), type); | 147 kAccessedTooltipIDs, arraysize(kAccessedTooltipIDs), type); |
138 explanation_id = 0; | 148 explanation_id = 0; |
139 } | 149 } |
140 set_visible(true); | 150 set_visible(true); |
| 151 DCHECK(icon_id); |
141 set_icon(icon_id); | 152 set_icon(icon_id); |
142 set_explanatory_string_id(explanation_id); | 153 set_explanatory_string_id(explanation_id); |
| 154 DCHECK(tooltip_id); |
143 set_tooltip(l10n_util::GetStringUTF8(tooltip_id)); | 155 set_tooltip(l10n_util::GetStringUTF8(tooltip_id)); |
144 } | 156 } |
145 | 157 |
146 ContentSettingGeolocationImageModel::ContentSettingGeolocationImageModel() | 158 ContentSettingGeolocationImageModel::ContentSettingGeolocationImageModel() |
147 : ContentSettingImageModel(CONTENT_SETTINGS_TYPE_GEOLOCATION) { | 159 : ContentSettingImageModel(CONTENT_SETTINGS_TYPE_GEOLOCATION) { |
148 } | 160 } |
149 | 161 |
150 void ContentSettingGeolocationImageModel::UpdateFromWebContents( | 162 void ContentSettingGeolocationImageModel::UpdateFromWebContents( |
151 WebContents* web_contents) { | 163 WebContents* web_contents) { |
152 set_visible(false); | 164 set_visible(false); |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
253 case CONTENT_SETTINGS_TYPE_NOTIFICATIONS: | 265 case CONTENT_SETTINGS_TYPE_NOTIFICATIONS: |
254 return new ContentSettingNotificationsImageModel(); | 266 return new ContentSettingNotificationsImageModel(); |
255 case CONTENT_SETTINGS_TYPE_PROTOCOL_HANDLERS: | 267 case CONTENT_SETTINGS_TYPE_PROTOCOL_HANDLERS: |
256 return new ContentSettingRPHImageModel(); | 268 return new ContentSettingRPHImageModel(); |
257 case CONTENT_SETTINGS_TYPE_MEDIASTREAM: | 269 case CONTENT_SETTINGS_TYPE_MEDIASTREAM: |
258 return new ContentSettingMediaImageModel(); | 270 return new ContentSettingMediaImageModel(); |
259 default: | 271 default: |
260 return new ContentSettingBlockedImageModel(content_settings_type); | 272 return new ContentSettingBlockedImageModel(content_settings_type); |
261 } | 273 } |
262 } | 274 } |
OLD | NEW |