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 | |
33 class ContentSettingRPHImageModel : public ContentSettingImageModel { | 41 class ContentSettingRPHImageModel : public ContentSettingImageModel { |
34 public: | 42 public: |
35 ContentSettingRPHImageModel(); | 43 ContentSettingRPHImageModel(); |
36 | 44 |
37 virtual void UpdateFromWebContents(WebContents* web_contents) OVERRIDE; | 45 virtual void UpdateFromWebContents(WebContents* web_contents) OVERRIDE; |
38 }; | 46 }; |
39 | 47 |
40 class ContentSettingNotificationsImageModel : public ContentSettingImageModel { | 48 class ContentSettingNotificationsImageModel : public ContentSettingImageModel { |
41 public: | 49 public: |
42 ContentSettingNotificationsImageModel(); | 50 ContentSettingNotificationsImageModel(); |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
159 unsigned int tab_state_flags = 0; | 167 unsigned int tab_state_flags = 0; |
160 settings_state.GetDetailedInfo(NULL, &tab_state_flags); | 168 settings_state.GetDetailedInfo(NULL, &tab_state_flags); |
161 bool allowed = | 169 bool allowed = |
162 !!(tab_state_flags & GeolocationSettingsState::TABSTATE_HAS_ANY_ALLOWED); | 170 !!(tab_state_flags & GeolocationSettingsState::TABSTATE_HAS_ANY_ALLOWED); |
163 set_icon(allowed ? IDR_GEOLOCATION_ALLOWED_LOCATIONBAR_ICON : | 171 set_icon(allowed ? IDR_GEOLOCATION_ALLOWED_LOCATIONBAR_ICON : |
164 IDR_GEOLOCATION_DENIED_LOCATIONBAR_ICON); | 172 IDR_GEOLOCATION_DENIED_LOCATIONBAR_ICON); |
165 set_tooltip(l10n_util::GetStringUTF8(allowed ? | 173 set_tooltip(l10n_util::GetStringUTF8(allowed ? |
166 IDS_GEOLOCATION_ALLOWED_TOOLTIP : IDS_GEOLOCATION_BLOCKED_TOOLTIP)); | 174 IDS_GEOLOCATION_ALLOWED_TOOLTIP : IDS_GEOLOCATION_BLOCKED_TOOLTIP)); |
167 } | 175 } |
168 | 176 |
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 ? IDS_MEDIASTREAM_BLOCKED_TOOLTIP | |
200 : IDS_MEDIASTREAM_ALLOWED_TOOLTIP)); | |
Peter Kasting
2013/01/27 22:36:16
Nit: Google style guide says wrap after operators,
markusheintz_
2013/01/28 10:06:47
Done.
| |
201 set_icon(blocked ? IDR_BLOCKED_MEDIA : IDR_ASK_MEDIA); | |
202 set_visible(true); | |
203 } | |
204 | |
169 ContentSettingRPHImageModel::ContentSettingRPHImageModel() | 205 ContentSettingRPHImageModel::ContentSettingRPHImageModel() |
170 : ContentSettingImageModel( | 206 : ContentSettingImageModel( |
171 CONTENT_SETTINGS_TYPE_PROTOCOL_HANDLERS) { | 207 CONTENT_SETTINGS_TYPE_PROTOCOL_HANDLERS) { |
172 set_icon(IDR_REGISTER_PROTOCOL_HANDLER_LOCATIONBAR_ICON); | 208 set_icon(IDR_REGISTER_PROTOCOL_HANDLER_LOCATIONBAR_ICON); |
173 set_tooltip(l10n_util::GetStringUTF8(IDS_REGISTER_PROTOCOL_HANDLER_TOOLTIP)); | 209 set_tooltip(l10n_util::GetStringUTF8(IDS_REGISTER_PROTOCOL_HANDLER_TOOLTIP)); |
174 } | 210 } |
175 | 211 |
176 void ContentSettingRPHImageModel::UpdateFromWebContents( | 212 void ContentSettingRPHImageModel::UpdateFromWebContents( |
177 WebContents* web_contents) { | 213 WebContents* web_contents) { |
178 set_visible(false); | 214 set_visible(false); |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
211 ContentSettingImageModel* | 247 ContentSettingImageModel* |
212 ContentSettingImageModel::CreateContentSettingImageModel( | 248 ContentSettingImageModel::CreateContentSettingImageModel( |
213 ContentSettingsType content_settings_type) { | 249 ContentSettingsType content_settings_type) { |
214 switch (content_settings_type) { | 250 switch (content_settings_type) { |
215 case CONTENT_SETTINGS_TYPE_GEOLOCATION: | 251 case CONTENT_SETTINGS_TYPE_GEOLOCATION: |
216 return new ContentSettingGeolocationImageModel(); | 252 return new ContentSettingGeolocationImageModel(); |
217 case CONTENT_SETTINGS_TYPE_NOTIFICATIONS: | 253 case CONTENT_SETTINGS_TYPE_NOTIFICATIONS: |
218 return new ContentSettingNotificationsImageModel(); | 254 return new ContentSettingNotificationsImageModel(); |
219 case CONTENT_SETTINGS_TYPE_PROTOCOL_HANDLERS: | 255 case CONTENT_SETTINGS_TYPE_PROTOCOL_HANDLERS: |
220 return new ContentSettingRPHImageModel(); | 256 return new ContentSettingRPHImageModel(); |
257 case CONTENT_SETTINGS_TYPE_MEDIASTREAM: | |
258 return new ContentSettingMediaImageModel(); | |
221 default: | 259 default: |
222 return new ContentSettingBlockedImageModel(content_settings_type); | 260 return new ContentSettingBlockedImageModel(content_settings_type); |
223 } | 261 } |
224 } | 262 } |
OLD | NEW |