| 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 #ifndef CHROME_BROWSER_EXTENSIONS_BOOKMARK_APP_HELPER_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_BOOKMARK_APP_HELPER_H_ |
| 6 #define CHROME_BROWSER_EXTENSIONS_BOOKMARK_APP_HELPER_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_BOOKMARK_APP_HELPER_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <set> | 9 #include <set> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 45 | 45 |
| 46 // This finds the closest not-smaller bitmap in |bitmaps| for each size in | 46 // This finds the closest not-smaller bitmap in |bitmaps| for each size in |
| 47 // |sizes| and resizes it to that size. This returns a map of sizes to bitmaps | 47 // |sizes| and resizes it to that size. This returns a map of sizes to bitmaps |
| 48 // which contains only bitmaps of a size in |sizes| and at most one bitmap of | 48 // which contains only bitmaps of a size in |sizes| and at most one bitmap of |
| 49 // each size. | 49 // each size. |
| 50 static std::map<int, SkBitmap> ConstrainBitmapsToSizes( | 50 static std::map<int, SkBitmap> ConstrainBitmapsToSizes( |
| 51 const std::vector<SkBitmap>& bitmaps, | 51 const std::vector<SkBitmap>& bitmaps, |
| 52 const std::set<int>& sizes); | 52 const std::set<int>& sizes); |
| 53 | 53 |
| 54 // Adds a square container icon of |output_size| pixels to |bitmaps| by | 54 // Adds a square container icon of |output_size| pixels to |bitmaps| by |
| 55 // centering the biggest smaller icon in |bitmaps| and drawing a rounded | 55 // drawing the given |letter| into a rounded background of |color|. |
| 56 // rectangle with strip of the that icon's dominant color at the bottom. | |
| 57 // Does nothing if an icon of |output_size| already exists in |bitmaps|. | 56 // Does nothing if an icon of |output_size| already exists in |bitmaps|. |
| 58 static void GenerateContainerIcon(std::map<int, SkBitmap>* bitmaps, | 57 static void GenerateIcon(std::map<int, SkBitmap>* bitmaps, |
| 59 int output_size); | 58 int output_size, |
| 59 SkColor color, |
| 60 char letter); |
| 60 | 61 |
| 61 // Begins the asynchronous bookmark app creation. | 62 // Begins the asynchronous bookmark app creation. |
| 62 void Create(const CreateBookmarkAppCallback& callback); | 63 void Create(const CreateBookmarkAppCallback& callback); |
| 63 | 64 |
| 64 private: | 65 private: |
| 65 friend class TestBookmarkAppHelper; | 66 friend class TestBookmarkAppHelper; |
| 66 | 67 |
| 67 // Performs post icon download tasks including installing the bookmark app. | 68 // Performs post icon download tasks including installing the bookmark app. |
| 68 void OnIconsDownloaded(bool success, | 69 void OnIconsDownloaded(bool success, |
| 69 const std::map<GURL, std::vector<SkBitmap> >& bitmaps); | 70 const std::map<GURL, std::vector<SkBitmap> >& bitmaps); |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 102 content::BrowserContext* browser_context, | 103 content::BrowserContext* browser_context, |
| 103 const extensions::Extension* extension, | 104 const extensions::Extension* extension, |
| 104 const base::Callback<void(const WebApplicationInfo&)> callback); | 105 const base::Callback<void(const WebApplicationInfo&)> callback); |
| 105 | 106 |
| 106 // Returns whether the given |url| is a valid bookmark app url. | 107 // Returns whether the given |url| is a valid bookmark app url. |
| 107 bool IsValidBookmarkAppUrl(const GURL& url); | 108 bool IsValidBookmarkAppUrl(const GURL& url); |
| 108 | 109 |
| 109 } // namespace extensions | 110 } // namespace extensions |
| 110 | 111 |
| 111 #endif // CHROME_BROWSER_EXTENSIONS_BOOKMARK_APP_HELPER_H_ | 112 #endif // CHROME_BROWSER_EXTENSIONS_BOOKMARK_APP_HELPER_H_ |
| OLD | NEW |