Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(199)

Side by Side Diff: chrome/browser/installable/installable_manager.h

Issue 2773353002: Make minimum PWA icon size the same accross all device densities
Patch Set: Merge branch 'master' into min_size Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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_INSTALLABLE_INSTALLABLE_MANAGER_H_ 5 #ifndef CHROME_BROWSER_INSTALLABLE_INSTALLABLE_MANAGER_H_
6 #define CHROME_BROWSER_INSTALLABLE_INSTALLABLE_MANAGER_H_ 6 #define CHROME_BROWSER_INSTALLABLE_INSTALLABLE_MANAGER_H_
7 7
8 #include <map> 8 #include <map>
9 #include <memory> 9 #include <memory>
10 #include <tuple>
11 #include <utility> 10 #include <utility>
12 #include <vector> 11 #include <vector>
13 12
14 #include "base/callback_forward.h" 13 #include "base/callback_forward.h"
15 #include "base/gtest_prod_util.h" 14 #include "base/gtest_prod_util.h"
16 #include "base/macros.h" 15 #include "base/macros.h"
17 #include "base/memory/weak_ptr.h" 16 #include "base/memory/weak_ptr.h"
18 #include "chrome/browser/installable/installable_logging.h" 17 #include "chrome/browser/installable/installable_logging.h"
19 #include "content/public/browser/service_worker_context.h" 18 #include "content/public/browser/service_worker_context.h"
20 #include "content/public/browser/web_contents_observer.h" 19 #include "content/public/browser/web_contents_observer.h"
21 #include "content/public/browser/web_contents_user_data.h" 20 #include "content/public/browser/web_contents_user_data.h"
22 #include "content/public/common/manifest.h" 21 #include "content/public/common/manifest.h"
23 #include "third_party/skia/include/core/SkBitmap.h" 22 #include "third_party/skia/include/core/SkBitmap.h"
24 #include "url/gurl.h" 23 #include "url/gurl.h"
25 24
26 // This struct specifies the work to be done by the InstallableManager. 25 // This struct specifies the work to be done by the InstallableManager.
27 // Data is cached and fetched in the order specified in this struct. A web app 26 // Data is cached and fetched in the order specified in this struct. A web app
28 // manifest will always be fetched first. 27 // manifest will always be fetched first.
29 struct InstallableParams { 28 struct InstallableParams {
30 // The ideal primary icon size to fetch. Used only if 29 // The ideal primary icon size to fetch. Used only if
31 // |fetch_valid_primary_icon| is true. 30 // |fetch_valid_primary_icon| is true.
32 int ideal_primary_icon_size_in_px = -1; 31 int ideal_primary_icon_size_in_px = -1;
33 32
34 // The minimum primary icon size to fetch. Used only if
35 // |fetch_valid_primary_icon| is true.
36 int minimum_primary_icon_size_in_px = -1;
37
38 // The ideal badge icon size to fetch. Used only if 33 // The ideal badge icon size to fetch. Used only if
39 // |fetch_valid_badge_icon| is true. 34 // |fetch_valid_badge_icon| is true.
40 int ideal_badge_icon_size_in_px = -1; 35 int ideal_badge_icon_size_in_px = -1;
41 36
42 // The minimum badge icon size to fetch. Used only if
43 // |fetch_valid_badge_icon| is true.
44 int minimum_badge_icon_size_in_px = -1;
45
46 // Check whether the site is installable. That is, it has a manifest valid for 37 // Check whether the site is installable. That is, it has a manifest valid for
47 // a web app and a service worker controlling the manifest start URL and the 38 // a web app and a service worker controlling the manifest start URL and the
48 // current URL. 39 // current URL.
49 bool check_installable = false; 40 bool check_installable = false;
50 41
51 // Check whether there is a fetchable, non-empty icon in the manifest 42 // Check whether there is a fetchable, non-empty icon in the manifest
52 // conforming to the primary icon size parameters. 43 // conforming to the primary icon size parameters.
53 bool fetch_valid_primary_icon = false; 44 bool fetch_valid_primary_icon = false;
54 45
55 // Check whether there is a fetchable, non-empty icon in the manifest 46 // Check whether there is a fetchable, non-empty icon in the manifest
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 virtual void GetData(const InstallableParams& params, 119 virtual void GetData(const InstallableParams& params,
129 const InstallableCallback& callback); 120 const InstallableCallback& callback);
130 121
131 private: 122 private:
132 friend class InstallableManagerUnitTest; 123 friend class InstallableManagerUnitTest;
133 FRIEND_TEST_ALL_PREFIXES(InstallableManagerBrowserTest, 124 FRIEND_TEST_ALL_PREFIXES(InstallableManagerBrowserTest,
134 ManagerBeginsInEmptyState); 125 ManagerBeginsInEmptyState);
135 FRIEND_TEST_ALL_PREFIXES(InstallableManagerBrowserTest, CheckWebapp); 126 FRIEND_TEST_ALL_PREFIXES(InstallableManagerBrowserTest, CheckWebapp);
136 127
137 using Task = std::pair<InstallableParams, InstallableCallback>; 128 using Task = std::pair<InstallableParams, InstallableCallback>;
138 using IconParams = std::tuple<int, int, content::Manifest::Icon::IconPurpose>; 129 using IconParams = std::pair<int, content::Manifest::Icon::IconPurpose>;
139 130
140 struct ManifestProperty; 131 struct ManifestProperty;
141 struct InstallableProperty; 132 struct InstallableProperty;
142 struct IconProperty; 133 struct IconProperty;
143 134
144 // Returns an IconParams object that queries for a primary icon conforming to 135 // Returns an IconParams object that queries for a primary icon conforming to
145 // the primary icon size parameters in |params|. 136 // the primary icon size parameters in |params|.
146 IconParams ParamsForPrimaryIcon(const InstallableParams& params) const; 137 IconParams ParamsForPrimaryIcon(const InstallableParams& params) const;
147 // Returns an IconParams object that queries for a badge icon conforming to 138 // Returns an IconParams object that queries for a badge icon conforming to
148 // the badge icon size parameters in |params|. 139 // the badge icon size parameters in |params|.
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
219 std::map<IconParams, IconProperty> icons_; 210 std::map<IconParams, IconProperty> icons_;
220 211
221 bool is_active_; 212 bool is_active_;
222 213
223 base::WeakPtrFactory<InstallableManager> weak_factory_; 214 base::WeakPtrFactory<InstallableManager> weak_factory_;
224 215
225 DISALLOW_COPY_AND_ASSIGN(InstallableManager); 216 DISALLOW_COPY_AND_ASSIGN(InstallableManager);
226 }; 217 };
227 218
228 #endif // CHROME_BROWSER_INSTALLABLE_INSTALLABLE_MANAGER_H_ 219 #endif // CHROME_BROWSER_INSTALLABLE_INSTALLABLE_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698