| 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 #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 <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/bind.h" |
| 10 #include "base/callback.h" |
| 9 #include "chrome/browser/android/banners/app_banner_infobar_delegate_android.h" | 11 #include "chrome/browser/android/banners/app_banner_infobar_delegate_android.h" |
| 10 #include "chrome/browser/android/shortcut_helper.h" | 12 #include "chrome/browser/android/shortcut_helper.h" |
| 11 #include "chrome/browser/banners/app_banner_metrics.h" | 13 #include "chrome/browser/banners/app_banner_metrics.h" |
| 12 #include "chrome/browser/infobars/infobar_service.h" | 14 #include "chrome/browser/infobars/infobar_service.h" |
| 13 #include "chrome/browser/manifest/manifest_icon_selector.h" | 15 #include "chrome/browser/manifest/manifest_icon_selector.h" |
| 14 #include "chrome/browser/ui/android/infobars/app_banner_infobar_android.h" | 16 #include "chrome/browser/ui/android/infobars/app_banner_infobar_android.h" |
| 15 #include "third_party/skia/include/core/SkBitmap.h" | 17 #include "third_party/skia/include/core/SkBitmap.h" |
| 16 #include "ui/gfx/screen.h" | 18 #include "ui/gfx/screen.h" |
| 17 | 19 |
| 18 namespace banners { | 20 namespace banners { |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 50 native_app_package_ = app_package; | 52 native_app_package_ = app_package; |
| 51 native_app_data_.Reset(app_data); | 53 native_app_data_.Reset(app_data); |
| 52 return FetchAppIcon(GetWebContents(), image_url); | 54 return FetchAppIcon(GetWebContents(), image_url); |
| 53 } | 55 } |
| 54 | 56 |
| 55 std::string AppBannerDataFetcherAndroid::GetAppIdentifier() { | 57 std::string AppBannerDataFetcherAndroid::GetAppIdentifier() { |
| 56 return native_app_data_.is_null() | 58 return native_app_data_.is_null() |
| 57 ? AppBannerDataFetcher::GetAppIdentifier() : native_app_package_; | 59 ? AppBannerDataFetcher::GetAppIdentifier() : native_app_package_; |
| 58 } | 60 } |
| 59 | 61 |
| 60 void AppBannerDataFetcherAndroid::FetchWebappSplashScreenImage( | 62 base::Closure AppBannerDataFetcherAndroid::FetchWebappSplashScreenImageCallback( |
| 61 const std::string& webapp_id) { | 63 const std::string& webapp_id) { |
| 62 content::WebContents* web_contents = GetWebContents(); | 64 content::WebContents* web_contents = GetWebContents(); |
| 63 DCHECK(web_contents); | 65 DCHECK(web_contents); |
| 64 | 66 |
| 65 GURL image_url = ManifestIconSelector::FindBestMatchingIcon( | 67 GURL image_url = ManifestIconSelector::FindBestMatchingIcon( |
| 66 web_app_data().icons, ideal_splash_image_size_in_dp_, | 68 web_app_data().icons, ideal_splash_image_size_in_dp_, |
| 67 minimum_splash_image_size_in_dp_); | 69 minimum_splash_image_size_in_dp_); |
| 68 | 70 |
| 69 ShortcutHelper::FetchSplashScreenImage( | 71 return base::Bind(&ShortcutHelper::FetchSplashScreenImage, |
| 70 web_contents, | 72 web_contents, image_url, ideal_splash_image_size_in_dp_, |
| 71 image_url, | 73 minimum_splash_image_size_in_dp_, webapp_id); |
| 72 ideal_splash_image_size_in_dp_, | |
| 73 minimum_splash_image_size_in_dp_, | |
| 74 webapp_id, | |
| 75 web_app_data().start_url.spec()); | |
| 76 } | 74 } |
| 77 | 75 |
| 78 void AppBannerDataFetcherAndroid::ShowBanner(const SkBitmap* icon, | 76 void AppBannerDataFetcherAndroid::ShowBanner(const SkBitmap* icon, |
| 79 const base::string16& title, | 77 const base::string16& title, |
| 80 const std::string& referrer) { | 78 const std::string& referrer) { |
| 81 content::WebContents* web_contents = GetWebContents(); | 79 content::WebContents* web_contents = GetWebContents(); |
| 82 DCHECK(web_contents); | 80 DCHECK(web_contents); |
| 83 | 81 |
| 84 infobars::InfoBar* infobar = nullptr; | 82 infobars::InfoBar* infobar = nullptr; |
| 85 if (native_app_data_.is_null()) { | 83 if (native_app_data_.is_null()) { |
| (...skipping 18 matching lines...) Expand all Loading... |
| 104 if (infobar) { | 102 if (infobar) { |
| 105 RecordDidShowBanner("AppBanner.NativeApp.Shown"); | 103 RecordDidShowBanner("AppBanner.NativeApp.Shown"); |
| 106 TrackDisplayEvent(DISPLAY_EVENT_NATIVE_APP_BANNER_CREATED); | 104 TrackDisplayEvent(DISPLAY_EVENT_NATIVE_APP_BANNER_CREATED); |
| 107 } | 105 } |
| 108 } | 106 } |
| 109 InfoBarService::FromWebContents(web_contents) | 107 InfoBarService::FromWebContents(web_contents) |
| 110 ->AddInfoBar(make_scoped_ptr(infobar)); | 108 ->AddInfoBar(make_scoped_ptr(infobar)); |
| 111 } | 109 } |
| 112 | 110 |
| 113 } // namespace banners | 111 } // namespace banners |
| OLD | NEW |