OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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_ANDROID_WEBAPPS_ADD_TO_HOMESCREEN_DATA_FETCHER_H_ | 5 #ifndef CHROME_BROWSER_ANDROID_WEBAPPS_ADD_TO_HOMESCREEN_DATA_FETCHER_H_ |
6 #define CHROME_BROWSER_ANDROID_WEBAPPS_ADD_TO_HOMESCREEN_DATA_FETCHER_H_ | 6 #define CHROME_BROWSER_ANDROID_WEBAPPS_ADD_TO_HOMESCREEN_DATA_FETCHER_H_ |
7 | 7 |
8 #include "base/macros.h" | 8 #include "base/macros.h" |
9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
10 #include "base/task/cancelable_task_tracker.h" | 10 #include "base/task/cancelable_task_tracker.h" |
(...skipping 12 matching lines...) Expand all Loading... |
23 | 23 |
24 namespace favicon_base { | 24 namespace favicon_base { |
25 struct FaviconRawBitmapResult; | 25 struct FaviconRawBitmapResult; |
26 } | 26 } |
27 | 27 |
28 namespace IPC { | 28 namespace IPC { |
29 class Message; | 29 class Message; |
30 } | 30 } |
31 | 31 |
32 class GURL; | 32 class GURL; |
| 33 class InstallableManager; |
33 struct InstallableData; | 34 struct InstallableData; |
34 struct WebApplicationInfo; | 35 struct WebApplicationInfo; |
35 | 36 |
36 // Aysnchronously fetches and processes data needed to create a shortcut for an | 37 // Aysnchronously fetches and processes data needed to create a shortcut for an |
37 // Android Home screen launcher. | 38 // Android Home screen launcher. |
38 // | 39 // |
39 // Because of the various asynchronous calls made by this class, it is | 40 // Because of the various asynchronous calls made by this class, it is |
40 // refcounted to prevent the class from being prematurely deleted. If the | 41 // refcounted to prevent the class from being prematurely deleted. If the |
41 // pointer to the ShortcutHelper becomes invalid, the pipeline should kill | 42 // |weak_observer| pointer becomes invalid, the pipeline should kill itself. |
42 // itself. | |
43 class AddToHomescreenDataFetcher | 43 class AddToHomescreenDataFetcher |
44 : public base::RefCounted<AddToHomescreenDataFetcher>, | 44 : public base::RefCounted<AddToHomescreenDataFetcher>, |
45 public content::WebContentsObserver { | 45 public content::WebContentsObserver { |
46 public: | 46 public: |
47 class Observer { | 47 class Observer { |
48 public: | 48 public: |
49 // Callded when the installable check is compelte. | 49 // Callded when the installable check is compelte. |
50 virtual void OnDidDetermineWebApkCompatibility( | 50 virtual void OnDidDetermineWebApkCompatibility( |
51 bool is_webapk_compatible) = 0; | 51 bool is_webapk_compatible) = 0; |
52 | 52 |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
95 | 95 |
96 ~AddToHomescreenDataFetcher() override; | 96 ~AddToHomescreenDataFetcher() override; |
97 | 97 |
98 // WebContentsObserver: | 98 // WebContentsObserver: |
99 bool OnMessageReceived(const IPC::Message& message) override; | 99 bool OnMessageReceived(const IPC::Message& message) override; |
100 | 100 |
101 // Called if either InstallableManager or the favicon fetch takes too long. | 101 // Called if either InstallableManager or the favicon fetch takes too long. |
102 void OnDataTimedout(); | 102 void OnDataTimedout(); |
103 | 103 |
104 // Called when InstallableManager finishes looking for a manifest and icon. | 104 // Called when InstallableManager finishes looking for a manifest and icon. |
| 105 void OnDidGetManifestAndIcon(const InstallableData& data); |
| 106 |
| 107 // Called when InstallableManager finishes checking for installability. |
105 void OnDidPerformInstallableCheck(const InstallableData& data); | 108 void OnDidPerformInstallableCheck(const InstallableData& data); |
106 | 109 |
107 // Grabs the favicon for the current URL. | 110 // Grabs the favicon for the current URL. |
108 void FetchFavicon(); | 111 void FetchFavicon(); |
109 void OnFaviconFetched( | 112 void OnFaviconFetched( |
110 const favicon_base::FaviconRawBitmapResult& bitmap_result); | 113 const favicon_base::FaviconRawBitmapResult& bitmap_result); |
111 | 114 |
112 // Creates the launcher icon from the given bitmap. shortcut_info_.url is | 115 // Creates the launcher icon from the given bitmap. shortcut_info_.url is |
113 // used to generate an icon if there is no bitmap in |bitmap_result| or the | 116 // used to generate an icon if there is no bitmap in |bitmap_result| or the |
114 // bitmap is not large enough. | 117 // bitmap is not large enough. |
115 SkBitmap CreateLauncherIconFromFaviconInBackground( | 118 SkBitmap CreateLauncherIconFromFaviconInBackground( |
116 const favicon_base::FaviconRawBitmapResult& bitmap_result); | 119 const favicon_base::FaviconRawBitmapResult& bitmap_result); |
117 | 120 |
118 // Creates the launcher icon from the given |raw_icon|. | 121 // Creates the launcher icon from the given |raw_icon|. |
119 void CreateLauncherIcon(const SkBitmap& raw_icon); | 122 void CreateLauncherIcon(const SkBitmap& raw_icon); |
120 SkBitmap CreateLauncherIconInBackground(const SkBitmap& raw_icon); | 123 SkBitmap CreateLauncherIconInBackground(const SkBitmap& raw_icon); |
121 | 124 |
122 // Notifies the observer that the shortcut data is all available. | 125 // Notifies the observer that the shortcut data is all available. |
123 void NotifyObserver(const SkBitmap& icon); | 126 void NotifyObserver(const SkBitmap& icon); |
124 | 127 |
125 scoped_refptr<base::TaskRunner> background_task_runner_; | 128 scoped_refptr<base::TaskRunner> background_task_runner_; |
126 | 129 |
| 130 InstallableManager* installable_manager_; |
127 Observer* weak_observer_; | 131 Observer* weak_observer_; |
128 | 132 |
129 // The icons must only be set on the UI thread for thread safety. | 133 // The icons must only be set on the UI thread for thread safety. |
130 SkBitmap badge_icon_; | 134 SkBitmap badge_icon_; |
131 SkBitmap primary_icon_; | 135 SkBitmap primary_icon_; |
132 ShortcutInfo shortcut_info_; | 136 ShortcutInfo shortcut_info_; |
133 | 137 |
134 base::CancelableTaskTracker favicon_task_tracker_; | 138 base::CancelableTaskTracker favicon_task_tracker_; |
135 base::OneShotTimer data_timeout_timer_; | 139 base::OneShotTimer data_timeout_timer_; |
136 | 140 |
137 const int ideal_icon_size_in_px_; | 141 const int ideal_icon_size_in_px_; |
138 const int minimum_icon_size_in_px_; | 142 const int minimum_icon_size_in_px_; |
139 const int ideal_splash_image_size_in_px_; | 143 const int ideal_splash_image_size_in_px_; |
140 const int minimum_splash_image_size_in_px_; | 144 const int minimum_splash_image_size_in_px_; |
141 const int badge_size_in_px_; | 145 const int badge_size_in_px_; |
142 | 146 |
143 // Indicates whether to check WebAPK compatibility. | 147 // Indicates whether to check WebAPK compatibility. |
144 bool check_webapk_compatibility_; | 148 bool check_webapk_compatibility_; |
145 bool is_waiting_for_web_application_info_; | 149 bool is_waiting_for_web_application_info_; |
146 bool is_installable_check_complete_; | 150 bool is_installable_check_complete_; |
147 bool is_icon_saved_; | 151 bool is_icon_saved_; |
148 | 152 |
149 DISALLOW_COPY_AND_ASSIGN(AddToHomescreenDataFetcher); | 153 DISALLOW_COPY_AND_ASSIGN(AddToHomescreenDataFetcher); |
150 }; | 154 }; |
151 | 155 |
152 #endif // CHROME_BROWSER_ANDROID_WEBAPPS_ADD_TO_HOMESCREEN_DATA_FETCHER_H_ | 156 #endif // CHROME_BROWSER_ANDROID_WEBAPPS_ADD_TO_HOMESCREEN_DATA_FETCHER_H_ |
OLD | NEW |