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
3 // found in the LICENSE file.
5 #include "chrome/browser/android/banners/app_banner_infobar_delegate.h"
7 #include "base/android/jni_android.h"
8 #include "base/strings/string16.h"
9 #include "base/strings/utf_string_conversions.h"
10 #include "chrome/browser/ui/android/infobars/app_banner_infobar.h"
11 #include "chrome/grit/generated_resources.h"
12 #include "components/infobars/core/infobar.h"
13 #include "components/infobars/core/infobar_manager.h"
18 AppBannerInfoBar
* AppBannerInfoBarDelegate::CreateForNativeApp(
19 infobars::InfoBarManager
* infobar_manager
,
20 AppDelegate
* app_delegate
,
21 const base::android::ScopedJavaGlobalRef
<jobject
>& japp_data
) {
22 scoped_ptr
<AppBannerInfoBarDelegate
> delegate(new AppBannerInfoBarDelegate(
24 AppBannerInfoBar
* infobar
= new AppBannerInfoBar(delegate
.Pass(), japp_data
);
25 return infobar_manager
->AddInfoBar(make_scoped_ptr(infobar
))
30 AppBannerInfoBar
* AppBannerInfoBarDelegate::CreateForWebApp(
31 infobars::InfoBarManager
* infobar_manager
,
32 AppDelegate
* app_delegate
,
34 scoped_ptr
<AppBannerInfoBarDelegate
> delegate(new AppBannerInfoBarDelegate(
36 AppBannerInfoBar
* infobar
= new AppBannerInfoBar(delegate
.Pass(), url
);
37 return infobar_manager
->AddInfoBar(make_scoped_ptr(infobar
))
41 AppBannerInfoBarDelegate::AppBannerInfoBarDelegate(AppDelegate
* app_delegate
)
42 : delegate_(app_delegate
) {
45 AppBannerInfoBarDelegate::~AppBannerInfoBarDelegate() {
47 delegate_
->OnInfoBarDestroyed();
50 base::string16
AppBannerInfoBarDelegate::GetMessageText() const {
52 return delegate_
->GetTitle();
55 int AppBannerInfoBarDelegate::GetButtons() const {
59 gfx::Image
AppBannerInfoBarDelegate::GetIcon() const {
61 return delegate_
->GetIcon();
64 void AppBannerInfoBarDelegate::InfoBarDismissed() {
69 bool AppBannerInfoBarDelegate::Accept() {
71 return delegate_
->OnButtonClicked();
74 bool AppBannerInfoBarDelegate::LinkClicked(WindowOpenDisposition disposition
) {
76 return delegate_
->OnLinkClicked();
79 } // namespace banners