| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/extensions/bookmark_app_helper.h" | 5 #include "chrome/browser/extensions/bookmark_app_helper.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <cctype> | 9 #include <cctype> |
| 10 #include <string> | 10 #include <string> |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 104 const size_t font_size = output_size_ * 7 / 16; | 104 const size_t font_size = output_size_ * 7 / 16; |
| 105 | 105 |
| 106 std::string font_name = | 106 std::string font_name = |
| 107 l10n_util::GetStringUTF8(IDS_SANS_SERIF_FONT_FAMILY); | 107 l10n_util::GetStringUTF8(IDS_SANS_SERIF_FONT_FAMILY); |
| 108 #if defined(OS_CHROMEOS) | 108 #if defined(OS_CHROMEOS) |
| 109 const std::string kChromeOSFontFamily = "Noto Sans"; | 109 const std::string kChromeOSFontFamily = "Noto Sans"; |
| 110 font_name = kChromeOSFontFamily; | 110 font_name = kChromeOSFontFamily; |
| 111 #endif | 111 #endif |
| 112 | 112 |
| 113 // Draw a rounded rect of the given |color|. | 113 // Draw a rounded rect of the given |color|. |
| 114 cc::PaintFlags background_paint; | 114 cc::PaintFlags background_flags; |
| 115 background_paint.setAntiAlias(true); | 115 background_flags.setAntiAlias(true); |
| 116 background_paint.setColor(color_); | 116 background_flags.setColor(color_); |
| 117 | 117 |
| 118 gfx::Rect icon_rect(icon_inset, icon_inset, icon_size, icon_size); | 118 gfx::Rect icon_rect(icon_inset, icon_inset, icon_size, icon_size); |
| 119 canvas->DrawRoundRect(icon_rect, border_radius, background_paint); | 119 canvas->DrawRoundRect(icon_rect, border_radius, background_flags); |
| 120 | 120 |
| 121 // The text rect's size needs to be odd to center the text correctly. | 121 // The text rect's size needs to be odd to center the text correctly. |
| 122 gfx::Rect text_rect(icon_inset, icon_inset, icon_size + 1, icon_size + 1); | 122 gfx::Rect text_rect(icon_inset, icon_inset, icon_size + 1, icon_size + 1); |
| 123 // Draw the letter onto the rounded rect. The letter's color depends on the | 123 // Draw the letter onto the rounded rect. The letter's color depends on the |
| 124 // luma of |color|. | 124 // luma of |color|. |
| 125 const uint8_t luma = color_utils::GetLuma(color_); | 125 const uint8_t luma = color_utils::GetLuma(color_); |
| 126 canvas->DrawStringRectWithFlags( | 126 canvas->DrawStringRectWithFlags( |
| 127 base::string16(1, std::toupper(letter_)), | 127 base::string16(1, std::toupper(letter_)), |
| 128 gfx::FontList(gfx::Font(font_name, font_size)), | 128 gfx::FontList(gfx::Font(font_name, font_size)), |
| 129 (luma > kLumaThreshold) ? SK_ColorBLACK : SK_ColorWHITE, | 129 (luma > kLumaThreshold) ? SK_ColorBLACK : SK_ColorWHITE, |
| (...skipping 683 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 813 extension, info_list, base::Bind(&OnIconsLoaded, web_app_info, callback)); | 813 extension, info_list, base::Bind(&OnIconsLoaded, web_app_info, callback)); |
| 814 } | 814 } |
| 815 | 815 |
| 816 bool IsValidBookmarkAppUrl(const GURL& url) { | 816 bool IsValidBookmarkAppUrl(const GURL& url) { |
| 817 URLPattern origin_only_pattern(Extension::kValidBookmarkAppSchemes); | 817 URLPattern origin_only_pattern(Extension::kValidBookmarkAppSchemes); |
| 818 origin_only_pattern.SetMatchAllURLs(true); | 818 origin_only_pattern.SetMatchAllURLs(true); |
| 819 return url.is_valid() && origin_only_pattern.MatchesURL(url); | 819 return url.is_valid() && origin_only_pattern.MatchesURL(url); |
| 820 } | 820 } |
| 821 | 821 |
| 822 } // namespace extensions | 822 } // namespace extensions |
| OLD | NEW |