| 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 22 matching lines...) Expand all Loading... |
| 33 static const int kBlockedTooltipIDs[]; | 33 static const int kBlockedTooltipIDs[]; |
| 34 }; | 34 }; |
| 35 | 35 |
| 36 class ContentSettingGeolocationImageModel : public ContentSettingImageModel { | 36 class ContentSettingGeolocationImageModel : public ContentSettingImageModel { |
| 37 public: | 37 public: |
| 38 ContentSettingGeolocationImageModel(); | 38 ContentSettingGeolocationImageModel(); |
| 39 | 39 |
| 40 virtual void UpdateFromWebContents(WebContents* web_contents) OVERRIDE; | 40 virtual void UpdateFromWebContents(WebContents* web_contents) OVERRIDE; |
| 41 }; | 41 }; |
| 42 | 42 |
| 43 class ContentSettingRPHImageModel : public ContentSettingImageModel { |
| 44 public: |
| 45 ContentSettingRPHImageModel(); |
| 46 |
| 47 virtual void UpdateFromWebContents(WebContents* web_contents) OVERRIDE; |
| 48 }; |
| 49 |
| 43 class ContentSettingNotificationsImageModel : public ContentSettingImageModel { | 50 class ContentSettingNotificationsImageModel : public ContentSettingImageModel { |
| 44 public: | 51 public: |
| 45 ContentSettingNotificationsImageModel(); | 52 ContentSettingNotificationsImageModel(); |
| 46 | 53 |
| 47 virtual void UpdateFromWebContents(WebContents* web_contents) OVERRIDE; | 54 virtual void UpdateFromWebContents(WebContents* web_contents) OVERRIDE; |
| 48 }; | 55 }; |
| 49 | 56 |
| 50 const int ContentSettingBlockedImageModel::kBlockedIconIDs[] = { | 57 const int ContentSettingBlockedImageModel::kBlockedIconIDs[] = { |
| 51 IDR_BLOCKED_COOKIES, | 58 IDR_BLOCKED_COOKIES, |
| 52 IDR_BLOCKED_IMAGES, | 59 IDR_BLOCKED_IMAGES, |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 155 unsigned int tab_state_flags = 0; | 162 unsigned int tab_state_flags = 0; |
| 156 settings_state.GetDetailedInfo(NULL, &tab_state_flags); | 163 settings_state.GetDetailedInfo(NULL, &tab_state_flags); |
| 157 bool allowed = | 164 bool allowed = |
| 158 !!(tab_state_flags & GeolocationSettingsState::TABSTATE_HAS_ANY_ALLOWED); | 165 !!(tab_state_flags & GeolocationSettingsState::TABSTATE_HAS_ANY_ALLOWED); |
| 159 set_icon(allowed ? IDR_GEOLOCATION_ALLOWED_LOCATIONBAR_ICON : | 166 set_icon(allowed ? IDR_GEOLOCATION_ALLOWED_LOCATIONBAR_ICON : |
| 160 IDR_GEOLOCATION_DENIED_LOCATIONBAR_ICON); | 167 IDR_GEOLOCATION_DENIED_LOCATIONBAR_ICON); |
| 161 set_tooltip(l10n_util::GetStringUTF8(allowed ? | 168 set_tooltip(l10n_util::GetStringUTF8(allowed ? |
| 162 IDS_GEOLOCATION_ALLOWED_TOOLTIP : IDS_GEOLOCATION_BLOCKED_TOOLTIP)); | 169 IDS_GEOLOCATION_ALLOWED_TOOLTIP : IDS_GEOLOCATION_BLOCKED_TOOLTIP)); |
| 163 } | 170 } |
| 164 | 171 |
| 172 ContentSettingRPHImageModel::ContentSettingRPHImageModel() |
| 173 : ContentSettingImageModel( |
| 174 CONTENT_SETTINGS_TYPE_REGISTER_PROTOCOL_HANDLER) { |
| 175 } |
| 176 |
| 177 void ContentSettingRPHImageModel::UpdateFromWebContents( |
| 178 WebContents* web_contents) { |
| 179 set_visible(false); |
| 180 if (!web_contents) |
| 181 return; |
| 182 |
| 183 TabSpecificContentSettings* content_settings = |
| 184 TabContents::FromWebContents(web_contents)->content_settings(); |
| 185 if (content_settings->GetPendingProtocolHandler().IsEmpty()) |
| 186 return; |
| 187 |
| 188 set_visible(true); |
| 189 set_icon(IDR_REGISTER_PROTOCOL_HANDLER_LOCATIONBAR_ICON); |
| 190 |
| 191 set_tooltip(l10n_util::GetStringUTF8(IDS_REGISTER_PROTOCOL_HANDLER_TOOLTIP)); |
| 192 // Can also use IDS_BLOCKED_HANDLERS_TITLE if the above tooltip doesn't make |
| 193 // it for M21. |
| 194 } |
| 195 |
| 165 ContentSettingNotificationsImageModel::ContentSettingNotificationsImageModel() | 196 ContentSettingNotificationsImageModel::ContentSettingNotificationsImageModel() |
| 166 : ContentSettingImageModel(CONTENT_SETTINGS_TYPE_NOTIFICATIONS) { | 197 : ContentSettingImageModel(CONTENT_SETTINGS_TYPE_NOTIFICATIONS) { |
| 167 } | 198 } |
| 168 | 199 |
| 169 void ContentSettingNotificationsImageModel::UpdateFromWebContents( | 200 void ContentSettingNotificationsImageModel::UpdateFromWebContents( |
| 170 WebContents* web_contents) { | 201 WebContents* web_contents) { |
| 171 // Notifications do not have a bubble. | 202 // Notifications do not have a bubble. |
| 172 set_visible(false); | 203 set_visible(false); |
| 173 } | 204 } |
| 174 | 205 |
| 175 ContentSettingImageModel::ContentSettingImageModel( | 206 ContentSettingImageModel::ContentSettingImageModel( |
| 176 ContentSettingsType content_settings_type) | 207 ContentSettingsType content_settings_type) |
| 177 : content_settings_type_(content_settings_type), | 208 : content_settings_type_(content_settings_type), |
| 178 is_visible_(false), | 209 is_visible_(false), |
| 179 icon_(0), | 210 icon_(0), |
| 180 explanatory_string_id_(0) { | 211 explanatory_string_id_(0) { |
| 181 } | 212 } |
| 182 | 213 |
| 183 // static | 214 // static |
| 184 ContentSettingImageModel* | 215 ContentSettingImageModel* |
| 185 ContentSettingImageModel::CreateContentSettingImageModel( | 216 ContentSettingImageModel::CreateContentSettingImageModel( |
| 186 ContentSettingsType content_settings_type) { | 217 ContentSettingsType content_settings_type) { |
| 187 switch (content_settings_type) { | 218 switch (content_settings_type) { |
| 188 case CONTENT_SETTINGS_TYPE_GEOLOCATION: | 219 case CONTENT_SETTINGS_TYPE_GEOLOCATION: |
| 189 return new ContentSettingGeolocationImageModel(); | 220 return new ContentSettingGeolocationImageModel(); |
| 190 case CONTENT_SETTINGS_TYPE_NOTIFICATIONS: | 221 case CONTENT_SETTINGS_TYPE_NOTIFICATIONS: |
| 191 return new ContentSettingNotificationsImageModel(); | 222 return new ContentSettingNotificationsImageModel(); |
| 223 case CONTENT_SETTINGS_TYPE_REGISTER_PROTOCOL_HANDLER: |
| 224 return new ContentSettingRPHImageModel(); |
| 192 default: | 225 default: |
| 193 return new ContentSettingBlockedImageModel(content_settings_type); | 226 return new ContentSettingBlockedImageModel(content_settings_type); |
| 194 } | 227 } |
| 195 } | 228 } |
| OLD | NEW |