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

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

Issue 1309063006: Fix vectorized icon for PPAPI broker website setting icon (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: docs Created 5 years, 3 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_image_model.h ('k') | ui/gfx/BUILD.gn » ('j') | 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 "chrome/browser/content_settings/tab_specific_content_settings.h" 7 #include "chrome/browser/content_settings/tab_specific_content_settings.h"
8 #include "chrome/browser/prerender/prerender_manager.h" 8 #include "chrome/browser/prerender/prerender_manager.h"
9 #include "chrome/browser/profiles/profile.h" 9 #include "chrome/browser/profiles/profile.h"
10 #include "chrome/grit/generated_resources.h" 10 #include "chrome/grit/generated_resources.h"
(...skipping 16 matching lines...) Expand all
27 namespace { 27 namespace {
28 28
29 bool UseVectorGraphics() { 29 bool UseVectorGraphics() {
30 #if defined(OS_MACOSX) 30 #if defined(OS_MACOSX)
31 return false; 31 return false;
32 #else 32 #else
33 return ui::MaterialDesignController::IsModeMaterial(); 33 return ui::MaterialDesignController::IsModeMaterial();
34 #endif 34 #endif
35 } 35 }
36 36
37 #if !defined(OS_MACOSX)
38 // Gets a vector icon badged with |badge|.
39 gfx::Image GetIcon(gfx::VectorIconId id, gfx::VectorIconId badge) {
40 SkColor icon_color;
41 ui::CommonThemeGetSystemColor(ui::NativeTheme::kColorId_ChromeIconGrey,
42 &icon_color);
43 return gfx::Image(gfx::CreateVectorIconWithBadge(id, 16, icon_color, badge));
44 }
45 #endif
46
37 } // namespace 47 } // namespace
38 48
39 class ContentSettingBlockedImageModel : public ContentSettingImageModel { 49 class ContentSettingBlockedImageModel : public ContentSettingImageModel {
40 public: 50 public:
41 explicit ContentSettingBlockedImageModel( 51 explicit ContentSettingBlockedImageModel(
42 ContentSettingsType content_settings_type); 52 ContentSettingsType content_settings_type);
43 53
44 void UpdateFromWebContents(WebContents* web_contents) override; 54 void UpdateFromWebContents(WebContents* web_contents) override;
45 }; 55 };
46 56
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 break; 148 break;
139 case CONTENT_SETTINGS_TYPE_PLUGINS: 149 case CONTENT_SETTINGS_TYPE_PLUGINS:
140 vector_icon_id = gfx::VectorIconId::EXTENSION; 150 vector_icon_id = gfx::VectorIconId::EXTENSION;
141 break; 151 break;
142 case CONTENT_SETTINGS_TYPE_POPUPS: 152 case CONTENT_SETTINGS_TYPE_POPUPS:
143 vector_icon_id = gfx::VectorIconId::WEB; 153 vector_icon_id = gfx::VectorIconId::WEB;
144 break; 154 break;
145 case CONTENT_SETTINGS_TYPE_MIXEDSCRIPT: 155 case CONTENT_SETTINGS_TYPE_MIXEDSCRIPT:
146 vector_icon_id = gfx::VectorIconId::MIXED_CONTENT; 156 vector_icon_id = gfx::VectorIconId::MIXED_CONTENT;
147 break; 157 break;
148 // TODO(estade): change this one?
149 case CONTENT_SETTINGS_TYPE_PPAPI_BROKER: 158 case CONTENT_SETTINGS_TYPE_PPAPI_BROKER:
150 vector_icon_id = gfx::VectorIconId::EXTENSION; 159 vector_icon_id = gfx::VectorIconId::EXTENSION;
151 break; 160 break;
152 case CONTENT_SETTINGS_TYPE_AUTOMATIC_DOWNLOADS: 161 case CONTENT_SETTINGS_TYPE_AUTOMATIC_DOWNLOADS:
153 vector_icon_id = gfx::VectorIconId::FILE_DOWNLOAD; 162 vector_icon_id = gfx::VectorIconId::FILE_DOWNLOAD;
154 break; 163 break;
155 default: 164 default:
156 // If we didn't find a vector icon ID we shouldn't have found an 165 // If we didn't find a vector icon ID we shouldn't have found an
157 // asset ID either. 166 // asset ID either.
158 DCHECK_EQ(0, icon_id); 167 DCHECK_EQ(0, icon_id);
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
228 kAccessedTooltipIDs, arraysize(kAccessedTooltipIDs), type); 237 kAccessedTooltipIDs, arraysize(kAccessedTooltipIDs), type);
229 explanation_id = 0; 238 explanation_id = 0;
230 } 239 }
231 set_visible(true); 240 set_visible(true);
232 if (!UseVectorGraphics()) { 241 if (!UseVectorGraphics()) {
233 DCHECK(icon_id); 242 DCHECK(icon_id);
234 SetIconByResourceId(icon_id); 243 SetIconByResourceId(icon_id);
235 #if !defined(OS_MACOSX) 244 #if !defined(OS_MACOSX)
236 } else { 245 } else {
237 DCHECK(gfx::VectorIconId::VECTOR_ICON_NONE != vector_icon_id); 246 DCHECK(gfx::VectorIconId::VECTOR_ICON_NONE != vector_icon_id);
238 SetIconByVectorId(vector_icon_id, content_settings->IsContentBlocked(type)); 247
248 if (type == CONTENT_SETTINGS_TYPE_PPAPI_BROKER) {
249 set_icon(GetIcon(vector_icon_id, gfx::VectorIconId::WARNING_BADGE));
250 } else {
251 SetIconByVectorId(vector_icon_id,
252 content_settings->IsContentBlocked(type));
253 }
239 #endif 254 #endif
240 } 255 }
241 set_explanatory_string_id(explanation_id); 256 set_explanatory_string_id(explanation_id);
242 DCHECK(tooltip_id); 257 DCHECK(tooltip_id);
243 set_tooltip(l10n_util::GetStringUTF8(tooltip_id)); 258 set_tooltip(l10n_util::GetStringUTF8(tooltip_id));
244 } 259 }
245 260
246 ContentSettingGeolocationImageModel::ContentSettingGeolocationImageModel() 261 ContentSettingGeolocationImageModel::ContentSettingGeolocationImageModel()
247 : ContentSettingImageModel(CONTENT_SETTINGS_TYPE_GEOLOCATION) { 262 : ContentSettingImageModel(CONTENT_SETTINGS_TYPE_GEOLOCATION) {
248 } 263 }
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after
453 } 468 }
454 469
455 void ContentSettingImageModel::SetIconByResourceId(int id) { 470 void ContentSettingImageModel::SetIconByResourceId(int id) {
456 icon_id_ = id; 471 icon_id_ = id;
457 icon_ = ui::ResourceBundle::GetSharedInstance().GetNativeImageNamed(id); 472 icon_ = ui::ResourceBundle::GetSharedInstance().GetNativeImageNamed(id);
458 } 473 }
459 474
460 #if !defined(OS_MACOSX) 475 #if !defined(OS_MACOSX)
461 void ContentSettingImageModel::SetIconByVectorId(gfx::VectorIconId id, 476 void ContentSettingImageModel::SetIconByVectorId(gfx::VectorIconId id,
462 bool blocked) { 477 bool blocked) {
463 SkColor icon_color; 478 icon_ = GetIcon(id, blocked ? gfx::VectorIconId::BLOCKED_BADGE
464 ui::CommonThemeGetSystemColor(ui::NativeTheme::kColorId_ChromeIconGrey, 479 : gfx::VectorIconId::VECTOR_ICON_NONE);
465 &icon_color);
466 icon_ = gfx::Image(gfx::CreateVectorIconWithBadge(
467 id, 16, icon_color, blocked ? gfx::VectorIconId::BLOCKED_BADGE
468 : gfx::VectorIconId::VECTOR_ICON_NONE));
469 } 480 }
470 #endif 481 #endif
OLDNEW
« no previous file with comments | « chrome/browser/ui/content_settings/content_setting_image_model.h ('k') | ui/gfx/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698