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

Side by Side Diff: chrome/browser/android/banners/app_banner_data_fetcher_android.cc

Issue 1308533006: webapps: allow callers of icon downloader/selector to specify a minimum size (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@webapps-splashscreen-icon
Patch Set: Address review comments 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/android/banners/app_banner_data_fetcher_android.h" 5 #include "chrome/browser/android/banners/app_banner_data_fetcher_android.h"
6 6
7 #include "chrome/browser/android/banners/app_banner_infobar_delegate_android.h" 7 #include "chrome/browser/android/banners/app_banner_infobar_delegate_android.h"
8 #include "chrome/browser/android/shortcut_helper.h" 8 #include "chrome/browser/android/shortcut_helper.h"
9 #include "chrome/browser/banners/app_banner_metrics.h" 9 #include "chrome/browser/banners/app_banner_metrics.h"
10 #include "chrome/browser/infobars/infobar_service.h" 10 #include "chrome/browser/infobars/infobar_service.h"
11 #include "chrome/browser/manifest/manifest_icon_selector.h" 11 #include "chrome/browser/manifest/manifest_icon_selector.h"
12 #include "chrome/browser/ui/android/infobars/app_banner_infobar_android.h" 12 #include "chrome/browser/ui/android/infobars/app_banner_infobar_android.h"
13 #include "third_party/skia/include/core/SkBitmap.h" 13 #include "third_party/skia/include/core/SkBitmap.h"
14 #include "ui/gfx/screen.h" 14 #include "ui/gfx/screen.h"
15 15
16 namespace banners { 16 namespace banners {
17 17
18 AppBannerDataFetcherAndroid::AppBannerDataFetcherAndroid( 18 AppBannerDataFetcherAndroid::AppBannerDataFetcherAndroid(
19 content::WebContents* web_contents, 19 content::WebContents* web_contents,
20 base::WeakPtr<Delegate> weak_delegate, 20 base::WeakPtr<Delegate> weak_delegate,
21 int ideal_icon_size_in_dp,
22 int minimum_icon_size_in_dp,
21 int ideal_splash_image_size_in_dp, 23 int ideal_splash_image_size_in_dp,
22 int ideal_icon_size_in_dp) 24 int minimum_splash_image_size_in_dp)
23 : AppBannerDataFetcher(web_contents, weak_delegate, ideal_icon_size_in_dp), 25 : AppBannerDataFetcher(web_contents,
24 ideal_splash_image_size_in_dp_(ideal_splash_image_size_in_dp) { 26 weak_delegate,
27 ideal_icon_size_in_dp,
28 minimum_icon_size_in_dp),
29 ideal_splash_image_size_in_dp_(ideal_splash_image_size_in_dp),
30 minimum_splash_image_size_in_dp_(minimum_splash_image_size_in_dp) {
25 } 31 }
26 32
27 AppBannerDataFetcherAndroid::~AppBannerDataFetcherAndroid() { 33 AppBannerDataFetcherAndroid::~AppBannerDataFetcherAndroid() {
28 } 34 }
29 35
30 std::string AppBannerDataFetcherAndroid::GetBannerType() { 36 std::string AppBannerDataFetcherAndroid::GetBannerType() {
31 return native_app_data_.is_null() 37 return native_app_data_.is_null()
32 ? AppBannerDataFetcher::GetBannerType() : "android"; 38 ? AppBannerDataFetcher::GetBannerType() : "android";
33 } 39 }
34 40
(...skipping 14 matching lines...) Expand all
49 } 55 }
50 56
51 void AppBannerDataFetcherAndroid::FetchWebappSplashScreenImage( 57 void AppBannerDataFetcherAndroid::FetchWebappSplashScreenImage(
52 const std::string& webapp_id) { 58 const std::string& webapp_id) {
53 content::WebContents* web_contents = GetWebContents(); 59 content::WebContents* web_contents = GetWebContents();
54 DCHECK(web_contents); 60 DCHECK(web_contents);
55 61
56 GURL image_url = ManifestIconSelector::FindBestMatchingIcon( 62 GURL image_url = ManifestIconSelector::FindBestMatchingIcon(
57 web_app_data().icons, 63 web_app_data().icons,
58 ideal_splash_image_size_in_dp_, 64 ideal_splash_image_size_in_dp_,
65 minimum_splash_image_size_in_dp_,
59 gfx::Screen::GetScreenFor(web_contents->GetNativeView())); 66 gfx::Screen::GetScreenFor(web_contents->GetNativeView()));
60 67
61 ShortcutHelper::FetchSplashScreenImage( 68 ShortcutHelper::FetchSplashScreenImage(
62 web_contents, image_url, ideal_splash_image_size_in_dp_, webapp_id); 69 web_contents,
70 image_url,
71 ideal_splash_image_size_in_dp_,
72 minimum_splash_image_size_in_dp_,
73 webapp_id);
63 } 74 }
64 75
65 void AppBannerDataFetcherAndroid::ShowBanner(const SkBitmap* icon, 76 void AppBannerDataFetcherAndroid::ShowBanner(const SkBitmap* icon,
66 const base::string16& title, 77 const base::string16& title,
67 const std::string& referrer) { 78 const std::string& referrer) {
68 content::WebContents* web_contents = GetWebContents(); 79 content::WebContents* web_contents = GetWebContents();
69 DCHECK(web_contents); 80 DCHECK(web_contents);
70 81
71 infobars::InfoBar* infobar = nullptr; 82 infobars::InfoBar* infobar = nullptr;
72 if (native_app_data_.is_null()) { 83 if (native_app_data_.is_null()) {
(...skipping 17 matching lines...) Expand all
90 if (infobar) { 101 if (infobar) {
91 RecordDidShowBanner("AppBanner.NativeApp.Shown"); 102 RecordDidShowBanner("AppBanner.NativeApp.Shown");
92 TrackDisplayEvent(DISPLAY_EVENT_NATIVE_APP_BANNER_CREATED); 103 TrackDisplayEvent(DISPLAY_EVENT_NATIVE_APP_BANNER_CREATED);
93 } 104 }
94 } 105 }
95 InfoBarService::FromWebContents(web_contents) 106 InfoBarService::FromWebContents(web_contents)
96 ->AddInfoBar(make_scoped_ptr(infobar)); 107 ->AddInfoBar(make_scoped_ptr(infobar));
97 } 108 }
98 109
99 } // namespace banners 110 } // namespace banners
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698