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/extensions/icon_with_badge_image_source.h" | 5 #include "chrome/browser/ui/extensions/icon_with_badge_image_source.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <cmath> | 8 #include <cmath> |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 161 void IconWithBadgeImageSource::PaintBadge(gfx::Canvas* canvas) { | 161 void IconWithBadgeImageSource::PaintBadge(gfx::Canvas* canvas) { |
| 162 if (!badge_ || badge_->text.empty()) | 162 if (!badge_ || badge_->text.empty()) |
| 163 return; | 163 return; |
| 164 | 164 |
| 165 SkColor text_color = SkColorGetA(badge_->text_color) == SK_AlphaTRANSPARENT | 165 SkColor text_color = SkColorGetA(badge_->text_color) == SK_AlphaTRANSPARENT |
| 166 ? SK_ColorWHITE | 166 ? SK_ColorWHITE |
| 167 : badge_->text_color; | 167 : badge_->text_color; |
| 168 | 168 |
| 169 SkColor background_color = ui::MaterialDesignController::IsModeMaterial() | 169 SkColor background_color = ui::MaterialDesignController::IsModeMaterial() |
| 170 ? gfx::kGoogleBlue500 | 170 ? gfx::kGoogleBlue500 |
| 171 : SkColorSetARGB(255, 218, 0, 24); | 171 : SkColorSetRGB(218, 0, 24); |
| 172 if (SkColorGetA(badge_->background_color) != SK_AlphaTRANSPARENT) | 172 if (SkColorGetA(badge_->background_color) != SK_AlphaTRANSPARENT) |
| 173 background_color = badge_->background_color; | 173 background_color = badge_->background_color; |
| 174 if (ui::MaterialDesignController::IsModeMaterial()) | |
| 175 background_color = SkColorSetA(background_color, SK_AlphaOPAQUE); | |
|
Devlin
2016/06/24 23:01:15
Let's add a comment here saying why we ignore alph
Evan Stade
2016/06/27 15:30:03
good idea, done.
| |
| 174 | 176 |
| 175 canvas->Save(); | 177 canvas->Save(); |
| 176 | 178 |
| 177 SkPaint* text_paint = nullptr; | 179 SkPaint* text_paint = nullptr; |
| 178 int text_width = 0; | 180 int text_width = 0; |
| 179 ResourceBundle* rb = &ResourceBundle::GetSharedInstance(); | 181 ResourceBundle* rb = &ResourceBundle::GetSharedInstance(); |
| 180 gfx::FontList base_font = rb->GetFontList(ResourceBundle::BaseFont) | 182 gfx::FontList base_font = rb->GetFontList(ResourceBundle::BaseFont) |
| 181 .DeriveWithHeightUpperBound(kBadgeHeight); | 183 .DeriveWithHeightUpperBound(kBadgeHeight); |
| 182 base::string16 utf16_text = base::UTF8ToUTF16(badge_->text); | 184 base::string16 utf16_text = base::UTF8ToUTF16(badge_->text); |
| 183 | 185 |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 306 } | 308 } |
| 307 | 309 |
| 308 void IconWithBadgeImageSource::PaintBlockedActionDecoration( | 310 void IconWithBadgeImageSource::PaintBlockedActionDecoration( |
| 309 gfx::Canvas* canvas) { | 311 gfx::Canvas* canvas) { |
| 310 canvas->Save(); | 312 canvas->Save(); |
| 311 gfx::ImageSkia img = *ResourceBundle::GetSharedInstance().GetImageSkiaNamed( | 313 gfx::ImageSkia img = *ResourceBundle::GetSharedInstance().GetImageSkiaNamed( |
| 312 IDR_BLOCKED_EXTENSION_SCRIPT); | 314 IDR_BLOCKED_EXTENSION_SCRIPT); |
| 313 canvas->DrawImageInt(img, size().width() - img.width(), 0); | 315 canvas->DrawImageInt(img, size().width() - img.width(), 0); |
| 314 canvas->Restore(); | 316 canvas->Restore(); |
| 315 } | 317 } |
| OLD | NEW |