Chromium Code Reviews| Index: chrome/browser/installable/installable_manager.h |
| diff --git a/chrome/browser/installable/installable_manager.h b/chrome/browser/installable/installable_manager.h |
| index 3906abe5aa3e80c9f67f7daff87db4789832e6d3..777fa2701884ab1522a4178cb9945beddd3b0bc0 100644 |
| --- a/chrome/browser/installable/installable_manager.h |
| +++ b/chrome/browser/installable/installable_manager.h |
| @@ -7,6 +7,7 @@ |
| #include <map> |
| #include <memory> |
| +#include <tuple> |
| #include <utility> |
| #include <vector> |
| @@ -25,6 +26,11 @@ |
| // Data is cached and fetched in the order specified in this struct. A web app |
| // manifest will always be fetched first. |
| struct InstallableParams { |
| + // Check whether the site is installable. That is, it has a manifest valid for |
| + // a web app and a service worker controlling the manifest start URL and the |
| + // current URL. |
|
dominickn
2017/01/27 06:40:43
The bools are last so that this struct will be lai
F
2017/01/27 20:11:17
Done. Thanks for the explanation.
|
| + bool check_installable = false; |
| + |
| // The ideal primary icon size to fetch. Used only if |
| // |fetch_valid_primary_icon| is true. |
| int ideal_primary_icon_size_in_px = -1; |
| @@ -33,14 +39,21 @@ struct InstallableParams { |
| // |fetch_valid_primary_icon| is true. |
| int minimum_primary_icon_size_in_px = -1; |
| - // Check whether the site is installable. That is, it has a manifest valid for |
| - // a web app and a service worker controlling the manifest start URL and the |
| - // current URL. |
| - bool check_installable = false; |
| - |
| // Check whether there is a fetchable, non-empty icon in the manifest |
| // conforming to the primary icon size parameters. |
| bool fetch_valid_primary_icon = false; |
| + |
| + // The ideal badge icon size to fetch. Used only if |
| + // |fetch_valid_badge_icon| is true. |
| + int ideal_badge_icon_size_in_px = -1; |
| + |
| + // The minimum badge icon size to fetch. Used only if |
| + // |fetch_valid_badge_icon| is true. |
| + int minimum_badge_icon_size_in_px = -1; |
| + |
| + // Check whether there is a fetchable, non-empty icon in the manifest |
| + // conforming to the badge icon size parameters. |
| + bool fetch_valid_badge_icon = false; |
| }; |
| // This struct is passed to an InstallableCallback when the InstallableManager |
| @@ -67,6 +80,16 @@ struct InstallableData { |
| // retrieved, the reason will be in error_code. |
| const SkBitmap* primary_icon; |
| + // Empty if no badge_icon was requested. |
| + const GURL& badge_icon_url; |
| + |
| + // nullptr if the most appropriate badge icon couldn't be determined or |
| + // downloaded. The underlying badge icon is owned by the InstallableManager; |
| + // clients must copy the bitmap if they want to to use it. If |
| + // fetch_valid_badge_icon was true and a badge icon could not be retrieved, |
|
dominickn
2017/01/27 06:40:42
I don't think this comment is accurate - the badge
F
2017/01/27 20:11:17
Done.
|
| + // the reason will be in error_code. |
| + const SkBitmap* badge_icon; |
| + |
| // true if the site has a service worker and a viable web app manifest. If |
| // check_installable was true and the site isn't installable, the reason will |
| // be in error_code. |
| @@ -110,21 +133,25 @@ class InstallableManager |
| FRIEND_TEST_ALL_PREFIXES(InstallableManagerBrowserTest, CheckWebapp); |
| using Task = std::pair<InstallableParams, InstallableCallback>; |
| - using IconParams = std::pair<int, int>; |
| + using IconParams = std::tuple<int, int, content::Manifest::Icon::IconPurpose>; |
| struct ManifestProperty; |
| struct InstallableProperty; |
| struct IconProperty; |
| - // Returns the IconProperty matching |params|. Creates if it doesn't exist. |
| - IconProperty& GetIcon(const InstallableParams& params); |
| + // Returns an IconParams object that queries for a primary icon conforming to |
| + // the primary icon size parameters in |params|. |
| + IconParams ParamsForPrimaryIcon(const InstallableParams& params) const; |
| + // Returns an IconParams object that queries for a badge icon conforming to |
| + // the badge icon size parameters in |params|. |
| + IconParams ParamsForBadgeIcon(const InstallableParams& params) const; |
| - // Returns true if the icon sizes in |params| matches any fetched icon. false |
| - // if no icon has been requested yet or there is no match. |
| - bool IsIconFetched(const InstallableParams& params) const; |
| + // Returns true if |params| matches any fetched icon, or false if no icon has |
| + // been requested yet or there is no match. |
| + bool IsIconFetched(const IconParams& params) const; |
| - // Sets the icon parameters in |params| as being fetched. |
| - void SetIconFetched(const InstallableParams& params); |
| + // Sets the icon matching |params| as fetched. |
| + void SetIconFetched(const IconParams& params); |
| // Returns the error code associated with the resources requested in |params|, |
| // or NO_ERROR_DETECTED if there is no error. |
| @@ -169,8 +196,9 @@ class InstallableManager |
| void CheckServiceWorker(); |
| void OnDidCheckHasServiceWorker(bool has_service_worker); |
| - void CheckAndFetchBestIcon(); |
| - void OnAppIconFetched(const GURL icon_url, const SkBitmap& bitmap); |
| + void CheckAndFetchBestIcon(const IconParams& params); |
| + void OnAppIconFetched( |
|
dominickn
2017/01/27 06:40:43
Rename to OnIconFetched.
F
2017/01/27 20:11:17
Done.
|
| + const GURL icon_url, const IconParams& params, const SkBitmap& bitmap); |
| // content::WebContentsObserver overrides |
| void DidFinishNavigation(content::NavigationHandle* handle) override; |