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/task/cancelable_task_tracker.h" | 10 #include "base/task/cancelable_task_tracker.h" |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
66 // Returns a callback which fetches the splash screen image to be stored for | 66 // Returns a callback which fetches the splash screen image to be stored for |
67 // the webapp with the specified |id|. | 67 // the webapp with the specified |id|. |
68 base::Closure FetchSplashScreenImageCallback(const std::string& id); | 68 base::Closure FetchSplashScreenImageCallback(const std::string& id); |
69 | 69 |
70 // IPC message received when the initialization is finished. | 70 // IPC message received when the initialization is finished. |
71 void OnDidGetWebApplicationInfo(const WebApplicationInfo& web_app_info); | 71 void OnDidGetWebApplicationInfo(const WebApplicationInfo& web_app_info); |
72 | 72 |
73 // Called when the Manifest has been parsed, or if no Manifest was found. | 73 // Called when the Manifest has been parsed, or if no Manifest was found. |
74 void OnDidGetManifest(const content::Manifest& manifest); | 74 void OnDidGetManifest(const content::Manifest& manifest); |
75 | 75 |
| 76 // Called once it has been determined whether there is a service worker |
| 77 // controlling the page. Only pages controlled by a service worker are |
| 78 // WebAPK-capable. |
| 79 void OnDidCheckServiceWorkerForWebApk(const content::Manifest& manifest, |
| 80 bool has_service_worker); |
| 81 |
| 82 // Called once it has been determined whether a WebAPK should be created for |
| 83 // the page. |
| 84 void OnCheckIsWebApk(const content::Manifest& manifest, bool is_webapk); |
| 85 |
76 // Accessors, etc. | 86 // Accessors, etc. |
77 void set_weak_observer(Observer* observer) { weak_observer_ = observer; } | 87 void set_weak_observer(Observer* observer) { weak_observer_ = observer; } |
78 bool is_ready() { return is_ready_; } | 88 bool is_ready() { return is_ready_; } |
79 ShortcutInfo& shortcut_info() { return shortcut_info_; } | 89 ShortcutInfo& shortcut_info() { return shortcut_info_; } |
80 const SkBitmap& shortcut_icon() { return shortcut_icon_; } | 90 const SkBitmap& shortcut_icon() { return shortcut_icon_; } |
81 | 91 |
82 // WebContentsObserver | 92 // WebContentsObserver |
83 bool OnMessageReceived(const IPC::Message& message) override; | 93 bool OnMessageReceived(const IPC::Message& message) override; |
84 | 94 |
85 private: | 95 private: |
(...skipping 13 matching lines...) Expand all Loading... |
99 void OnManifestIconFetched(const SkBitmap& icon); | 109 void OnManifestIconFetched(const SkBitmap& icon); |
100 | 110 |
101 // Notifies the observer that the shortcut data is all available. | 111 // Notifies the observer that the shortcut data is all available. |
102 void NotifyObserver(const SkBitmap& icon, bool is_generated); | 112 void NotifyObserver(const SkBitmap& icon, bool is_generated); |
103 | 113 |
104 // Looks up the original, online URL of the site requested. The URL from the | 114 // Looks up the original, online URL of the site requested. The URL from the |
105 // WebContents may be an offline page or a distilled article which is not | 115 // WebContents may be an offline page or a distilled article which is not |
106 // appropriate for a home screen shortcut. | 116 // appropriate for a home screen shortcut. |
107 GURL GetShortcutUrl(const GURL& original_url); | 117 GURL GetShortcutUrl(const GURL& original_url); |
108 | 118 |
| 119 // Returns whether a WebAPK can be built for |manifest|. |
| 120 bool IsManifestWebApkCapable(const content::Manifest& manifest) const; |
| 121 |
109 Observer* weak_observer_; | 122 Observer* weak_observer_; |
110 | 123 |
111 bool is_waiting_for_web_application_info_; | 124 bool is_waiting_for_web_application_info_; |
112 bool is_icon_saved_; | 125 bool is_icon_saved_; |
113 bool is_ready_; | 126 bool is_ready_; |
114 base::Timer icon_timeout_timer_; | 127 base::Timer icon_timeout_timer_; |
| 128 |
| 129 // The web page's current URL. |
| 130 GURL shortcut_url_; |
| 131 |
115 ShortcutInfo shortcut_info_; | 132 ShortcutInfo shortcut_info_; |
116 GURL splash_screen_url_; | 133 GURL splash_screen_url_; |
117 | 134 |
118 // The icon must only be set on the UI thread for thread safety. | 135 // The icon must only be set on the UI thread for thread safety. |
119 SkBitmap shortcut_icon_; | 136 SkBitmap shortcut_icon_; |
120 base::CancelableTaskTracker favicon_task_tracker_; | 137 base::CancelableTaskTracker favicon_task_tracker_; |
121 | 138 |
122 const int ideal_icon_size_in_dp_; | 139 const int ideal_icon_size_in_dp_; |
123 const int minimum_icon_size_in_dp_; | 140 const int minimum_icon_size_in_dp_; |
124 const int ideal_splash_image_size_in_dp_; | 141 const int ideal_splash_image_size_in_dp_; |
125 const int minimum_splash_image_size_in_dp_; | 142 const int minimum_splash_image_size_in_dp_; |
126 | 143 |
127 friend class base::RefCounted<AddToHomescreenDataFetcher>; | 144 friend class base::RefCounted<AddToHomescreenDataFetcher>; |
128 DISALLOW_COPY_AND_ASSIGN(AddToHomescreenDataFetcher); | 145 DISALLOW_COPY_AND_ASSIGN(AddToHomescreenDataFetcher); |
129 }; | 146 }; |
130 | 147 |
131 #endif // CHROME_BROWSER_ANDROID_WEBAPPS_ADD_TO_HOMESCREEN_DATA_FETCHER_H_ | 148 #endif // CHROME_BROWSER_ANDROID_WEBAPPS_ADD_TO_HOMESCREEN_DATA_FETCHER_H_ |
OLD | NEW |