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 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
74 if (!web_contents) | 74 if (!web_contents) |
75 return; | 75 return; |
76 | 76 |
77 static const ContentSettingsTypeIdEntry kBlockedIconIDs[] = { | 77 static const ContentSettingsTypeIdEntry kBlockedIconIDs[] = { |
78 {CONTENT_SETTINGS_TYPE_COOKIES, IDR_BLOCKED_COOKIES}, | 78 {CONTENT_SETTINGS_TYPE_COOKIES, IDR_BLOCKED_COOKIES}, |
79 {CONTENT_SETTINGS_TYPE_IMAGES, IDR_BLOCKED_IMAGES}, | 79 {CONTENT_SETTINGS_TYPE_IMAGES, IDR_BLOCKED_IMAGES}, |
80 {CONTENT_SETTINGS_TYPE_JAVASCRIPT, IDR_BLOCKED_JAVASCRIPT}, | 80 {CONTENT_SETTINGS_TYPE_JAVASCRIPT, IDR_BLOCKED_JAVASCRIPT}, |
81 {CONTENT_SETTINGS_TYPE_PLUGINS, IDR_BLOCKED_PLUGINS}, | 81 {CONTENT_SETTINGS_TYPE_PLUGINS, IDR_BLOCKED_PLUGINS}, |
82 {CONTENT_SETTINGS_TYPE_POPUPS, IDR_BLOCKED_POPUPS}, | 82 {CONTENT_SETTINGS_TYPE_POPUPS, IDR_BLOCKED_POPUPS}, |
83 {CONTENT_SETTINGS_TYPE_MIXEDSCRIPT, IDR_BLOCKED_MIXED_CONTENT}, | 83 {CONTENT_SETTINGS_TYPE_MIXEDSCRIPT, IDR_BLOCKED_MIXED_CONTENT}, |
84 {CONTENT_SETTINGS_TYPE_PPAPI_BROKER, IDR_BLOCKED_PPAPI_BROKER}, | |
84 }; | 85 }; |
85 static const ContentSettingsTypeIdEntry kBlockedTooltipIDs[] = { | 86 static const ContentSettingsTypeIdEntry kBlockedTooltipIDs[] = { |
86 {CONTENT_SETTINGS_TYPE_COOKIES, IDS_BLOCKED_COOKIES_TITLE}, | 87 {CONTENT_SETTINGS_TYPE_COOKIES, IDS_BLOCKED_COOKIES_TITLE}, |
87 {CONTENT_SETTINGS_TYPE_IMAGES, IDS_BLOCKED_IMAGES_TITLE}, | 88 {CONTENT_SETTINGS_TYPE_IMAGES, IDS_BLOCKED_IMAGES_TITLE}, |
88 {CONTENT_SETTINGS_TYPE_JAVASCRIPT, IDS_BLOCKED_JAVASCRIPT_TITLE}, | 89 {CONTENT_SETTINGS_TYPE_JAVASCRIPT, IDS_BLOCKED_JAVASCRIPT_TITLE}, |
89 {CONTENT_SETTINGS_TYPE_PLUGINS, IDS_BLOCKED_PLUGINS_MESSAGE}, | 90 {CONTENT_SETTINGS_TYPE_PLUGINS, IDS_BLOCKED_PLUGINS_MESSAGE}, |
90 {CONTENT_SETTINGS_TYPE_POPUPS, IDS_BLOCKED_POPUPS_TOOLTIP}, | 91 {CONTENT_SETTINGS_TYPE_POPUPS, IDS_BLOCKED_POPUPS_TOOLTIP}, |
91 {CONTENT_SETTINGS_TYPE_MIXEDSCRIPT, | 92 {CONTENT_SETTINGS_TYPE_MIXEDSCRIPT, |
92 IDS_BLOCKED_DISPLAYING_INSECURE_CONTENT}, | 93 IDS_BLOCKED_DISPLAYING_INSECURE_CONTENT}, |
94 {CONTENT_SETTINGS_TYPE_PPAPI_BROKER, IDS_BLOCKED_PPAPI_BROKER_TITLE}, | |
93 }; | 95 }; |
94 static const ContentSettingsTypeIdEntry kBlockedExplanatoryTextIDs[] = { | 96 static const ContentSettingsTypeIdEntry kBlockedExplanatoryTextIDs[] = { |
95 {CONTENT_SETTINGS_TYPE_POPUPS, IDS_BLOCKED_POPUPS_EXPLANATORY_TEXT}, | 97 {CONTENT_SETTINGS_TYPE_POPUPS, IDS_BLOCKED_POPUPS_EXPLANATORY_TEXT}, |
96 }; | 98 }; |
97 | 99 |
98 ContentSettingsType type = get_content_settings_type(); | 100 ContentSettingsType type = get_content_settings_type(); |
99 int icon_id = GetIdForContentType( | 101 int icon_id = GetIdForContentType( |
100 kBlockedIconIDs, arraysize(kBlockedIconIDs), type); | 102 kBlockedIconIDs, arraysize(kBlockedIconIDs), type); |
101 int tooltip_id = GetIdForContentType( | 103 int tooltip_id = GetIdForContentType( |
102 kBlockedTooltipIDs, arraysize(kBlockedTooltipIDs), type); | 104 kBlockedTooltipIDs, arraysize(kBlockedTooltipIDs), type); |
103 int explanation_id = GetIdForContentType( | 105 int explanation_id = GetIdForContentType( |
104 kBlockedExplanatoryTextIDs, arraysize(kBlockedExplanatoryTextIDs), type); | 106 kBlockedExplanatoryTextIDs, arraysize(kBlockedExplanatoryTextIDs), type); |
105 | 107 |
106 // If a content type is blocked by default and was accessed, display the | 108 // If a content type is blocked by default and was accessed, display the |
107 // accessed icon. | 109 // accessed icon. |
108 TabSpecificContentSettings* content_settings = | 110 TabSpecificContentSettings* content_settings = |
109 TabSpecificContentSettings::FromWebContents(web_contents); | 111 TabSpecificContentSettings::FromWebContents(web_contents); |
110 if (!content_settings) | 112 if (!content_settings) |
111 return; | 113 return; |
112 Profile* profile = | 114 Profile* profile = |
113 Profile::FromBrowserContext(web_contents->GetBrowserContext()); | 115 Profile::FromBrowserContext(web_contents->GetBrowserContext()); |
114 if (!content_settings->IsContentBlocked(get_content_settings_type())) { | 116 if (!content_settings->IsContentBlocked(get_content_settings_type())) { |
115 if (!content_settings->IsContentAccessed(get_content_settings_type()) || | 117 if (!content_settings->IsContentAccessed(get_content_settings_type())) |
118 return; | |
119 | |
120 // For cookies, only show the accessed bubble if cookies are blocked by | |
markusheintz_
2012/12/17 16:03:59
This Change seems not to be related to the issue.
Bernhard Bauer
2012/12/17 16:41:31
This behavior (for cookies at least) has been in C
| |
121 // default. | |
122 if (get_content_settings_type() == CONTENT_SETTINGS_TYPE_COOKIES && | |
116 (profile->GetHostContentSettingsMap()-> | 123 (profile->GetHostContentSettingsMap()-> |
117 GetDefaultContentSetting(get_content_settings_type(), NULL) != | 124 GetDefaultContentSetting(CONTENT_SETTINGS_TYPE_COOKIES, NULL) != |
118 CONTENT_SETTING_BLOCK)) | 125 CONTENT_SETTING_BLOCK)) |
119 return; | 126 return; |
127 | |
120 static const ContentSettingsTypeIdEntry kAccessedIconIDs[] = { | 128 static const ContentSettingsTypeIdEntry kAccessedIconIDs[] = { |
121 {CONTENT_SETTINGS_TYPE_COOKIES, IDR_ACCESSED_COOKIES}, | 129 {CONTENT_SETTINGS_TYPE_COOKIES, IDR_ACCESSED_COOKIES}, |
130 {CONTENT_SETTINGS_TYPE_PPAPI_BROKER, IDR_BLOCKED_PPAPI_BROKER}, | |
122 }; | 131 }; |
123 static const ContentSettingsTypeIdEntry kAccessedTooltipIDs[] = { | 132 static const ContentSettingsTypeIdEntry kAccessedTooltipIDs[] = { |
124 {CONTENT_SETTINGS_TYPE_COOKIES, IDS_ACCESSED_COOKIES_TITLE}, | 133 {CONTENT_SETTINGS_TYPE_COOKIES, IDS_ACCESSED_COOKIES_TITLE}, |
134 {CONTENT_SETTINGS_TYPE_PPAPI_BROKER, IDS_ALLOWED_PPAPI_BROKER_TITLE}, | |
125 }; | 135 }; |
126 icon_id = GetIdForContentType( | 136 icon_id = GetIdForContentType( |
127 kAccessedIconIDs, arraysize(kAccessedIconIDs), type); | 137 kAccessedIconIDs, arraysize(kAccessedIconIDs), type); |
128 tooltip_id = GetIdForContentType( | 138 tooltip_id = GetIdForContentType( |
129 kAccessedTooltipIDs, arraysize(kAccessedTooltipIDs), type); | 139 kAccessedTooltipIDs, arraysize(kAccessedTooltipIDs), type); |
130 explanation_id = 0; | 140 explanation_id = 0; |
131 } | 141 } |
132 set_visible(true); | 142 set_visible(true); |
143 DCHECK(icon_id); | |
133 set_icon(icon_id); | 144 set_icon(icon_id); |
134 set_explanatory_string_id(explanation_id); | 145 set_explanatory_string_id(explanation_id); |
146 DCHECK(tooltip_id); | |
135 set_tooltip(l10n_util::GetStringUTF8(tooltip_id)); | 147 set_tooltip(l10n_util::GetStringUTF8(tooltip_id)); |
136 } | 148 } |
137 | 149 |
138 ContentSettingGeolocationImageModel::ContentSettingGeolocationImageModel() | 150 ContentSettingGeolocationImageModel::ContentSettingGeolocationImageModel() |
139 : ContentSettingImageModel(CONTENT_SETTINGS_TYPE_GEOLOCATION) { | 151 : ContentSettingImageModel(CONTENT_SETTINGS_TYPE_GEOLOCATION) { |
140 } | 152 } |
141 | 153 |
142 void ContentSettingGeolocationImageModel::UpdateFromWebContents( | 154 void ContentSettingGeolocationImageModel::UpdateFromWebContents( |
143 WebContents* web_contents) { | 155 WebContents* web_contents) { |
144 set_visible(false); | 156 set_visible(false); |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
215 case CONTENT_SETTINGS_TYPE_GEOLOCATION: | 227 case CONTENT_SETTINGS_TYPE_GEOLOCATION: |
216 return new ContentSettingGeolocationImageModel(); | 228 return new ContentSettingGeolocationImageModel(); |
217 case CONTENT_SETTINGS_TYPE_NOTIFICATIONS: | 229 case CONTENT_SETTINGS_TYPE_NOTIFICATIONS: |
218 return new ContentSettingNotificationsImageModel(); | 230 return new ContentSettingNotificationsImageModel(); |
219 case CONTENT_SETTINGS_TYPE_PROTOCOL_HANDLERS: | 231 case CONTENT_SETTINGS_TYPE_PROTOCOL_HANDLERS: |
220 return new ContentSettingRPHImageModel(); | 232 return new ContentSettingRPHImageModel(); |
221 default: | 233 default: |
222 return new ContentSettingBlockedImageModel(content_settings_type); | 234 return new ContentSettingBlockedImageModel(content_settings_type); |
223 } | 235 } |
224 } | 236 } |
OLD | NEW |