| 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 "base/strings/utf_string_conversions.h" | 7 #include "base/strings/utf_string_conversions.h" |
| 8 #include "chrome/browser/chrome_notification_types.h" | 8 #include "chrome/browser/chrome_notification_types.h" |
| 9 #include "chrome/browser/extensions/crx_installer.h" | 9 #include "chrome/browser/extensions/crx_installer.h" |
| 10 #include "chrome/browser/extensions/extension_service.h" | 10 #include "chrome/browser/extensions/extension_service.h" |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 103 const SkColor kBorderColor = 0xFFD5D5D5; | 103 const SkColor kBorderColor = 0xFFD5D5D5; |
| 104 const SkColor kBackgroundColor = 0xFFFFFFFF; | 104 const SkColor kBackgroundColor = 0xFFFFFFFF; |
| 105 | 105 |
| 106 // Create a separate canvas for the color strip. | 106 // Create a separate canvas for the color strip. |
| 107 scoped_ptr<SkCanvas> color_strip_canvas( | 107 scoped_ptr<SkCanvas> color_strip_canvas( |
| 108 skia::CreateBitmapCanvas(output_size, output_size, false)); | 108 skia::CreateBitmapCanvas(output_size, output_size, false)); |
| 109 DCHECK(color_strip_canvas); | 109 DCHECK(color_strip_canvas); |
| 110 | 110 |
| 111 // Draw a rounded rect of the |base_icon|'s dominant color. | 111 // Draw a rounded rect of the |base_icon|'s dominant color. |
| 112 SkPaint color_strip_paint; | 112 SkPaint color_strip_paint; |
| 113 color_utils::GridSampler sampler; | |
| 114 color_strip_paint.setFlags(SkPaint::kAntiAlias_Flag); | 113 color_strip_paint.setFlags(SkPaint::kAntiAlias_Flag); |
| 115 color_strip_paint.setColor(color_utils::CalculateKMeanColorOfPNG( | 114 color_strip_paint.setColor( |
| 116 gfx::Image::CreateFrom1xBitmap(base_icon).As1xPNGBytes(), | 115 color_utils::CalculateKMeanColorOfBitmap(base_icon)); |
| 117 100, | |
| 118 665, | |
| 119 &sampler)); | |
| 120 color_strip_canvas->drawRoundRect(SkRect::MakeWH(output_size, output_size), | 116 color_strip_canvas->drawRoundRect(SkRect::MakeWH(output_size, output_size), |
| 121 kBorderRadius, | 117 kBorderRadius, |
| 122 kBorderRadius, | 118 kBorderRadius, |
| 123 color_strip_paint); | 119 color_strip_paint); |
| 124 | 120 |
| 125 // Erase the top of the rounded rect to leave a color strip. | 121 // Erase the top of the rounded rect to leave a color strip. |
| 126 SkPaint clear_paint; | 122 SkPaint clear_paint; |
| 127 clear_paint.setColor(SK_ColorTRANSPARENT); | 123 clear_paint.setColor(SK_ColorTRANSPARENT); |
| 128 clear_paint.setXfermodeMode(SkXfermode::kSrc_Mode); | 124 clear_paint.setXfermodeMode(SkXfermode::kSrc_Mode); |
| 129 color_strip_canvas->drawRect( | 125 color_strip_canvas->drawRect( |
| (...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 347 extension, info_list, base::Bind(&OnIconsLoaded, web_app_info, callback)); | 343 extension, info_list, base::Bind(&OnIconsLoaded, web_app_info, callback)); |
| 348 } | 344 } |
| 349 | 345 |
| 350 bool IsValidBookmarkAppUrl(const GURL& url) { | 346 bool IsValidBookmarkAppUrl(const GURL& url) { |
| 351 URLPattern origin_only_pattern(Extension::kValidWebExtentSchemes); | 347 URLPattern origin_only_pattern(Extension::kValidWebExtentSchemes); |
| 352 origin_only_pattern.SetMatchAllURLs(true); | 348 origin_only_pattern.SetMatchAllURLs(true); |
| 353 return url.is_valid() && origin_only_pattern.MatchesURL(url); | 349 return url.is_valid() && origin_only_pattern.MatchesURL(url); |
| 354 } | 350 } |
| 355 | 351 |
| 356 } // namespace extensions | 352 } // namespace extensions |
| OLD | NEW |