| 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 13 matching lines...) Expand all Loading... |
| 24 virtual void UpdateFromWebContents(WebContents* web_contents) OVERRIDE; | 24 virtual void UpdateFromWebContents(WebContents* web_contents) OVERRIDE; |
| 25 }; | 25 }; |
| 26 | 26 |
| 27 class ContentSettingGeolocationImageModel : public ContentSettingImageModel { | 27 class ContentSettingGeolocationImageModel : public ContentSettingImageModel { |
| 28 public: | 28 public: |
| 29 ContentSettingGeolocationImageModel(); | 29 ContentSettingGeolocationImageModel(); |
| 30 | 30 |
| 31 virtual void UpdateFromWebContents(WebContents* web_contents) OVERRIDE; | 31 virtual void UpdateFromWebContents(WebContents* web_contents) OVERRIDE; |
| 32 }; | 32 }; |
| 33 | 33 |
| 34 class ContentSettingRPHImageModel : public ContentSettingImageModel { |
| 35 public: |
| 36 ContentSettingRPHImageModel(); |
| 37 |
| 38 virtual void UpdateFromWebContents(WebContents* web_contents) OVERRIDE; |
| 39 }; |
| 40 |
| 34 class ContentSettingNotificationsImageModel : public ContentSettingImageModel { | 41 class ContentSettingNotificationsImageModel : public ContentSettingImageModel { |
| 35 public: | 42 public: |
| 36 ContentSettingNotificationsImageModel(); | 43 ContentSettingNotificationsImageModel(); |
| 37 | 44 |
| 38 virtual void UpdateFromWebContents(WebContents* web_contents) OVERRIDE; | 45 virtual void UpdateFromWebContents(WebContents* web_contents) OVERRIDE; |
| 39 }; | 46 }; |
| 40 | 47 |
| 41 namespace { | 48 namespace { |
| 42 | 49 |
| 43 struct ContentSettingsTypeIdEntry { | 50 struct ContentSettingsTypeIdEntry { |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 148 unsigned int tab_state_flags = 0; | 155 unsigned int tab_state_flags = 0; |
| 149 settings_state.GetDetailedInfo(NULL, &tab_state_flags); | 156 settings_state.GetDetailedInfo(NULL, &tab_state_flags); |
| 150 bool allowed = | 157 bool allowed = |
| 151 !!(tab_state_flags & GeolocationSettingsState::TABSTATE_HAS_ANY_ALLOWED); | 158 !!(tab_state_flags & GeolocationSettingsState::TABSTATE_HAS_ANY_ALLOWED); |
| 152 set_icon(allowed ? IDR_GEOLOCATION_ALLOWED_LOCATIONBAR_ICON : | 159 set_icon(allowed ? IDR_GEOLOCATION_ALLOWED_LOCATIONBAR_ICON : |
| 153 IDR_GEOLOCATION_DENIED_LOCATIONBAR_ICON); | 160 IDR_GEOLOCATION_DENIED_LOCATIONBAR_ICON); |
| 154 set_tooltip(l10n_util::GetStringUTF8(allowed ? | 161 set_tooltip(l10n_util::GetStringUTF8(allowed ? |
| 155 IDS_GEOLOCATION_ALLOWED_TOOLTIP : IDS_GEOLOCATION_BLOCKED_TOOLTIP)); | 162 IDS_GEOLOCATION_ALLOWED_TOOLTIP : IDS_GEOLOCATION_BLOCKED_TOOLTIP)); |
| 156 } | 163 } |
| 157 | 164 |
| 165 ContentSettingRPHImageModel::ContentSettingRPHImageModel() |
| 166 : ContentSettingImageModel( |
| 167 CONTENT_SETTINGS_TYPE_PROTOCOL_HANDLERS) { |
| 168 set_icon(IDR_REGISTER_PROTOCOL_HANDLER_LOCATIONBAR_ICON); |
| 169 set_tooltip(l10n_util::GetStringUTF8(IDS_REGISTER_PROTOCOL_HANDLER_TOOLTIP)); |
| 170 } |
| 171 |
| 172 void ContentSettingRPHImageModel::UpdateFromWebContents( |
| 173 WebContents* web_contents) { |
| 174 set_visible(false); |
| 175 if (!web_contents) |
| 176 return; |
| 177 |
| 178 TabSpecificContentSettings* content_settings = |
| 179 TabContents::FromWebContents(web_contents)->content_settings(); |
| 180 if (content_settings->pending_protocol_handler().IsEmpty()) |
| 181 return; |
| 182 |
| 183 set_visible(true); |
| 184 } |
| 185 |
| 158 ContentSettingNotificationsImageModel::ContentSettingNotificationsImageModel() | 186 ContentSettingNotificationsImageModel::ContentSettingNotificationsImageModel() |
| 159 : ContentSettingImageModel(CONTENT_SETTINGS_TYPE_NOTIFICATIONS) { | 187 : ContentSettingImageModel(CONTENT_SETTINGS_TYPE_NOTIFICATIONS) { |
| 160 } | 188 } |
| 161 | 189 |
| 162 void ContentSettingNotificationsImageModel::UpdateFromWebContents( | 190 void ContentSettingNotificationsImageModel::UpdateFromWebContents( |
| 163 WebContents* web_contents) { | 191 WebContents* web_contents) { |
| 164 // Notifications do not have a bubble. | 192 // Notifications do not have a bubble. |
| 165 set_visible(false); | 193 set_visible(false); |
| 166 } | 194 } |
| 167 | 195 |
| 168 ContentSettingImageModel::ContentSettingImageModel( | 196 ContentSettingImageModel::ContentSettingImageModel( |
| 169 ContentSettingsType content_settings_type) | 197 ContentSettingsType content_settings_type) |
| 170 : content_settings_type_(content_settings_type), | 198 : content_settings_type_(content_settings_type), |
| 171 is_visible_(false), | 199 is_visible_(false), |
| 172 icon_(0), | 200 icon_(0), |
| 173 explanatory_string_id_(0) { | 201 explanatory_string_id_(0) { |
| 174 } | 202 } |
| 175 | 203 |
| 176 // static | 204 // static |
| 177 ContentSettingImageModel* | 205 ContentSettingImageModel* |
| 178 ContentSettingImageModel::CreateContentSettingImageModel( | 206 ContentSettingImageModel::CreateContentSettingImageModel( |
| 179 ContentSettingsType content_settings_type) { | 207 ContentSettingsType content_settings_type) { |
| 180 switch (content_settings_type) { | 208 switch (content_settings_type) { |
| 181 case CONTENT_SETTINGS_TYPE_GEOLOCATION: | 209 case CONTENT_SETTINGS_TYPE_GEOLOCATION: |
| 182 return new ContentSettingGeolocationImageModel(); | 210 return new ContentSettingGeolocationImageModel(); |
| 183 case CONTENT_SETTINGS_TYPE_NOTIFICATIONS: | 211 case CONTENT_SETTINGS_TYPE_NOTIFICATIONS: |
| 184 return new ContentSettingNotificationsImageModel(); | 212 return new ContentSettingNotificationsImageModel(); |
| 213 case CONTENT_SETTINGS_TYPE_PROTOCOL_HANDLERS: |
| 214 return new ContentSettingRPHImageModel(); |
| 185 default: | 215 default: |
| 186 return new ContentSettingBlockedImageModel(content_settings_type); | 216 return new ContentSettingBlockedImageModel(content_settings_type); |
| 187 } | 217 } |
| 188 } | 218 } |
| OLD | NEW |