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

Unified Diff: chrome/browser/android/banners/app_banner_infobar_delegate.cc

Issue 901203003: Redo how AppBannerInfoBars are created and stored (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Moving init before the early return so that restored tabs also get them Created 5 years, 10 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/android/banners/app_banner_infobar_delegate.cc
diff --git a/chrome/browser/android/banners/app_banner_infobar_delegate.cc b/chrome/browser/android/banners/app_banner_infobar_delegate.cc
index dfa580f56e0bd906b079dc5811240c68c8c0965a..e35f55b42a5d4350a8159e72d780e6a8e0a4a660 100644
--- a/chrome/browser/android/banners/app_banner_infobar_delegate.cc
+++ b/chrome/browser/android/banners/app_banner_infobar_delegate.cc
@@ -4,57 +4,46 @@
#include "chrome/browser/android/banners/app_banner_infobar_delegate.h"
+#include "base/android/jni_android.h"
#include "base/strings/string16.h"
#include "base/strings/utf_string_conversions.h"
#include "chrome/browser/ui/android/infobars/app_banner_infobar.h"
#include "chrome/grit/generated_resources.h"
#include "components/infobars/core/infobar.h"
#include "components/infobars/core/infobar_manager.h"
-#include "ui/base/l10n/l10n_util.h"
namespace banners {
-infobars::InfoBar* AppBannerInfoBarDelegate::CreateForWebApp(
+// static
+AppBannerInfoBar* AppBannerInfoBarDelegate::CreateForWebApp(
infobars::InfoBarManager* infobar_manager,
- const AppDelegate* app_delegate,
- const base::string16& app_name,
+ AppDelegate* app_delegate,
const GURL& url) {
scoped_ptr<AppBannerInfoBarDelegate> delegate(new AppBannerInfoBarDelegate(
- app_delegate,
- app_name,
- url));
-
- return infobar_manager->AddInfoBar(
- make_scoped_ptr(new AppBannerInfoBar(delegate.Pass(), url)));
+ app_delegate));
+ AppBannerInfoBar* infobar = new AppBannerInfoBar(delegate.Pass(), url);
+ return infobar_manager->AddInfoBar(make_scoped_ptr(infobar))
+ ? infobar : nullptr;
}
-AppBannerInfoBarDelegate::AppBannerInfoBarDelegate(
- const AppDelegate* helper,
- const base::string16& app_title,
- const GURL& url)
- : delegate_(helper),
- app_title_(app_title),
- url_(url),
- button_text_(l10n_util::GetStringUTF16(
- IDS_APP_INSTALL_ALERTS_ADD_TO_HOMESCREEN)) {
+AppBannerInfoBarDelegate::AppBannerInfoBarDelegate(AppDelegate* app_delegate)
+ : delegate_(app_delegate) {
}
AppBannerInfoBarDelegate::~AppBannerInfoBarDelegate() {
+ DCHECK(delegate_);
+ delegate_->OnInfoBarDestroyed();
}
base::string16 AppBannerInfoBarDelegate::GetMessageText() const {
- return app_title_;
+ DCHECK(delegate_);
+ return delegate_->GetTitle();
}
int AppBannerInfoBarDelegate::GetButtons() const {
return BUTTON_OK;
}
-base::string16 AppBannerInfoBarDelegate::GetButtonLabel(InfoBarButton button)
- const {
- return button_text_;
-}
-
gfx::Image AppBannerInfoBarDelegate::GetIcon() const {
DCHECK(delegate_);
return delegate_->GetIcon();
@@ -67,8 +56,7 @@ void AppBannerInfoBarDelegate::InfoBarDismissed() {
bool AppBannerInfoBarDelegate::Accept() {
DCHECK(delegate_);
- delegate_->Install();
- return true;
+ return delegate_->OnButtonClicked();
}
} // namespace banners
« no previous file with comments | « chrome/browser/android/banners/app_banner_infobar_delegate.h ('k') | chrome/browser/android/banners/app_banner_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698