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

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

Issue 2371083002: Cleanup nits in content_setting*model. (Closed)
Patch Set: Created 4 years, 2 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
« no previous file with comments | « chrome/browser/ui/content_settings/content_setting_bubble_model.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "base/macros.h" 7 #include "base/macros.h"
8 #include "base/memory/ptr_util.h" 8 #include "base/memory/ptr_util.h"
9 #include "build/build_config.h" 9 #include "build/build_config.h"
10 #include "chrome/browser/content_settings/host_content_settings_map_factory.h" 10 #include "chrome/browser/content_settings/host_content_settings_map_factory.h"
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 namespace { 97 namespace {
98 98
99 struct ContentSettingsImageDetails { 99 struct ContentSettingsImageDetails {
100 ContentSettingsType type; 100 ContentSettingsType type;
101 gfx::VectorIconId icon_id; 101 gfx::VectorIconId icon_id;
102 int blocked_tooltip_id; 102 int blocked_tooltip_id;
103 int blocked_explanatory_text_id; 103 int blocked_explanatory_text_id;
104 int accessed_tooltip_id; 104 int accessed_tooltip_id;
105 }; 105 };
106 106
107 static const ContentSettingsImageDetails kImageDetails[] = { 107 const ContentSettingsImageDetails kImageDetails[] = {
108 {CONTENT_SETTINGS_TYPE_COOKIES, 108 {CONTENT_SETTINGS_TYPE_COOKIES, gfx::VectorIconId::COOKIE,
109 gfx::VectorIconId::COOKIE, 109 IDS_BLOCKED_COOKIES_TITLE, 0, IDS_ACCESSED_COOKIES_TITLE},
110 IDS_BLOCKED_COOKIES_TITLE, 110 {CONTENT_SETTINGS_TYPE_IMAGES, gfx::VectorIconId::IMAGE,
111 0, 111 IDS_BLOCKED_IMAGES_TITLE, 0, 0},
112 IDS_ACCESSED_COOKIES_TITLE}, 112 {CONTENT_SETTINGS_TYPE_JAVASCRIPT, gfx::VectorIconId::CODE,
113 {CONTENT_SETTINGS_TYPE_IMAGES, 113 IDS_BLOCKED_JAVASCRIPT_TITLE, 0, 0},
114 gfx::VectorIconId::IMAGE, 114 {CONTENT_SETTINGS_TYPE_PLUGINS, gfx::VectorIconId::EXTENSION,
115 IDS_BLOCKED_IMAGES_TITLE, 115 IDS_BLOCKED_PLUGINS_MESSAGE, IDS_BLOCKED_PLUGIN_EXPLANATORY_TEXT, 0},
116 0, 116 {CONTENT_SETTINGS_TYPE_POPUPS, gfx::VectorIconId::WEB,
117 0}, 117 IDS_BLOCKED_POPUPS_TOOLTIP, IDS_BLOCKED_POPUPS_EXPLANATORY_TEXT, 0},
118 {CONTENT_SETTINGS_TYPE_JAVASCRIPT, 118 {CONTENT_SETTINGS_TYPE_MIXEDSCRIPT, gfx::VectorIconId::MIXED_CONTENT,
119 gfx::VectorIconId::CODE, 119 IDS_BLOCKED_DISPLAYING_INSECURE_CONTENT, 0, 0},
120 IDS_BLOCKED_JAVASCRIPT_TITLE, 120 {CONTENT_SETTINGS_TYPE_PPAPI_BROKER, gfx::VectorIconId::EXTENSION,
121 0, 121 IDS_BLOCKED_PPAPI_BROKER_TITLE, 0, IDS_ALLOWED_PPAPI_BROKER_TITLE},
122 0},
123 {CONTENT_SETTINGS_TYPE_PLUGINS,
124 gfx::VectorIconId::EXTENSION,
125 IDS_BLOCKED_PLUGINS_MESSAGE,
126 IDS_BLOCKED_PLUGIN_EXPLANATORY_TEXT,
127 0},
128 {CONTENT_SETTINGS_TYPE_POPUPS,
129 gfx::VectorIconId::WEB,
130 IDS_BLOCKED_POPUPS_TOOLTIP,
131 IDS_BLOCKED_POPUPS_EXPLANATORY_TEXT,
132 0},
133 {CONTENT_SETTINGS_TYPE_MIXEDSCRIPT,
134 gfx::VectorIconId::MIXED_CONTENT,
135 IDS_BLOCKED_DISPLAYING_INSECURE_CONTENT,
136 0,
137 0},
138 {CONTENT_SETTINGS_TYPE_PPAPI_BROKER,
139 gfx::VectorIconId::EXTENSION,
140 IDS_BLOCKED_PPAPI_BROKER_TITLE,
141 0,
142 IDS_ALLOWED_PPAPI_BROKER_TITLE},
143 {CONTENT_SETTINGS_TYPE_AUTOMATIC_DOWNLOADS, 122 {CONTENT_SETTINGS_TYPE_AUTOMATIC_DOWNLOADS,
144 gfx::VectorIconId::FILE_DOWNLOAD, 123 gfx::VectorIconId::FILE_DOWNLOAD, IDS_BLOCKED_DOWNLOAD_TITLE,
145 IDS_BLOCKED_DOWNLOAD_TITLE, 124 IDS_BLOCKED_DOWNLOADS_EXPLANATION, IDS_ALLOWED_DOWNLOAD_TITLE},
146 IDS_BLOCKED_DOWNLOADS_EXPLANATION,
147 IDS_ALLOWED_DOWNLOAD_TITLE},
148 }; 125 };
149 126
150 const ContentSettingsImageDetails* GetImageDetails(ContentSettingsType type) { 127 const ContentSettingsImageDetails* GetImageDetails(ContentSettingsType type) {
151 for (const ContentSettingsImageDetails& image_details : kImageDetails) { 128 for (const ContentSettingsImageDetails& image_details : kImageDetails) {
152 if (image_details.type == type) 129 if (image_details.type == type)
153 return &image_details; 130 return &image_details;
154 } 131 }
155 return nullptr; 132 return nullptr;
156 } 133 }
157 134
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
256 TabSpecificContentSettings::FromWebContents(web_contents); 233 TabSpecificContentSettings::FromWebContents(web_contents);
257 if (!content_settings) 234 if (!content_settings)
258 return; 235 return;
259 if (!content_settings->IsContentBlocked(type)) { 236 if (!content_settings->IsContentBlocked(type)) {
260 if (!content_settings->IsContentAllowed(type)) 237 if (!content_settings->IsContentAllowed(type))
261 return; 238 return;
262 239
263 // For cookies, only show the cookie blocked page action if cookies are 240 // For cookies, only show the cookie blocked page action if cookies are
264 // blocked by default. 241 // blocked by default.
265 if (type == CONTENT_SETTINGS_TYPE_COOKIES && 242 if (type == CONTENT_SETTINGS_TYPE_COOKIES &&
266 (map->GetDefaultContentSetting(type, NULL) != CONTENT_SETTING_BLOCK)) 243 (map->GetDefaultContentSetting(type, nullptr) != CONTENT_SETTING_BLOCK))
267 return; 244 return;
268 245
269 tooltip_id = image_details->accessed_tooltip_id; 246 tooltip_id = image_details->accessed_tooltip_id;
270 explanation_id = 0; 247 explanation_id = 0;
271 } 248 }
272 set_visible(true); 249 set_visible(true);
273 gfx::VectorIconId badge_id = gfx::VectorIconId::VECTOR_ICON_NONE; 250 gfx::VectorIconId badge_id = gfx::VectorIconId::VECTOR_ICON_NONE;
274 if (type == CONTENT_SETTINGS_TYPE_PPAPI_BROKER) 251 if (type == CONTENT_SETTINGS_TYPE_PPAPI_BROKER)
275 badge_id = gfx::VectorIconId::WARNING_BADGE; 252 badge_id = gfx::VectorIconId::WARNING_BADGE;
276 else if (content_settings->IsContentBlocked(type)) 253 else if (content_settings->IsContentBlocked(type))
(...skipping 22 matching lines...) Expand all
299 return; 276 return;
300 const ContentSettingsUsagesState& usages_state = content_settings-> 277 const ContentSettingsUsagesState& usages_state = content_settings->
301 geolocation_usages_state(); 278 geolocation_usages_state();
302 if (usages_state.state_map().empty()) 279 if (usages_state.state_map().empty())
303 return; 280 return;
304 set_visible(true); 281 set_visible(true);
305 282
306 // If any embedded site has access the allowed icon takes priority over the 283 // If any embedded site has access the allowed icon takes priority over the
307 // blocked icon. 284 // blocked icon.
308 unsigned int state_flags = 0; 285 unsigned int state_flags = 0;
309 usages_state.GetDetailedInfo(NULL, &state_flags); 286 usages_state.GetDetailedInfo(nullptr, &state_flags);
310 bool allowed = 287 bool allowed =
311 !!(state_flags & ContentSettingsUsagesState::TABSTATE_HAS_ANY_ALLOWED); 288 !!(state_flags & ContentSettingsUsagesState::TABSTATE_HAS_ANY_ALLOWED);
312 set_icon_by_vector_id(gfx::VectorIconId::MY_LOCATION, 289 set_icon_by_vector_id(gfx::VectorIconId::MY_LOCATION,
313 allowed ? gfx::VectorIconId::VECTOR_ICON_NONE 290 allowed ? gfx::VectorIconId::VECTOR_ICON_NONE
314 : gfx::VectorIconId::BLOCKED_BADGE); 291 : gfx::VectorIconId::BLOCKED_BADGE);
315 set_tooltip(l10n_util::GetStringUTF16(allowed 292 set_tooltip(l10n_util::GetStringUTF16(allowed
316 ? IDS_GEOLOCATION_ALLOWED_TOOLTIP 293 ? IDS_GEOLOCATION_ALLOWED_TOOLTIP
317 : IDS_GEOLOCATION_BLOCKED_TOOLTIP)); 294 : IDS_GEOLOCATION_BLOCKED_TOOLTIP));
318 } 295 }
319 296
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
497 return; 474 return;
498 const ContentSettingsUsagesState& usages_state = 475 const ContentSettingsUsagesState& usages_state =
499 content_settings->midi_usages_state(); 476 content_settings->midi_usages_state();
500 if (usages_state.state_map().empty()) 477 if (usages_state.state_map().empty())
501 return; 478 return;
502 set_visible(true); 479 set_visible(true);
503 480
504 // If any embedded site has access the allowed icon takes priority over the 481 // If any embedded site has access the allowed icon takes priority over the
505 // blocked icon. 482 // blocked icon.
506 unsigned int state_flags = 0; 483 unsigned int state_flags = 0;
507 usages_state.GetDetailedInfo(NULL, &state_flags); 484 usages_state.GetDetailedInfo(nullptr, &state_flags);
508 bool allowed = 485 bool allowed =
509 !!(state_flags & ContentSettingsUsagesState::TABSTATE_HAS_ANY_ALLOWED); 486 !!(state_flags & ContentSettingsUsagesState::TABSTATE_HAS_ANY_ALLOWED);
510 set_icon_by_vector_id(gfx::VectorIconId::MIDI, 487 set_icon_by_vector_id(gfx::VectorIconId::MIDI,
511 allowed ? gfx::VectorIconId::VECTOR_ICON_NONE 488 allowed ? gfx::VectorIconId::VECTOR_ICON_NONE
512 : gfx::VectorIconId::BLOCKED_BADGE); 489 : gfx::VectorIconId::BLOCKED_BADGE);
513 set_tooltip(l10n_util::GetStringUTF16(allowed 490 set_tooltip(l10n_util::GetStringUTF16(allowed
514 ? IDS_MIDI_SYSEX_ALLOWED_TOOLTIP 491 ? IDS_MIDI_SYSEX_ALLOWED_TOOLTIP
515 : IDS_MIDI_SYSEX_BLOCKED_TOOLTIP)); 492 : IDS_MIDI_SYSEX_BLOCKED_TOOLTIP));
516 } 493 }
517 494
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
569 546
570 #if defined(OS_MACOSX) 547 #if defined(OS_MACOSX)
571 bool ContentSettingImageModel::UpdateFromWebContentsAndCheckIfIconChanged( 548 bool ContentSettingImageModel::UpdateFromWebContentsAndCheckIfIconChanged(
572 content::WebContents* web_contents) { 549 content::WebContents* web_contents) {
573 gfx::VectorIconId old_icon = icon_id_; 550 gfx::VectorIconId old_icon = icon_id_;
574 gfx::VectorIconId old_badge_icon = icon_badge_id_; 551 gfx::VectorIconId old_badge_icon = icon_badge_id_;
575 UpdateFromWebContents(web_contents); 552 UpdateFromWebContents(web_contents);
576 return old_icon != icon_id_ && old_badge_icon != icon_badge_id_; 553 return old_icon != icon_id_ && old_badge_icon != icon_badge_id_;
577 } 554 }
578 #endif 555 #endif
OLDNEW
« no previous file with comments | « chrome/browser/ui/content_settings/content_setting_bubble_model.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698