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

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

Issue 1161233005: Implement app banner info bars on desktop. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@stop-icon-overgeneration
Patch Set: Moving feature enabling to existing #ifs Created 5 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/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/infobars/infobar_service.h"
8 #include "chrome/browser/ui/android/infobars/app_banner_infobar_android.h" 9 #include "chrome/browser/ui/android/infobars/app_banner_infobar_android.h"
9 #include "third_party/skia/include/core/SkBitmap.h" 10 #include "third_party/skia/include/core/SkBitmap.h"
10 11
11 namespace banners { 12 namespace banners {
12 13
13 AppBannerDataFetcherAndroid::AppBannerDataFetcherAndroid( 14 AppBannerDataFetcherAndroid::AppBannerDataFetcherAndroid(
14 content::WebContents* web_contents, 15 content::WebContents* web_contents,
15 base::WeakPtr<Delegate> weak_delegate, 16 base::WeakPtr<Delegate> weak_delegate,
16 int ideal_icon_size) 17 int ideal_icon_size)
17 : AppBannerDataFetcher(web_contents, weak_delegate, ideal_icon_size) { 18 : AppBannerDataFetcher(web_contents, weak_delegate, ideal_icon_size) {
(...skipping 16 matching lines...) Expand all
34 native_app_package_ = app_package; 35 native_app_package_ = app_package;
35 native_app_data_.Reset(app_data); 36 native_app_data_.Reset(app_data);
36 return FetchIcon(image_url); 37 return FetchIcon(image_url);
37 } 38 }
38 39
39 std::string AppBannerDataFetcherAndroid::GetAppIdentifier() { 40 std::string AppBannerDataFetcherAndroid::GetAppIdentifier() {
40 return native_app_data_.is_null() 41 return native_app_data_.is_null()
41 ? AppBannerDataFetcher::GetAppIdentifier() : native_app_package_; 42 ? AppBannerDataFetcher::GetAppIdentifier() : native_app_package_;
42 } 43 }
43 44
44 infobars::InfoBar* AppBannerDataFetcherAndroid::CreateBanner( 45 void AppBannerDataFetcherAndroid::ShowBanner(const SkBitmap* icon,
45 const SkBitmap* icon, 46 const base::string16& title) {
46 const base::string16& title) {
47 content::WebContents* web_contents = GetWebContents(); 47 content::WebContents* web_contents = GetWebContents();
48 DCHECK(web_contents); 48 DCHECK(web_contents);
49 49
50 infobars::InfoBar* infobar = nullptr; 50 infobars::InfoBar* infobar = nullptr;
51 if (native_app_data_.is_null()) { 51 if (native_app_data_.is_null()) {
52 scoped_ptr<AppBannerInfoBarDelegateAndroid> delegate( 52 scoped_ptr<AppBannerInfoBarDelegateAndroid> delegate(
53 new AppBannerInfoBarDelegateAndroid( 53 new AppBannerInfoBarDelegateAndroid(
54 event_request_id(), title, new SkBitmap(*icon), web_app_data())); 54 event_request_id(), title, new SkBitmap(*icon), web_app_data()));
55 55
56 infobar = 56 infobar =
57 new AppBannerInfoBarAndroid(delegate.Pass(), web_app_data().start_url); 57 new AppBannerInfoBarAndroid(delegate.Pass(), web_app_data().start_url);
58 if (infobar) 58 if (infobar)
59 RecordDidShowBanner("AppBanner.WebApp.Shown"); 59 RecordDidShowBanner("AppBanner.WebApp.Shown");
60 } else { 60 } else {
61 scoped_ptr<AppBannerInfoBarDelegateAndroid> delegate( 61 scoped_ptr<AppBannerInfoBarDelegateAndroid> delegate(
62 new AppBannerInfoBarDelegateAndroid( 62 new AppBannerInfoBarDelegateAndroid(
63 event_request_id(), title, new SkBitmap(*icon), native_app_data_, 63 event_request_id(), title, new SkBitmap(*icon), native_app_data_,
64 native_app_package_)); 64 native_app_package_));
65 infobar = new AppBannerInfoBarAndroid(delegate.Pass(), native_app_data_); 65 infobar = new AppBannerInfoBarAndroid(delegate.Pass(), native_app_data_);
66 if (infobar) 66 if (infobar)
67 RecordDidShowBanner("AppBanner.NativeApp.Shown"); 67 RecordDidShowBanner("AppBanner.NativeApp.Shown");
68 } 68 }
69 69 InfoBarService::FromWebContents(web_contents)
70 return infobar; 70 ->AddInfoBar(make_scoped_ptr(infobar));
71 } 71 }
72 72
73 } // namespace banners 73 } // namespace banners
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698