| 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/callback_forward.h" | 8 #include "base/callback_forward.h" |
| 9 #include "base/macros.h" | 9 #include "base/macros.h" |
| 10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
| 11 #include "base/task/cancelable_task_tracker.h" | 11 #include "base/task/cancelable_task_tracker.h" |
| 12 #include "base/timer/timer.h" | 12 #include "base/timer/timer.h" |
| 13 #include "chrome/browser/android/shortcut_info.h" | 13 #include "chrome/browser/android/shortcut_info.h" |
| 14 #include "content/public/browser/web_contents_observer.h" | 14 #include "content/public/browser/web_contents_observer.h" |
| 15 #include "third_party/skia/include/core/SkBitmap.h" | 15 #include "third_party/skia/include/core/SkBitmap.h" |
| 16 | 16 |
| 17 namespace base { |
| 18 class TaskRunner; |
| 19 } |
| 20 |
| 17 namespace content { | 21 namespace content { |
| 18 class WebContents; | 22 class WebContents; |
| 19 } | 23 } |
| 20 | 24 |
| 21 namespace favicon_base { | 25 namespace favicon_base { |
| 22 struct FaviconRawBitmapResult; | 26 struct FaviconRawBitmapResult; |
| 23 } | 27 } |
| 24 | 28 |
| 25 namespace IPC { | 29 namespace IPC { |
| 26 class Message; | 30 class Message; |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 107 void OnDidPerformInstallableCheck(const InstallableData& data); | 111 void OnDidPerformInstallableCheck(const InstallableData& data); |
| 108 | 112 |
| 109 // Grabs the favicon for the current URL. | 113 // Grabs the favicon for the current URL. |
| 110 void FetchFavicon(); | 114 void FetchFavicon(); |
| 111 void OnFaviconFetched( | 115 void OnFaviconFetched( |
| 112 const favicon_base::FaviconRawBitmapResult& bitmap_result); | 116 const favicon_base::FaviconRawBitmapResult& bitmap_result); |
| 113 | 117 |
| 114 // Creates the launcher icon from the given bitmap. shortcut_info_.url is | 118 // Creates the launcher icon from the given bitmap. shortcut_info_.url is |
| 115 // used to generate an icon if there is no bitmap in |bitmap_result| or the | 119 // used to generate an icon if there is no bitmap in |bitmap_result| or the |
| 116 // bitmap is not large enough. | 120 // bitmap is not large enough. |
| 117 void CreateLauncherIconFromFaviconInBackground( | 121 SkBitmap CreateLauncherIconFromFaviconInBackground( |
| 118 const favicon_base::FaviconRawBitmapResult& bitmap_result); | 122 const favicon_base::FaviconRawBitmapResult& bitmap_result); |
| 119 | 123 |
| 120 // Creates the launcher icon from the given |raw_icon|. | 124 // Creates the launcher icon from the given |raw_icon|. |
| 121 void CreateLauncherIcon(const SkBitmap& raw_icon); | 125 void CreateLauncherIcon(const SkBitmap& raw_icon); |
| 122 void CreateLauncherIconInBackground(const SkBitmap& raw_icon); | 126 SkBitmap CreateLauncherIconInBackground(const SkBitmap& raw_icon); |
| 123 | 127 |
| 124 // Notifies the observer that the shortcut data is all available. | 128 // Notifies the observer that the shortcut data is all available. |
| 125 void NotifyObserver(const SkBitmap& icon); | 129 void NotifyObserver(const SkBitmap& icon); |
| 126 | 130 |
| 131 scoped_refptr<base::TaskRunner> background_task_runner_; |
| 132 |
| 127 Observer* weak_observer_; | 133 Observer* weak_observer_; |
| 128 | 134 |
| 129 // The icons must only be set on the UI thread for thread safety. | 135 // The icons must only be set on the UI thread for thread safety. |
| 130 SkBitmap badge_icon_; | 136 SkBitmap badge_icon_; |
| 131 SkBitmap primary_icon_; | 137 SkBitmap primary_icon_; |
| 132 ShortcutInfo shortcut_info_; | 138 ShortcutInfo shortcut_info_; |
| 133 GURL splash_screen_url_; | 139 GURL splash_screen_url_; |
| 134 | 140 |
| 135 base::CancelableTaskTracker favicon_task_tracker_; | 141 base::CancelableTaskTracker favicon_task_tracker_; |
| 136 base::Timer data_timeout_timer_; | 142 base::Timer data_timeout_timer_; |
| 137 | 143 |
| 138 const int ideal_icon_size_in_px_; | 144 const int ideal_icon_size_in_px_; |
| 139 const int minimum_icon_size_in_px_; | 145 const int minimum_icon_size_in_px_; |
| 140 const int ideal_splash_image_size_in_px_; | 146 const int ideal_splash_image_size_in_px_; |
| 141 const int minimum_splash_image_size_in_px_; | 147 const int minimum_splash_image_size_in_px_; |
| 142 const int badge_size_in_px_; | 148 const int badge_size_in_px_; |
| 143 | 149 |
| 144 // Indicates whether to check WebAPK compatibility. | 150 // Indicates whether to check WebAPK compatibility. |
| 145 bool check_webapk_compatibility_; | 151 bool check_webapk_compatibility_; |
| 146 bool is_waiting_for_web_application_info_; | 152 bool is_waiting_for_web_application_info_; |
| 147 bool is_installable_check_complete_; | 153 bool is_installable_check_complete_; |
| 148 bool is_icon_saved_; | 154 bool is_icon_saved_; |
| 149 bool is_ready_; | 155 bool is_ready_; |
| 150 | 156 |
| 151 DISALLOW_COPY_AND_ASSIGN(AddToHomescreenDataFetcher); | 157 DISALLOW_COPY_AND_ASSIGN(AddToHomescreenDataFetcher); |
| 152 }; | 158 }; |
| 153 | 159 |
| 154 #endif // CHROME_BROWSER_ANDROID_WEBAPPS_ADD_TO_HOMESCREEN_DATA_FETCHER_H_ | 160 #endif // CHROME_BROWSER_ANDROID_WEBAPPS_ADD_TO_HOMESCREEN_DATA_FETCHER_H_ |
| OLD | NEW |