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

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

Issue 10782038: Revert 147045 - Bring up a content settings icon for ungestured registerProtocolHandler call. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 5 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 13 matching lines...) Expand all
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
41 class ContentSettingNotificationsImageModel : public ContentSettingImageModel { 34 class ContentSettingNotificationsImageModel : public ContentSettingImageModel {
42 public: 35 public:
43 ContentSettingNotificationsImageModel(); 36 ContentSettingNotificationsImageModel();
44 37
45 virtual void UpdateFromWebContents(WebContents* web_contents) OVERRIDE; 38 virtual void UpdateFromWebContents(WebContents* web_contents) OVERRIDE;
46 }; 39 };
47 40
48 namespace { 41 namespace {
49 42
50 struct ContentSettingsTypeIdEntry { 43 struct ContentSettingsTypeIdEntry {
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 unsigned int tab_state_flags = 0; 148 unsigned int tab_state_flags = 0;
156 settings_state.GetDetailedInfo(NULL, &tab_state_flags); 149 settings_state.GetDetailedInfo(NULL, &tab_state_flags);
157 bool allowed = 150 bool allowed =
158 !!(tab_state_flags & GeolocationSettingsState::TABSTATE_HAS_ANY_ALLOWED); 151 !!(tab_state_flags & GeolocationSettingsState::TABSTATE_HAS_ANY_ALLOWED);
159 set_icon(allowed ? IDR_GEOLOCATION_ALLOWED_LOCATIONBAR_ICON : 152 set_icon(allowed ? IDR_GEOLOCATION_ALLOWED_LOCATIONBAR_ICON :
160 IDR_GEOLOCATION_DENIED_LOCATIONBAR_ICON); 153 IDR_GEOLOCATION_DENIED_LOCATIONBAR_ICON);
161 set_tooltip(l10n_util::GetStringUTF8(allowed ? 154 set_tooltip(l10n_util::GetStringUTF8(allowed ?
162 IDS_GEOLOCATION_ALLOWED_TOOLTIP : IDS_GEOLOCATION_BLOCKED_TOOLTIP)); 155 IDS_GEOLOCATION_ALLOWED_TOOLTIP : IDS_GEOLOCATION_BLOCKED_TOOLTIP));
163 } 156 }
164 157
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
186 ContentSettingNotificationsImageModel::ContentSettingNotificationsImageModel() 158 ContentSettingNotificationsImageModel::ContentSettingNotificationsImageModel()
187 : ContentSettingImageModel(CONTENT_SETTINGS_TYPE_NOTIFICATIONS) { 159 : ContentSettingImageModel(CONTENT_SETTINGS_TYPE_NOTIFICATIONS) {
188 } 160 }
189 161
190 void ContentSettingNotificationsImageModel::UpdateFromWebContents( 162 void ContentSettingNotificationsImageModel::UpdateFromWebContents(
191 WebContents* web_contents) { 163 WebContents* web_contents) {
192 // Notifications do not have a bubble. 164 // Notifications do not have a bubble.
193 set_visible(false); 165 set_visible(false);
194 } 166 }
195 167
196 ContentSettingImageModel::ContentSettingImageModel( 168 ContentSettingImageModel::ContentSettingImageModel(
197 ContentSettingsType content_settings_type) 169 ContentSettingsType content_settings_type)
198 : content_settings_type_(content_settings_type), 170 : content_settings_type_(content_settings_type),
199 is_visible_(false), 171 is_visible_(false),
200 icon_(0), 172 icon_(0),
201 explanatory_string_id_(0) { 173 explanatory_string_id_(0) {
202 } 174 }
203 175
204 // static 176 // static
205 ContentSettingImageModel* 177 ContentSettingImageModel*
206 ContentSettingImageModel::CreateContentSettingImageModel( 178 ContentSettingImageModel::CreateContentSettingImageModel(
207 ContentSettingsType content_settings_type) { 179 ContentSettingsType content_settings_type) {
208 switch (content_settings_type) { 180 switch (content_settings_type) {
209 case CONTENT_SETTINGS_TYPE_GEOLOCATION: 181 case CONTENT_SETTINGS_TYPE_GEOLOCATION:
210 return new ContentSettingGeolocationImageModel(); 182 return new ContentSettingGeolocationImageModel();
211 case CONTENT_SETTINGS_TYPE_NOTIFICATIONS: 183 case CONTENT_SETTINGS_TYPE_NOTIFICATIONS:
212 return new ContentSettingNotificationsImageModel(); 184 return new ContentSettingNotificationsImageModel();
213 case CONTENT_SETTINGS_TYPE_PROTOCOL_HANDLERS:
214 return new ContentSettingRPHImageModel();
215 default: 185 default:
216 return new ContentSettingBlockedImageModel(content_settings_type); 186 return new ContentSettingBlockedImageModel(content_settings_type);
217 } 187 }
218 } 188 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698