Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(199)

Side by Side Diff: chrome/browser/android/webapps/add_to_homescreen_data_fetcher.cc

Issue 2342183002: Call AddToHomescreenDataFetcher::Observer callbacks when manifest fetch times out (Closed)
Patch Set: Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « chrome/browser/android/webapps/add_to_homescreen_data_fetcher.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #include "chrome/browser/android/webapps/add_to_homescreen_data_fetcher.h" 5 #include "chrome/browser/android/webapps/add_to_homescreen_data_fetcher.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/callback.h" 10 #include "base/callback.h"
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 : WebContentsObserver(web_contents), 78 : WebContentsObserver(web_contents),
79 weak_observer_(observer), 79 weak_observer_(observer),
80 shortcut_info_(GetShortcutUrl(web_contents->GetBrowserContext(), 80 shortcut_info_(GetShortcutUrl(web_contents->GetBrowserContext(),
81 web_contents->GetLastCommittedURL())), 81 web_contents->GetLastCommittedURL())),
82 data_timeout_timer_(false, false), 82 data_timeout_timer_(false, false),
83 ideal_icon_size_in_dp_(ideal_icon_size_in_dp), 83 ideal_icon_size_in_dp_(ideal_icon_size_in_dp),
84 minimum_icon_size_in_dp_(minimum_icon_size_in_dp), 84 minimum_icon_size_in_dp_(minimum_icon_size_in_dp),
85 ideal_splash_image_size_in_dp_(ideal_splash_image_size_in_dp), 85 ideal_splash_image_size_in_dp_(ideal_splash_image_size_in_dp),
86 minimum_splash_image_size_in_dp_(minimum_splash_image_size_in_dp), 86 minimum_splash_image_size_in_dp_(minimum_splash_image_size_in_dp),
87 check_installable_(check_installable), 87 check_installable_(check_installable),
88 is_waiting_for_installable_check_(check_installable),
89 is_waiting_for_web_application_info_(true), 88 is_waiting_for_web_application_info_(true),
90 is_icon_saved_(false), 89 is_icon_saved_(false),
91 is_ready_(false) { 90 is_ready_(false) {
92 DCHECK(minimum_icon_size_in_dp <= ideal_icon_size_in_dp); 91 DCHECK(minimum_icon_size_in_dp <= ideal_icon_size_in_dp);
93 DCHECK(minimum_splash_image_size_in_dp <= ideal_splash_image_size_in_dp); 92 DCHECK(minimum_splash_image_size_in_dp <= ideal_splash_image_size_in_dp);
94 93
95 // Send a message to the renderer to retrieve information about the page. 94 // Send a message to the renderer to retrieve information about the page.
96 Send(new ChromeViewMsg_GetWebApplicationInfo(routing_id())); 95 Send(new ChromeViewMsg_GetWebApplicationInfo(routing_id()));
97 } 96 }
98 97
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
156 base::Bind(&AddToHomescreenDataFetcher::OnDidPerformInstallableCheck, 155 base::Bind(&AddToHomescreenDataFetcher::OnDidPerformInstallableCheck,
157 this)); 156 this));
158 } 157 }
159 158
160 void AddToHomescreenDataFetcher::OnDidPerformInstallableCheck( 159 void AddToHomescreenDataFetcher::OnDidPerformInstallableCheck(
161 const InstallableData& data) { 160 const InstallableData& data) {
162 if (!web_contents() || !weak_observer_) 161 if (!web_contents() || !weak_observer_)
163 return; 162 return;
164 163
165 if (check_installable_) { 164 if (check_installable_) {
166 is_waiting_for_installable_check_ = false;
167 weak_observer_->OnDidDetermineWebApkCompatibility(data.is_installable); 165 weak_observer_->OnDidDetermineWebApkCompatibility(data.is_installable);
168 } 166 }
169 167
170 if (!data.manifest.IsEmpty()) { 168 if (!data.manifest.IsEmpty()) {
171 content::RecordAction( 169 content::RecordAction(
172 base::UserMetricsAction("webapps.AddShortcut.Manifest")); 170 base::UserMetricsAction("webapps.AddShortcut.Manifest"));
173 shortcut_info_.UpdateFromManifest(data.manifest); 171 shortcut_info_.UpdateFromManifest(data.manifest);
174 shortcut_info_.manifest_url = data.manifest_url; 172 shortcut_info_.manifest_url = data.manifest_url;
175 } 173 }
176 174
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
223 const std::string& webapp_id) { 221 const std::string& webapp_id) {
224 return base::Bind(&ShortcutHelper::FetchSplashScreenImage, web_contents(), 222 return base::Bind(&ShortcutHelper::FetchSplashScreenImage, web_contents(),
225 splash_screen_url_, ideal_splash_image_size_in_dp_, 223 splash_screen_url_, ideal_splash_image_size_in_dp_,
226 minimum_splash_image_size_in_dp_, webapp_id); 224 minimum_splash_image_size_in_dp_, webapp_id);
227 } 225 }
228 226
229 void AddToHomescreenDataFetcher::FetchFavicon() { 227 void AddToHomescreenDataFetcher::FetchFavicon() {
230 if (!web_contents() || !weak_observer_) 228 if (!web_contents() || !weak_observer_)
231 return; 229 return;
232 230
233 if (check_installable_ && is_waiting_for_installable_check_) {
pkotwicz 2016/09/15 22:44:41 I don't see how this if() statement evaluates to t
234 is_waiting_for_installable_check_ = false;
235 weak_observer_->OnDidDetermineWebApkCompatibility(false);
236 }
237
238 // Grab the best, largest icon we can find to represent this bookmark. 231 // Grab the best, largest icon we can find to represent this bookmark.
239 // TODO(dfalcantara): Try combining with the new BookmarksHandler once its 232 // TODO(dfalcantara): Try combining with the new BookmarksHandler once its
240 // rewrite is further along. 233 // rewrite is further along.
241 std::vector<int> icon_types{ 234 std::vector<int> icon_types{
242 favicon_base::FAVICON, 235 favicon_base::FAVICON,
243 favicon_base::TOUCH_PRECOMPOSED_ICON | favicon_base::TOUCH_ICON}; 236 favicon_base::TOUCH_PRECOMPOSED_ICON | favicon_base::TOUCH_ICON};
244 237
245 favicon::FaviconService* favicon_service = 238 favicon::FaviconService* favicon_service =
246 FaviconServiceFactory::GetForProfile( 239 FaviconServiceFactory::GetForProfile(
247 Profile::FromBrowserContext(web_contents()->GetBrowserContext()), 240 Profile::FromBrowserContext(web_contents()->GetBrowserContext()),
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
307 void AddToHomescreenDataFetcher::NotifyObserver(const SkBitmap& icon) { 300 void AddToHomescreenDataFetcher::NotifyObserver(const SkBitmap& icon) {
308 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 301 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
309 if (!web_contents() || !weak_observer_ || is_icon_saved_) 302 if (!web_contents() || !weak_observer_ || is_icon_saved_)
310 return; 303 return;
311 304
312 is_icon_saved_ = true; 305 is_icon_saved_ = true;
313 shortcut_icon_ = icon; 306 shortcut_icon_ = icon;
314 is_ready_ = true; 307 is_ready_ = true;
315 weak_observer_->OnDataAvailable(shortcut_info_, shortcut_icon_); 308 weak_observer_->OnDataAvailable(shortcut_info_, shortcut_icon_);
316 } 309 }
OLDNEW
« no previous file with comments | « chrome/browser/android/webapps/add_to_homescreen_data_fetcher.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698