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