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