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_infobar_delegate.h" | 5 #include "chrome/browser/android/banners/app_banner_infobar_delegate.h" |
6 | 6 |
7 #include "base/android/jni_android.h" | 7 #include "base/android/jni_android.h" |
8 #include "base/strings/string16.h" | 8 #include "base/strings/string16.h" |
9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
10 #include "chrome/browser/ui/android/infobars/app_banner_infobar.h" | 10 #include "chrome/browser/ui/android/infobars/app_banner_infobar.h" |
11 #include "chrome/grit/generated_resources.h" | 11 #include "chrome/grit/generated_resources.h" |
12 #include "components/infobars/core/infobar.h" | 12 #include "components/infobars/core/infobar.h" |
13 #include "components/infobars/core/infobar_manager.h" | 13 #include "components/infobars/core/infobar_manager.h" |
14 | 14 |
15 namespace banners { | 15 namespace banners { |
16 | 16 |
17 // static | 17 // static |
| 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( |
| 23 app_delegate)); |
| 24 AppBannerInfoBar* infobar = new AppBannerInfoBar(delegate.Pass(), japp_data); |
| 25 return infobar_manager->AddInfoBar(make_scoped_ptr(infobar)) |
| 26 ? infobar : nullptr; |
| 27 } |
| 28 |
| 29 // static |
18 AppBannerInfoBar* AppBannerInfoBarDelegate::CreateForWebApp( | 30 AppBannerInfoBar* AppBannerInfoBarDelegate::CreateForWebApp( |
19 infobars::InfoBarManager* infobar_manager, | 31 infobars::InfoBarManager* infobar_manager, |
20 AppDelegate* app_delegate, | 32 AppDelegate* app_delegate, |
21 const GURL& url) { | 33 const GURL& url) { |
22 scoped_ptr<AppBannerInfoBarDelegate> delegate(new AppBannerInfoBarDelegate( | 34 scoped_ptr<AppBannerInfoBarDelegate> delegate(new AppBannerInfoBarDelegate( |
23 app_delegate)); | 35 app_delegate)); |
24 AppBannerInfoBar* infobar = new AppBannerInfoBar(delegate.Pass(), url); | 36 AppBannerInfoBar* infobar = new AppBannerInfoBar(delegate.Pass(), url); |
25 return infobar_manager->AddInfoBar(make_scoped_ptr(infobar)) | 37 return infobar_manager->AddInfoBar(make_scoped_ptr(infobar)) |
26 ? infobar : nullptr; | 38 ? infobar : nullptr; |
27 } | 39 } |
(...skipping 25 matching lines...) Expand all Loading... |
53 DCHECK(delegate_); | 65 DCHECK(delegate_); |
54 delegate_->Block(); | 66 delegate_->Block(); |
55 } | 67 } |
56 | 68 |
57 bool AppBannerInfoBarDelegate::Accept() { | 69 bool AppBannerInfoBarDelegate::Accept() { |
58 DCHECK(delegate_); | 70 DCHECK(delegate_); |
59 return delegate_->OnButtonClicked(); | 71 return delegate_->OnButtonClicked(); |
60 } | 72 } |
61 | 73 |
62 } // namespace banners | 74 } // namespace banners |
OLD | NEW |