Chromium Code Reviews| 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" |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 66 }; | 66 }; |
| 67 | 67 |
| 68 // Initialize the fetcher by requesting the information about the page from | 68 // Initialize the fetcher by requesting the information about the page from |
| 69 // the renderer process. The initialization is asynchronous and | 69 // the renderer process. The initialization is asynchronous and |
| 70 // OnDidGetWebApplicationInfo is expected to be called when finished. | 70 // OnDidGetWebApplicationInfo is expected to be called when finished. |
| 71 AddToHomescreenDataFetcher(content::WebContents* web_contents, | 71 AddToHomescreenDataFetcher(content::WebContents* web_contents, |
| 72 int ideal_icon_size_in_dp, | 72 int ideal_icon_size_in_dp, |
| 73 int minimum_icon_size_in_dp, | 73 int minimum_icon_size_in_dp, |
| 74 int ideal_splash_image_size_in_dp, | 74 int ideal_splash_image_size_in_dp, |
| 75 int minimum_splash_image_size_in_dp, | 75 int minimum_splash_image_size_in_dp, |
| 76 bool check_installable, | 76 bool check_webapk_compatible, |
| 77 Observer* observer); | 77 Observer* observer); |
| 78 | 78 |
| 79 // Returns a callback which fetches the splash screen image to be stored for | 79 // Returns a callback which fetches the splash screen image to be stored for |
| 80 // the webapp with the specified |id|. | 80 // the webapp with the specified |id|. |
| 81 base::Closure FetchSplashScreenImageCallback(const std::string& id); | 81 base::Closure FetchSplashScreenImageCallback(const std::string& id); |
| 82 | 82 |
| 83 // IPC message received when the initialization is finished. | 83 // IPC message received when the initialization is finished. |
| 84 void OnDidGetWebApplicationInfo(const WebApplicationInfo& web_app_info); | 84 void OnDidGetWebApplicationInfo(const WebApplicationInfo& web_app_info); |
| 85 | 85 |
| 86 // Accessors, etc. | 86 // Accessors, etc. |
| 87 void set_weak_observer(Observer* observer) { weak_observer_ = observer; } | 87 void set_weak_observer(Observer* observer) { weak_observer_ = observer; } |
| 88 bool is_ready() const { return is_ready_; } | 88 bool is_ready() const { return is_ready_; } |
| 89 ShortcutInfo& shortcut_info() { return shortcut_info_; } | 89 ShortcutInfo& shortcut_info() { return shortcut_info_; } |
| 90 const SkBitmap& shortcut_icon() const { return shortcut_icon_; } | 90 const SkBitmap& shortcut_icon() const { return shortcut_icon_; } |
| 91 | 91 |
| 92 private: | 92 private: |
| 93 friend class base::RefCounted<AddToHomescreenDataFetcher>; | 93 friend class base::RefCounted<AddToHomescreenDataFetcher>; |
| 94 | 94 |
| 95 ~AddToHomescreenDataFetcher() override; | 95 ~AddToHomescreenDataFetcher() override; |
| 96 | 96 |
| 97 // WebContentsObserver | 97 // WebContentsObserver: |
| 98 bool OnMessageReceived(const IPC::Message& message) override; | 98 bool OnMessageReceived(const IPC::Message& message) override; |
| 99 | 99 |
| 100 // Called if either InstallableManager or the favicon fetch takes too long. | |
| 101 void OnTimeout(); | |
|
dominickn
2016/09/19 05:41:44
Nit: call this OnDataTimedout() to match data_time
| |
| 102 | |
| 100 // Called when InstallableManager finishes looking for a manifest and icon. | 103 // Called when InstallableManager finishes looking for a manifest and icon. |
| 101 void OnDidPerformInstallableCheck(const InstallableData& data); | 104 void OnDidPerformInstallableCheck(const InstallableData& data); |
| 102 | 105 |
| 103 // Grabs the favicon for the current URL. | 106 // Grabs the favicon for the current URL. |
| 104 void FetchFavicon(); | 107 void FetchFavicon(); |
| 105 void OnFaviconFetched( | 108 void OnFaviconFetched( |
| 106 const favicon_base::FaviconRawBitmapResult& bitmap_result); | 109 const favicon_base::FaviconRawBitmapResult& bitmap_result); |
| 107 | 110 |
| 108 // Creates the launcher icon from the given bitmap. shortcut_info_.url is | 111 // Creates the launcher icon from the given bitmap. shortcut_info_.url is |
| 109 // used to generate an icon if there is no bitmap in |bitmap_result| or the | 112 // used to generate an icon if there is no bitmap in |bitmap_result| or the |
| 110 // bitmap is not large enough. | 113 // bitmap is not large enough. |
| 111 void CreateLauncherIconFromFaviconInBackground( | 114 void CreateLauncherIconFromFaviconInBackground( |
| 112 const favicon_base::FaviconRawBitmapResult& bitmap_result); | 115 const favicon_base::FaviconRawBitmapResult& bitmap_result); |
| 113 | 116 |
| 114 // Creates the launcher icon from the given |icon|. | 117 // Creates the launcher icon from the given |icon|. |
| 118 void CreateLauncherIcon(const SkBitmap& raw__icon); | |
|
dominickn
2016/09/19 05:41:44
Nit: two underscores in variable name.
Nit: make
pkotwicz
2016/09/19 23:34:02
You've got good eyes!
__fixed__
| |
| 115 void CreateLauncherIconInBackground(const SkBitmap& raw__icon); | 119 void CreateLauncherIconInBackground(const SkBitmap& raw__icon); |
| 116 | 120 |
| 117 // Notifies the observer that the shortcut data is all available. | 121 // Notifies the observer that the shortcut data is all available. |
| 118 void NotifyObserver(const SkBitmap& icon); | 122 void NotifyObserver(const SkBitmap& icon); |
| 119 | 123 |
| 120 Observer* weak_observer_; | 124 Observer* weak_observer_; |
| 121 | 125 |
| 122 // The icon must only be set on the UI thread for thread safety. | 126 // The icon must only be set on the UI thread for thread safety. |
| 123 SkBitmap shortcut_icon_; | 127 SkBitmap shortcut_icon_; |
| 124 ShortcutInfo shortcut_info_; | 128 ShortcutInfo shortcut_info_; |
| 125 GURL splash_screen_url_; | 129 GURL splash_screen_url_; |
| 126 | 130 |
| 127 base::CancelableTaskTracker favicon_task_tracker_; | 131 base::CancelableTaskTracker favicon_task_tracker_; |
| 128 base::Timer data_timeout_timer_; | 132 base::Timer data_timeout_timer_; |
| 129 | 133 |
| 130 const int ideal_icon_size_in_dp_; | 134 const int ideal_icon_size_in_dp_; |
| 131 const int minimum_icon_size_in_dp_; | 135 const int minimum_icon_size_in_dp_; |
| 132 const int ideal_splash_image_size_in_dp_; | 136 const int ideal_splash_image_size_in_dp_; |
| 133 const int minimum_splash_image_size_in_dp_; | 137 const int minimum_splash_image_size_in_dp_; |
| 134 | 138 |
| 135 // Indicates whether to check WebAPK compatibility. | 139 // Indicates whether to check WebAPK compatibility. |
| 136 bool check_installable_; | 140 bool check_webapk_compatibility_; |
| 137 bool is_waiting_for_installable_check_; | |
| 138 bool is_waiting_for_web_application_info_; | 141 bool is_waiting_for_web_application_info_; |
| 142 bool did_installable_check_; | |
|
dominickn
2016/09/19 05:41:44
Nit: is_installable_check_complete_
| |
| 139 bool is_icon_saved_; | 143 bool is_icon_saved_; |
| 140 bool is_ready_; | 144 bool is_ready_; |
| 141 | 145 |
| 142 DISALLOW_COPY_AND_ASSIGN(AddToHomescreenDataFetcher); | 146 DISALLOW_COPY_AND_ASSIGN(AddToHomescreenDataFetcher); |
| 143 }; | 147 }; |
| 144 | 148 |
| 145 #endif // CHROME_BROWSER_ANDROID_WEBAPPS_ADD_TO_HOMESCREEN_DATA_FETCHER_H_ | 149 #endif // CHROME_BROWSER_ANDROID_WEBAPPS_ADD_TO_HOMESCREEN_DATA_FETCHER_H_ |
| OLD | NEW |