Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(379)

Side by Side Diff: chrome/browser/ui/content_settings/content_setting_image_model.cc

Issue 10584042: Bring up a content settings icon for ungestured registerProtocolHandler call. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Repair merge Created 8 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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
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_PROTOCOL_HANDLERS) {
169 set_icon(IDR_REGISTER_PROTOCOL_HANDLER_LOCATIONBAR_ICON);
170 set_tooltip(l10n_util::GetStringUTF8(IDS_REGISTER_PROTOCOL_HANDLER_TOOLTIP));
171 }
172
173 void ContentSettingRPHImageModel::UpdateFromWebContents(
174 WebContents* web_contents) {
175 set_visible(false);
176 if (!web_contents)
177 return;
178
Peter Kasting 2012/06/26 19:53:00 Nit: These blank lines are optional (ContentSettin
Greg Billock 2012/06/26 20:31:41 I think they set off this text-heavy para better.
179 TabSpecificContentSettings* content_settings =
180 TabContents::FromWebContents(web_contents)->content_settings();
181 if (content_settings->pending_protocol_handler().IsEmpty())
182 return;
183
184 set_visible(true);
185 }
186
159 ContentSettingNotificationsImageModel::ContentSettingNotificationsImageModel() 187 ContentSettingNotificationsImageModel::ContentSettingNotificationsImageModel()
160 : ContentSettingImageModel(CONTENT_SETTINGS_TYPE_NOTIFICATIONS) { 188 : ContentSettingImageModel(CONTENT_SETTINGS_TYPE_NOTIFICATIONS) {
161 } 189 }
162 190
163 void ContentSettingNotificationsImageModel::UpdateFromWebContents( 191 void ContentSettingNotificationsImageModel::UpdateFromWebContents(
164 WebContents* web_contents) { 192 WebContents* web_contents) {
165 // Notifications do not have a bubble. 193 // Notifications do not have a bubble.
166 set_visible(false); 194 set_visible(false);
167 } 195 }
168 196
169 ContentSettingImageModel::ContentSettingImageModel( 197 ContentSettingImageModel::ContentSettingImageModel(
170 ContentSettingsType content_settings_type) 198 ContentSettingsType content_settings_type)
171 : content_settings_type_(content_settings_type), 199 : content_settings_type_(content_settings_type),
172 is_visible_(false), 200 is_visible_(false),
173 icon_(0), 201 icon_(0),
174 explanatory_string_id_(0) { 202 explanatory_string_id_(0) {
175 } 203 }
176 204
177 // static 205 // static
178 ContentSettingImageModel* 206 ContentSettingImageModel*
179 ContentSettingImageModel::CreateContentSettingImageModel( 207 ContentSettingImageModel::CreateContentSettingImageModel(
180 ContentSettingsType content_settings_type) { 208 ContentSettingsType content_settings_type) {
181 switch (content_settings_type) { 209 switch (content_settings_type) {
182 case CONTENT_SETTINGS_TYPE_GEOLOCATION: 210 case CONTENT_SETTINGS_TYPE_GEOLOCATION:
183 return new ContentSettingGeolocationImageModel(); 211 return new ContentSettingGeolocationImageModel();
184 case CONTENT_SETTINGS_TYPE_NOTIFICATIONS: 212 case CONTENT_SETTINGS_TYPE_NOTIFICATIONS:
185 return new ContentSettingNotificationsImageModel(); 213 return new ContentSettingNotificationsImageModel();
214 case CONTENT_SETTINGS_TYPE_PROTOCOL_HANDLERS:
215 return new ContentSettingRPHImageModel();
186 default: 216 default:
187 return new ContentSettingBlockedImageModel(content_settings_type); 217 return new ContentSettingBlockedImageModel(content_settings_type);
188 } 218 }
189 } 219 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698