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 12 matching lines...) Expand all Loading... |
23 virtual void UpdateFromWebContents(WebContents* web_contents) OVERRIDE; | 23 virtual void UpdateFromWebContents(WebContents* web_contents) OVERRIDE; |
24 }; | 24 }; |
25 | 25 |
26 class ContentSettingGeolocationImageModel : public ContentSettingImageModel { | 26 class ContentSettingGeolocationImageModel : public ContentSettingImageModel { |
27 public: | 27 public: |
28 ContentSettingGeolocationImageModel(); | 28 ContentSettingGeolocationImageModel(); |
29 | 29 |
30 virtual void UpdateFromWebContents(WebContents* web_contents) OVERRIDE; | 30 virtual void UpdateFromWebContents(WebContents* web_contents) OVERRIDE; |
31 }; | 31 }; |
32 | 32 |
33 // Image model for displaying media icons in the location bar. | |
34 class ContentSettingMediaImageModel : public ContentSettingImageModel { | |
35 public: | |
36 ContentSettingMediaImageModel(); | |
37 | |
38 virtual void UpdateFromWebContents(WebContents* web_contents) OVERRIDE; | |
39 }; | |
40 | |
41 class ContentSettingRPHImageModel : public ContentSettingImageModel { | 33 class ContentSettingRPHImageModel : public ContentSettingImageModel { |
42 public: | 34 public: |
43 ContentSettingRPHImageModel(); | 35 ContentSettingRPHImageModel(); |
44 | 36 |
45 virtual void UpdateFromWebContents(WebContents* web_contents) OVERRIDE; | 37 virtual void UpdateFromWebContents(WebContents* web_contents) OVERRIDE; |
46 }; | 38 }; |
47 | 39 |
48 class ContentSettingNotificationsImageModel : public ContentSettingImageModel { | 40 class ContentSettingNotificationsImageModel : public ContentSettingImageModel { |
49 public: | 41 public: |
50 ContentSettingNotificationsImageModel(); | 42 ContentSettingNotificationsImageModel(); |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
167 unsigned int tab_state_flags = 0; | 159 unsigned int tab_state_flags = 0; |
168 settings_state.GetDetailedInfo(NULL, &tab_state_flags); | 160 settings_state.GetDetailedInfo(NULL, &tab_state_flags); |
169 bool allowed = | 161 bool allowed = |
170 !!(tab_state_flags & GeolocationSettingsState::TABSTATE_HAS_ANY_ALLOWED); | 162 !!(tab_state_flags & GeolocationSettingsState::TABSTATE_HAS_ANY_ALLOWED); |
171 set_icon(allowed ? IDR_GEOLOCATION_ALLOWED_LOCATIONBAR_ICON : | 163 set_icon(allowed ? IDR_GEOLOCATION_ALLOWED_LOCATIONBAR_ICON : |
172 IDR_GEOLOCATION_DENIED_LOCATIONBAR_ICON); | 164 IDR_GEOLOCATION_DENIED_LOCATIONBAR_ICON); |
173 set_tooltip(l10n_util::GetStringUTF8(allowed ? | 165 set_tooltip(l10n_util::GetStringUTF8(allowed ? |
174 IDS_GEOLOCATION_ALLOWED_TOOLTIP : IDS_GEOLOCATION_BLOCKED_TOOLTIP)); | 166 IDS_GEOLOCATION_ALLOWED_TOOLTIP : IDS_GEOLOCATION_BLOCKED_TOOLTIP)); |
175 } | 167 } |
176 | 168 |
177 ContentSettingMediaImageModel::ContentSettingMediaImageModel() | |
178 : ContentSettingImageModel(CONTENT_SETTINGS_TYPE_MEDIASTREAM) { | |
179 } | |
180 | |
181 void ContentSettingMediaImageModel::UpdateFromWebContents( | |
182 WebContents* web_contents) { | |
183 set_visible(false); | |
184 if (!web_contents) | |
185 return; | |
186 | |
187 TabSpecificContentSettings* content_settings = | |
188 TabSpecificContentSettings::FromWebContents(web_contents); | |
189 if (!content_settings) | |
190 return; | |
191 | |
192 bool blocked = | |
193 content_settings->IsContentBlocked(CONTENT_SETTINGS_TYPE_MEDIASTREAM); | |
194 if (!blocked && | |
195 !content_settings->IsContentAccessed(get_content_settings_type())) | |
196 return; | |
197 | |
198 set_tooltip( | |
199 l10n_util::GetStringUTF8(blocked ? | |
200 IDS_MEDIASTREAM_BLOCKED_TOOLTIP : IDS_MEDIASTREAM_ALLOWED_TOOLTIP)); | |
201 set_icon(blocked ? IDR_BLOCKED_MEDIA : IDR_ASK_MEDIA); | |
202 set_visible(true); | |
203 } | |
204 | |
205 ContentSettingRPHImageModel::ContentSettingRPHImageModel() | 169 ContentSettingRPHImageModel::ContentSettingRPHImageModel() |
206 : ContentSettingImageModel( | 170 : ContentSettingImageModel( |
207 CONTENT_SETTINGS_TYPE_PROTOCOL_HANDLERS) { | 171 CONTENT_SETTINGS_TYPE_PROTOCOL_HANDLERS) { |
208 set_icon(IDR_REGISTER_PROTOCOL_HANDLER_LOCATIONBAR_ICON); | 172 set_icon(IDR_REGISTER_PROTOCOL_HANDLER_LOCATIONBAR_ICON); |
209 set_tooltip(l10n_util::GetStringUTF8(IDS_REGISTER_PROTOCOL_HANDLER_TOOLTIP)); | 173 set_tooltip(l10n_util::GetStringUTF8(IDS_REGISTER_PROTOCOL_HANDLER_TOOLTIP)); |
210 } | 174 } |
211 | 175 |
212 void ContentSettingRPHImageModel::UpdateFromWebContents( | 176 void ContentSettingRPHImageModel::UpdateFromWebContents( |
213 WebContents* web_contents) { | 177 WebContents* web_contents) { |
214 set_visible(false); | 178 set_visible(false); |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
247 ContentSettingImageModel* | 211 ContentSettingImageModel* |
248 ContentSettingImageModel::CreateContentSettingImageModel( | 212 ContentSettingImageModel::CreateContentSettingImageModel( |
249 ContentSettingsType content_settings_type) { | 213 ContentSettingsType content_settings_type) { |
250 switch (content_settings_type) { | 214 switch (content_settings_type) { |
251 case CONTENT_SETTINGS_TYPE_GEOLOCATION: | 215 case CONTENT_SETTINGS_TYPE_GEOLOCATION: |
252 return new ContentSettingGeolocationImageModel(); | 216 return new ContentSettingGeolocationImageModel(); |
253 case CONTENT_SETTINGS_TYPE_NOTIFICATIONS: | 217 case CONTENT_SETTINGS_TYPE_NOTIFICATIONS: |
254 return new ContentSettingNotificationsImageModel(); | 218 return new ContentSettingNotificationsImageModel(); |
255 case CONTENT_SETTINGS_TYPE_PROTOCOL_HANDLERS: | 219 case CONTENT_SETTINGS_TYPE_PROTOCOL_HANDLERS: |
256 return new ContentSettingRPHImageModel(); | 220 return new ContentSettingRPHImageModel(); |
257 case CONTENT_SETTINGS_TYPE_MEDIASTREAM: | |
258 return new ContentSettingMediaImageModel(); | |
259 default: | 221 default: |
260 return new ContentSettingBlockedImageModel(content_settings_type); | 222 return new ContentSettingBlockedImageModel(content_settings_type); |
261 } | 223 } |
262 } | 224 } |
OLD | NEW |