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

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

Issue 2589503002: Use exact pixel sizes instead of dip in webapp/WebAPK installability code (Closed)
Patch Set: Merge branch 'master' into dp_px Created 4 years 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 <utility> 10 #include <utility>
11 #include <vector> 11 #include <vector>
12 12
13 #include "base/callback_forward.h" 13 #include "base/callback_forward.h"
14 #include "base/gtest_prod_util.h" 14 #include "base/gtest_prod_util.h"
15 #include "base/macros.h" 15 #include "base/macros.h"
16 #include "base/memory/weak_ptr.h" 16 #include "base/memory/weak_ptr.h"
17 #include "chrome/browser/installable/installable_logging.h" 17 #include "chrome/browser/installable/installable_logging.h"
18 #include "content/public/browser/web_contents_observer.h" 18 #include "content/public/browser/web_contents_observer.h"
19 #include "content/public/browser/web_contents_user_data.h" 19 #include "content/public/browser/web_contents_user_data.h"
20 #include "content/public/common/manifest.h" 20 #include "content/public/common/manifest.h"
21 #include "third_party/skia/include/core/SkBitmap.h" 21 #include "third_party/skia/include/core/SkBitmap.h"
22 #include "url/gurl.h" 22 #include "url/gurl.h"
23 23
24 // This struct specifies the work to be done by the InstallableManager. 24 // This struct specifies the work to be done by the InstallableManager.
25 // Data is cached and fetched in the order specified in this struct. A web app 25 // Data is cached and fetched in the order specified in this struct. A web app
26 // manifest will always be fetched first. 26 // manifest will always be fetched first.
27 struct InstallableParams { 27 struct InstallableParams {
28 // The ideal icon size to fetch. Used only if |fetch_valid_icon| is true. 28 // The ideal icon size to fetch. Used only if |fetch_valid_icon| is true.
29 int ideal_icon_size_in_dp = -1; 29 int ideal_icon_size_in_px = -1;
30 30
31 // The minimum icon size to fetch. Used only if |fetch_valid_icon| is true. 31 // The minimum icon size to fetch. Used only if |fetch_valid_icon| is true.
32 int minimum_icon_size_in_dp = -1; 32 int minimum_icon_size_in_px = -1;
33 33
34 // Check whether the site is installable. That is, it has a manifest valid for 34 // Check whether the site is installable. That is, it has a manifest valid for
35 // a web app and a service worker controlling the manifest start URL and the 35 // a web app and a service worker controlling the manifest start URL and the
36 // current URL. 36 // current URL.
37 bool check_installable = false; 37 bool check_installable = false;
38 38
39 // Check whether there is an icon in the manifest conforming to the icon size 39 // Check whether there is an icon in the manifest conforming to the icon size
40 // parameters, and that the icon can be fetched and isn't an empty bitmap. 40 // parameters, and that the icon can be fetched and isn't an empty bitmap.
41 bool fetch_valid_icon = false; 41 bool fetch_valid_icon = false;
42 }; 42 };
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 // This class is responsible for fetching the resources required to check and 75 // This class is responsible for fetching the resources required to check and
76 // install a site. 76 // install a site.
77 class InstallableManager 77 class InstallableManager
78 : public content::WebContentsObserver, 78 : public content::WebContentsObserver,
79 public content::WebContentsUserData<InstallableManager> { 79 public content::WebContentsUserData<InstallableManager> {
80 public: 80 public:
81 explicit InstallableManager(content::WebContents* web_contents); 81 explicit InstallableManager(content::WebContents* web_contents);
82 ~InstallableManager() override; 82 ~InstallableManager() override;
83 83
84 // Returns the minimum icon size in pixels for a site to be installable. 84 // Returns the minimum icon size in pixels for a site to be installable.
85 // TODO(dominickn): consolidate this concept with minimum_icon_size_in_dp 85 // TODO(dominickn): consolidate this concept with minimum_icon_size_in_px
86 // across all platforms. 86 // across all platforms.
87 static int GetMinimumIconSizeInPx(); 87 static int GetMinimumIconSizeInPx();
88 88
89 // Get the installable data, fetching the resources specified in |params|. 89 // Get the installable data, fetching the resources specified in |params|.
90 // |callback| is invoked synchronously (i.e. no via PostTask on the UI thread 90 // |callback| is invoked synchronously (i.e. no via PostTask on the UI thread
91 // when the data is ready; the synchronous execution ensures that the 91 // when the data is ready; the synchronous execution ensures that the
92 // references |callback| receives in its InstallableData argument are valid. 92 // references |callback| receives in its InstallableData argument are valid.
93 // 93 //
94 // Calls requesting data that is already fetched will return the cached data. 94 // Calls requesting data that is already fetched will return the cached data.
95 // This method is marked virtual so clients may mock this object in tests. 95 // This method is marked virtual so clients may mock this object in tests.
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 std::map<IconParams, IconProperty> icons_; 182 std::map<IconParams, IconProperty> icons_;
183 183
184 bool is_active_; 184 bool is_active_;
185 185
186 base::WeakPtrFactory<InstallableManager> weak_factory_; 186 base::WeakPtrFactory<InstallableManager> weak_factory_;
187 187
188 DISALLOW_COPY_AND_ASSIGN(InstallableManager); 188 DISALLOW_COPY_AND_ASSIGN(InstallableManager);
189 }; 189 };
190 190
191 #endif // CHROME_BROWSER_INSTALLABLE_INSTALLABLE_MANAGER_H_ 191 #endif // CHROME_BROWSER_INSTALLABLE_INSTALLABLE_MANAGER_H_
OLDNEW
« no previous file with comments | « chrome/browser/banners/app_banner_manager.cc ('k') | chrome/browser/installable/installable_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698