| 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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 44 | 44 |
| 45 // This finds the closest not-smaller bitmap in |bitmaps| for each size in | 45 // This finds the closest not-smaller bitmap in |bitmaps| for each size in |
| 46 // |sizes| and resizes it to that size. This returns a map of sizes to bitmaps | 46 // |sizes| and resizes it to that size. This returns a map of sizes to bitmaps |
| 47 // which contains only bitmaps of a size in |sizes| and at most one bitmap of | 47 // which contains only bitmaps of a size in |sizes| and at most one bitmap of |
| 48 // each size. | 48 // each size. |
| 49 static std::map<int, SkBitmap> ConstrainBitmapsToSizes( | 49 static std::map<int, SkBitmap> ConstrainBitmapsToSizes( |
| 50 const std::vector<SkBitmap>& bitmaps, | 50 const std::vector<SkBitmap>& bitmaps, |
| 51 const std::set<int>& sizes); | 51 const std::set<int>& sizes); |
| 52 | 52 |
| 53 // Adds a square container icon of |output_size| pixels to |bitmaps| by | 53 // Adds a square container icon of |output_size| pixels to |bitmaps| by |
| 54 // centering the biggest smaller icon in |bitmaps| and drawing a rounded | 54 // drawing the given |letter| into a rounded background of |color|. |
| 55 // rectangle with strip of the that icon's dominant color at the bottom. | |
| 56 // Does nothing if an icon of |output_size| already exists in |bitmaps|. | 55 // Does nothing if an icon of |output_size| already exists in |bitmaps|. |
| 57 static void GenerateContainerIcon(std::map<int, SkBitmap>* bitmaps, | 56 static void GenerateIcon(std::map<int, SkBitmap>* bitmaps, |
| 58 int output_size); | 57 int output_size, |
| 58 SkColor color, |
| 59 char letter); |
| 59 | 60 |
| 60 // Begins the asynchronous bookmark app creation. | 61 // Begins the asynchronous bookmark app creation. |
| 61 void Create(const CreateBookmarkAppCallback& callback); | 62 void Create(const CreateBookmarkAppCallback& callback); |
| 62 | 63 |
| 63 private: | 64 private: |
| 64 friend class TestBookmarkAppHelper; | 65 friend class TestBookmarkAppHelper; |
| 65 | 66 |
| 66 // Performs post icon download tasks including installing the bookmark app. | 67 // Performs post icon download tasks including installing the bookmark app. |
| 67 void OnIconsDownloaded(bool success, | 68 void OnIconsDownloaded(bool success, |
| 68 const std::map<GURL, std::vector<SkBitmap> >& bitmaps); | 69 const std::map<GURL, std::vector<SkBitmap> >& bitmaps); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 92 // not be downloaded so only supplied icon data will be used. | 93 // not be downloaded so only supplied icon data will be used. |
| 93 void CreateOrUpdateBookmarkApp(ExtensionService* service, | 94 void CreateOrUpdateBookmarkApp(ExtensionService* service, |
| 94 WebApplicationInfo& web_app_info); | 95 WebApplicationInfo& web_app_info); |
| 95 | 96 |
| 96 // Returns whether the given |url| is a valid bookmark app url. | 97 // Returns whether the given |url| is a valid bookmark app url. |
| 97 bool IsValidBookmarkAppUrl(const GURL& url); | 98 bool IsValidBookmarkAppUrl(const GURL& url); |
| 98 | 99 |
| 99 } // namespace extensions | 100 } // namespace extensions |
| 100 | 101 |
| 101 #endif // CHROME_BROWSER_EXTENSIONS_BOOKMARK_APP_HELPER_H_ | 102 #endif // CHROME_BROWSER_EXTENSIONS_BOOKMARK_APP_HELPER_H_ |
| OLD | NEW |