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 398 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
409 int output_size, | 409 int output_size, |
410 SkColor color, | 410 SkColor color, |
411 char letter) { | 411 char letter) { |
412 // Do nothing if there is already an icon of |output_size|. | 412 // Do nothing if there is already an icon of |output_size|. |
413 if (bitmaps->count(output_size)) | 413 if (bitmaps->count(output_size)) |
414 return; | 414 return; |
415 | 415 |
416 gfx::ImageSkia icon_image( | 416 gfx::ImageSkia icon_image( |
417 new GeneratedIconImageSource(letter, color, output_size), | 417 new GeneratedIconImageSource(letter, color, output_size), |
418 gfx::Size(output_size, output_size)); | 418 gfx::Size(output_size, output_size)); |
419 icon_image.bitmap()->deepCopyTo(&(*bitmaps)[output_size].bitmap); | 419 SkBitmap& dst = (*bitmaps)[output_size].bitmap; |
| 420 if (dst.tryAllocPixels(icon_image.bitmap()->info())) { |
| 421 icon_image.bitmap()->readPixels(dst.info(), dst.getPixels(), dst.rowBytes(), |
| 422 0, 0); |
| 423 } |
420 } | 424 } |
421 | 425 |
422 // static | 426 // static |
423 bool BookmarkAppHelper::BookmarkOrHostedAppInstalled( | 427 bool BookmarkAppHelper::BookmarkOrHostedAppInstalled( |
424 content::BrowserContext* browser_context, | 428 content::BrowserContext* browser_context, |
425 const GURL& url) { | 429 const GURL& url) { |
426 ExtensionRegistry* registry = ExtensionRegistry::Get(browser_context); | 430 ExtensionRegistry* registry = ExtensionRegistry::Get(browser_context); |
427 const ExtensionSet& extensions = registry->enabled_extensions(); | 431 const ExtensionSet& extensions = registry->enabled_extensions(); |
428 | 432 |
429 // Iterate through the extensions and extract the LaunchWebUrl (bookmark apps) | 433 // Iterate through the extensions and extract the LaunchWebUrl (bookmark apps) |
(...skipping 381 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
811 extension, info_list, base::Bind(&OnIconsLoaded, web_app_info, callback)); | 815 extension, info_list, base::Bind(&OnIconsLoaded, web_app_info, callback)); |
812 } | 816 } |
813 | 817 |
814 bool IsValidBookmarkAppUrl(const GURL& url) { | 818 bool IsValidBookmarkAppUrl(const GURL& url) { |
815 URLPattern origin_only_pattern(Extension::kValidBookmarkAppSchemes); | 819 URLPattern origin_only_pattern(Extension::kValidBookmarkAppSchemes); |
816 origin_only_pattern.SetMatchAllURLs(true); | 820 origin_only_pattern.SetMatchAllURLs(true); |
817 return url.is_valid() && origin_only_pattern.MatchesURL(url); | 821 return url.is_valid() && origin_only_pattern.MatchesURL(url); |
818 } | 822 } |
819 | 823 |
820 } // namespace extensions | 824 } // namespace extensions |
OLD | NEW |