OLD | NEW |
(Empty) | |
| 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. |
| 4 |
| 5 #include "chrome/browser/android/banners/app_banner_infobar_delegate.h" |
| 6 |
| 7 #include "base/strings/string16.h" |
| 8 #include "base/strings/utf_string_conversions.h" |
| 9 #include "chrome/browser/infobars/infobar_service.h" |
| 10 #include "chrome/grit/generated_resources.h" |
| 11 #include "components/infobars/core/infobar.h" |
| 12 #include "ui/base/l10n/l10n_util.h" |
| 13 |
| 14 namespace banners { |
| 15 |
| 16 infobars::InfoBar* AppBannerInfoBarDelegate::CreateForWebApp( |
| 17 InfoBarService* infobar_service, |
| 18 const AppDelegate* helper, |
| 19 const base::string16& app_name, |
| 20 const GURL& url) { |
| 21 AppBannerInfoBarDelegate* const delegate = new AppBannerInfoBarDelegate( |
| 22 helper, |
| 23 app_name, |
| 24 url); |
| 25 |
| 26 return infobar_service->AddInfoBar(infobar_service->CreateConfirmInfoBar( |
| 27 scoped_ptr<ConfirmInfoBarDelegate>(delegate))); |
| 28 } |
| 29 |
| 30 AppBannerInfoBarDelegate::AppBannerInfoBarDelegate( |
| 31 const AppDelegate* helper, |
| 32 const base::string16& app_title, |
| 33 const GURL& url) |
| 34 : delegate_(helper), |
| 35 app_title_(app_title), |
| 36 url_(url), |
| 37 button_text_(l10n_util::GetStringUTF16( |
| 38 IDS_APP_INSTALL_ALERTS_ADD_TO_HOMESCREEN)) { |
| 39 } |
| 40 |
| 41 AppBannerInfoBarDelegate::~AppBannerInfoBarDelegate() { |
| 42 } |
| 43 |
| 44 base::string16 AppBannerInfoBarDelegate::GetMessageText() const { |
| 45 return app_title_; |
| 46 } |
| 47 |
| 48 int AppBannerInfoBarDelegate::GetButtons() const { |
| 49 return BUTTON_OK; |
| 50 } |
| 51 |
| 52 base::string16 AppBannerInfoBarDelegate::GetButtonLabel(InfoBarButton button) |
| 53 const { |
| 54 return button_text_; |
| 55 } |
| 56 |
| 57 gfx::Image AppBannerInfoBarDelegate::GetIcon() const { |
| 58 DCHECK(delegate_); |
| 59 return delegate_->GetIcon(); |
| 60 } |
| 61 |
| 62 void AppBannerInfoBarDelegate::InfoBarDismissed() { |
| 63 DCHECK(delegate_); |
| 64 delegate_->Block(); |
| 65 } |
| 66 |
| 67 bool AppBannerInfoBarDelegate::Accept() { |
| 68 DCHECK(delegate_); |
| 69 delegate_->Install(); |
| 70 return true; |
| 71 } |
| 72 |
| 73 } // namespace banners |
OLD | NEW |