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/banners/app_banner_infobar_delegate_desktop.h" | 5 #include "chrome/browser/banners/app_banner_infobar_delegate_desktop.h" |
6 | 6 |
7 #include "chrome/browser/banners/app_banner_data_fetcher_desktop.h" | 7 #include "chrome/browser/banners/app_banner_data_fetcher_desktop.h" |
8 #include "chrome/browser/banners/app_banner_metrics.h" | 8 #include "chrome/browser/banners/app_banner_metrics.h" |
9 #include "chrome/browser/banners/app_banner_settings_helper.h" | 9 #include "chrome/browser/banners/app_banner_settings_helper.h" |
10 #include "chrome/browser/extensions/bookmark_app_helper.h" | 10 #include "chrome/browser/extensions/bookmark_app_helper.h" |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
54 } | 54 } |
55 | 55 |
56 int AppBannerInfoBarDelegateDesktop::GetIconID() const { | 56 int AppBannerInfoBarDelegateDesktop::GetIconID() const { |
57 return IDR_INFOBAR_APP_BANNER; | 57 return IDR_INFOBAR_APP_BANNER; |
58 } | 58 } |
59 | 59 |
60 base::string16 AppBannerInfoBarDelegateDesktop::GetMessageText() const { | 60 base::string16 AppBannerInfoBarDelegateDesktop::GetMessageText() const { |
61 return l10n_util::GetStringUTF16(IDS_ADD_TO_SHELF_INFOBAR_TITLE); | 61 return l10n_util::GetStringUTF16(IDS_ADD_TO_SHELF_INFOBAR_TITLE); |
62 } | 62 } |
63 | 63 |
| 64 int AppBannerInfoBarDelegateDesktop::GetButtons() const { |
| 65 return BUTTON_OK; |
| 66 } |
| 67 |
64 base::string16 AppBannerInfoBarDelegateDesktop::GetButtonLabel( | 68 base::string16 AppBannerInfoBarDelegateDesktop::GetButtonLabel( |
65 InfoBarButton button) const { | 69 InfoBarButton button) const { |
66 return l10n_util::GetStringUTF16((button == BUTTON_OK) | 70 return l10n_util::GetStringUTF16(IDS_ADD_TO_SHELF_INFOBAR_ADD_BUTTON); |
67 ? IDS_ADD_TO_SHELF_INFOBAR_ADD_BUTTON | |
68 : IDS_ADD_TO_SHELF_INFOBAR_NEVER_BUTTON); | |
69 } | 71 } |
70 | 72 |
71 bool AppBannerInfoBarDelegateDesktop::Accept() { | 73 bool AppBannerInfoBarDelegateDesktop::Accept() { |
72 bookmark_app_helper_->CreateFromAppBanner( | 74 bookmark_app_helper_->CreateFromAppBanner( |
73 base::Bind(&AppBannerDataFetcherDesktop::FinishCreateBookmarkApp, | 75 base::Bind(&AppBannerDataFetcherDesktop::FinishCreateBookmarkApp, |
74 fetcher_), | 76 fetcher_), |
75 web_manifest_); | 77 web_manifest_); |
76 return true; | 78 return true; |
77 } | 79 } |
78 | 80 |
79 bool AppBannerInfoBarDelegateDesktop::Cancel() { | 81 void AppBannerInfoBarDelegateDesktop::InfoBarDismissed() { |
80 content::WebContents* web_contents = | 82 content::WebContents* web_contents = |
81 InfoBarService::WebContentsFromInfoBar(infobar()); | 83 InfoBarService::WebContentsFromInfoBar(infobar()); |
82 if (web_contents) { | 84 if (web_contents) { |
83 fetcher_.get()->Cancel(); | 85 fetcher_.get()->Cancel(); |
84 | 86 |
85 web_contents->GetMainFrame()->Send( | 87 web_contents->GetMainFrame()->Send( |
86 new ChromeViewMsg_AppBannerDismissed( | 88 new ChromeViewMsg_AppBannerDismissed( |
87 web_contents->GetMainFrame()->GetRoutingID(), | 89 web_contents->GetMainFrame()->GetRoutingID(), |
88 event_request_id_)); | 90 event_request_id_)); |
89 | 91 |
90 AppBannerSettingsHelper::RecordBannerDismissEvent( | 92 AppBannerSettingsHelper::RecordBannerDismissEvent( |
91 web_contents, web_manifest_.start_url.spec(), | 93 web_contents, web_manifest_.start_url.spec(), |
92 AppBannerSettingsHelper::WEB); | 94 AppBannerSettingsHelper::WEB); |
93 } | 95 } |
94 return true; | |
95 } | |
96 | |
97 void AppBannerInfoBarDelegateDesktop::InfoBarDismissed() { | |
98 Cancel(); | |
99 } | 96 } |
100 | 97 |
101 } // namespace banners | 98 } // namespace banners |
OLD | NEW |