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

Side by Side Diff: chrome/browser/banners/app_banner_data_fetcher.cc

Issue 2064943002: Pass in extra parameters to WebApkBuilder#buildWebApkAsync() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Merge branch 'master' into webapk_manifest Created 4 years, 6 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
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/banners/app_banner_data_fetcher.h" 5 #include "chrome/browser/banners/app_banner_data_fetcher.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/lazy_instance.h" 9 #include "base/lazy_instance.h"
10 #include "base/strings/string_number_conversions.h" 10 #include "base/strings/string_number_conversions.h"
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
195 return; 195 return;
196 } 196 }
197 197
198 AppBannerSettingsHelper::RecordMinutesFromFirstVisitToShow( 198 AppBannerSettingsHelper::RecordMinutesFromFirstVisitToShow(
199 web_contents, validated_url_, GetAppIdentifier(), GetCurrentTime()); 199 web_contents, validated_url_, GetAppIdentifier(), GetCurrentTime());
200 200
201 // Definitely going to show the banner now. 201 // Definitely going to show the banner now.
202 FOR_EACH_OBSERVER(Observer, observer_list_, 202 FOR_EACH_OBSERVER(Observer, observer_list_,
203 OnDecidedWhetherToShow(this, true)); 203 OnDecidedWhetherToShow(this, true));
204 204
205 ShowBanner(app_icon_.get(), app_title_, referrer); 205 ShowBanner(app_icon_url_, app_icon_.get(), app_title_, referrer);
206 is_active_ = false; 206 is_active_ = false;
207 } 207 }
208 208
209 void AppBannerDataFetcher::OnRequestShowAppBanner( 209 void AppBannerDataFetcher::OnRequestShowAppBanner(
210 content::RenderFrameHost* render_frame_host, 210 content::RenderFrameHost* render_frame_host,
211 int request_id) { 211 int request_id) {
212 if (was_canceled_by_page_) { 212 if (was_canceled_by_page_) {
213 // Simulate an "OK" from the website to restart the banner display pipeline. 213 // Simulate an "OK" from the website to restart the banner display pipeline.
214 was_canceled_by_page_ = false; 214 was_canceled_by_page_ = false;
215 OnBannerPromptReply(render_frame_host, request_id, 215 OnBannerPromptReply(render_frame_host, request_id,
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
368 } 368 }
369 369
370 bool AppBannerDataFetcher::FetchAppIcon(content::WebContents* web_contents, 370 bool AppBannerDataFetcher::FetchAppIcon(content::WebContents* web_contents,
371 const GURL& icon_url) { 371 const GURL& icon_url) {
372 return ManifestIconDownloader::Download( 372 return ManifestIconDownloader::Download(
373 web_contents, 373 web_contents,
374 icon_url, 374 icon_url,
375 ideal_icon_size_in_dp_, 375 ideal_icon_size_in_dp_,
376 minimum_icon_size_in_dp_, 376 minimum_icon_size_in_dp_,
377 base::Bind(&AppBannerDataFetcher::OnAppIconFetched, 377 base::Bind(&AppBannerDataFetcher::OnAppIconFetched,
378 this)); 378 this, icon_url));
379 } 379 }
380 380
381 void AppBannerDataFetcher::OnAppIconFetched(const SkBitmap& bitmap) { 381 void AppBannerDataFetcher::OnAppIconFetched(const GURL& icon_url,
382 const SkBitmap& bitmap) {
382 if (!is_active_) return; 383 if (!is_active_) return;
383 384
384 content::WebContents* web_contents = GetWebContents(); 385 content::WebContents* web_contents = GetWebContents();
385 if (!CheckFetcherIsStillAlive(web_contents)) { 386 if (!CheckFetcherIsStillAlive(web_contents)) {
386 Cancel(); 387 Cancel();
387 return; 388 return;
388 } 389 }
389 if (bitmap.drawsNothing()) { 390 if (bitmap.drawsNothing()) {
390 OutputDeveloperNotShownMessage(web_contents, kNoIconAvailable, 391 OutputDeveloperNotShownMessage(web_contents, kNoIconAvailable,
391 is_debug_mode_); 392 is_debug_mode_);
392 Cancel(); 393 Cancel();
393 return; 394 return;
394 } 395 }
395 396
396 RecordCouldShowBanner(); 397 RecordCouldShowBanner();
397 if (!is_debug_mode_ && !CheckIfShouldShowBanner()) { 398 if (!is_debug_mode_ && !CheckIfShouldShowBanner()) {
398 // At this point, the only possible case is that the banner has been added 399 // At this point, the only possible case is that the banner has been added
399 // to the homescreen, given all of the other checks that have been made. 400 // to the homescreen, given all of the other checks that have been made.
400 Cancel(); 401 Cancel();
401 return; 402 return;
402 } 403 }
403 404
405 app_icon_url_ = icon_url;
dominickn 2016/06/16 21:16:36 Can this be done in FetchAppIcon(), so that it doe
404 app_icon_.reset(new SkBitmap(bitmap)); 406 app_icon_.reset(new SkBitmap(bitmap));
405 event_request_id_ = ++gCurrentRequestID; 407 event_request_id_ = ++gCurrentRequestID;
406 web_contents->GetMainFrame()->Send( 408 web_contents->GetMainFrame()->Send(
407 new ChromeViewMsg_AppBannerPromptRequest( 409 new ChromeViewMsg_AppBannerPromptRequest(
408 web_contents->GetMainFrame()->GetRoutingID(), 410 web_contents->GetMainFrame()->GetRoutingID(),
409 event_request_id_, 411 event_request_id_,
410 GetBannerType())); 412 GetBannerType()));
411 } 413 }
412 414
413 bool AppBannerDataFetcher::IsWebAppInstalled( 415 bool AppBannerDataFetcher::IsWebAppInstalled(
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
479 481
480 if (!DoesManifestContainRequiredIcon(manifest)) { 482 if (!DoesManifestContainRequiredIcon(manifest)) {
481 OutputDeveloperNotShownMessage(web_contents, kManifestMissingSuitableIcon, 483 OutputDeveloperNotShownMessage(web_contents, kManifestMissingSuitableIcon,
482 is_debug_mode); 484 is_debug_mode);
483 return false; 485 return false;
484 } 486 }
485 return true; 487 return true;
486 } 488 }
487 489
488 } // namespace banners 490 } // namespace banners
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698