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

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

Issue 1310223002: webapps: initial addition of splash screen icon downloading (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@webapps-database-exp
Patch Set: Fix compile Created 5 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
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/strings/string_util.h" 9 #include "base/strings/string_util.h"
10 #include "base/strings/utf_string_conversions.h" 10 #include "base/strings/utf_string_conversions.h"
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 } 67 }
68 68
69 // static 69 // static
70 void AppBannerDataFetcher::SetTimeDeltaForTesting(int days) { 70 void AppBannerDataFetcher::SetTimeDeltaForTesting(int days) {
71 gTimeDeltaForTesting = base::TimeDelta::FromDays(days); 71 gTimeDeltaForTesting = base::TimeDelta::FromDays(days);
72 } 72 }
73 73
74 AppBannerDataFetcher::AppBannerDataFetcher( 74 AppBannerDataFetcher::AppBannerDataFetcher(
75 content::WebContents* web_contents, 75 content::WebContents* web_contents,
76 base::WeakPtr<Delegate> delegate, 76 base::WeakPtr<Delegate> delegate,
77 int ideal_icon_size) 77 int ideal_icon_size_in_dp)
78 : WebContentsObserver(web_contents), 78 : WebContentsObserver(web_contents),
79 ideal_icon_size_(ideal_icon_size), 79 ideal_icon_size_in_dp_(ideal_icon_size_in_dp),
80 weak_delegate_(delegate), 80 weak_delegate_(delegate),
81 is_active_(false), 81 is_active_(false),
82 was_canceled_by_page_(false), 82 was_canceled_by_page_(false),
83 page_requested_prompt_(false), 83 page_requested_prompt_(false),
84 event_request_id_(-1) { 84 event_request_id_(-1) {
85 } 85 }
86 86
87 void AppBannerDataFetcher::Start(const GURL& validated_url, 87 void AppBannerDataFetcher::Start(const GURL& validated_url,
88 ui::PageTransition transition_type) { 88 ui::PageTransition transition_type) {
89 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 89 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after
312 } 312 }
313 313
314 OnHasServiceWorker(web_contents); 314 OnHasServiceWorker(web_contents);
315 } 315 }
316 316
317 void AppBannerDataFetcher::OnHasServiceWorker( 317 void AppBannerDataFetcher::OnHasServiceWorker(
318 content::WebContents* web_contents) { 318 content::WebContents* web_contents) {
319 GURL icon_url = 319 GURL icon_url =
320 ManifestIconSelector::FindBestMatchingIcon( 320 ManifestIconSelector::FindBestMatchingIcon(
321 web_app_data_.icons, 321 web_app_data_.icons,
322 ideal_icon_size_, 322 ideal_icon_size_in_dp_,
323 gfx::Screen::GetScreenFor(web_contents->GetNativeView())); 323 gfx::Screen::GetScreenFor(web_contents->GetNativeView()));
324 324
325 if (!FetchAppIcon(web_contents, icon_url)) { 325 if (!FetchAppIcon(web_contents, icon_url)) {
326 OutputDeveloperNotShownMessage(web_contents, kCannotDetermineBestIcon); 326 OutputDeveloperNotShownMessage(web_contents, kCannotDetermineBestIcon);
327 Cancel(); 327 Cancel();
328 } 328 }
329 } 329 }
330 330
331 bool AppBannerDataFetcher::FetchAppIcon(content::WebContents* web_contents, 331 bool AppBannerDataFetcher::FetchAppIcon(content::WebContents* web_contents,
332 const GURL& icon_url) { 332 const GURL& icon_url) {
333 return ManifestIconDownloader::Download( 333 return ManifestIconDownloader::Download(
334 web_contents, 334 web_contents,
335 icon_url, 335 icon_url,
336 ideal_icon_size_, 336 ideal_icon_size_in_dp_,
337 base::Bind(&AppBannerDataFetcher::OnAppIconFetched, 337 base::Bind(&AppBannerDataFetcher::OnAppIconFetched,
338 this)); 338 this));
339 } 339 }
340 340
341 void AppBannerDataFetcher::OnAppIconFetched(const SkBitmap& bitmap) { 341 void AppBannerDataFetcher::OnAppIconFetched(const SkBitmap& bitmap) {
342 if (!is_active_) return; 342 if (!is_active_) return;
343 343
344 content::WebContents* web_contents = GetWebContents(); 344 content::WebContents* web_contents = GetWebContents();
345 if (!CheckFetcherIsStillAlive(web_contents)) { 345 if (!CheckFetcherIsStillAlive(web_contents)) {
346 Cancel(); 346 Cancel();
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
424 return false; 424 return false;
425 } 425 }
426 if (!DoesManifestContainRequiredIcon(manifest)) { 426 if (!DoesManifestContainRequiredIcon(manifest)) {
427 OutputDeveloperNotShownMessage(web_contents, kManifestMissingSuitableIcon); 427 OutputDeveloperNotShownMessage(web_contents, kManifestMissingSuitableIcon);
428 return false; 428 return false;
429 } 429 }
430 return true; 430 return true;
431 } 431 }
432 432
433 } // namespace banners 433 } // namespace banners
OLDNEW
« no previous file with comments | « chrome/browser/banners/app_banner_data_fetcher.h ('k') | chrome/browser/banners/app_banner_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698