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

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

Issue 893073002: Start showing basic infobars for manifest apps (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Revised icon storage logic 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 unified diff | Download patch
OLDNEW
(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 {
newt (away) 2015/02/03 00:57:24 How could delegate_ ever be null? It seems impossi
gone 2015/02/03 01:18:16 Done.
58 return delegate_ ? delegate_->GetIcon() : gfx::Image();
59 }
60
61 void AppBannerInfoBarDelegate::InfoBarDismissed() {
62 if (delegate_)
63 delegate_->Block();
64 }
65
66 bool AppBannerInfoBarDelegate::Accept() {
67 if (delegate_)
68 delegate_->Install();
69 return true;
70 }
71
72 } // namespace banners
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698