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

Side by Side Diff: chrome/browser/banners/app_banner_infobar_delegate_desktop.cc

Issue 2969163002: Remove AppBannerManager::event_request_id(). (Closed)
Patch Set: Refactor into method Created 3 years, 5 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
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 <memory> 7 #include <memory>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "chrome/app/vector_icons/vector_icons.h" 10 #include "chrome/app/vector_icons/vector_icons.h"
11 #include "chrome/browser/banners/app_banner_manager.h" 11 #include "chrome/browser/banners/app_banner_manager.h"
12 #include "chrome/browser/banners/app_banner_metrics.h" 12 #include "chrome/browser/banners/app_banner_metrics.h"
13 #include "chrome/browser/banners/app_banner_settings_helper.h" 13 #include "chrome/browser/banners/app_banner_settings_helper.h"
14 #include "chrome/browser/extensions/bookmark_app_helper.h" 14 #include "chrome/browser/extensions/bookmark_app_helper.h"
15 #include "chrome/browser/infobars/infobar_service.h" 15 #include "chrome/browser/infobars/infobar_service.h"
16 #include "chrome/common/web_application_info.h" 16 #include "chrome/common/web_application_info.h"
17 #include "chrome/grit/generated_resources.h" 17 #include "chrome/grit/generated_resources.h"
18 #include "components/infobars/core/infobar.h" 18 #include "components/infobars/core/infobar.h"
19 #include "content/public/browser/web_contents.h" 19 #include "content/public/browser/web_contents.h"
20 #include "ui/base/l10n/l10n_util.h" 20 #include "ui/base/l10n/l10n_util.h"
21 21
22 namespace banners { 22 namespace banners {
23 23
24 // static 24 // static
25 infobars::InfoBar* AppBannerInfoBarDelegateDesktop::Create( 25 infobars::InfoBar* AppBannerInfoBarDelegateDesktop::Create(
26 content::WebContents* web_contents, 26 content::WebContents* web_contents,
27 base::WeakPtr<AppBannerManager> weak_manager, 27 base::WeakPtr<AppBannerManager> weak_manager,
28 extensions::BookmarkAppHelper* bookmark_app_helper, 28 extensions::BookmarkAppHelper* bookmark_app_helper,
29 const content::Manifest& manifest, 29 const content::Manifest& manifest) {
30 int event_request_id) {
31 InfoBarService* infobar_service = 30 InfoBarService* infobar_service =
32 InfoBarService::FromWebContents(web_contents); 31 InfoBarService::FromWebContents(web_contents);
33 return infobar_service->AddInfoBar(infobar_service->CreateConfirmInfoBar( 32 return infobar_service->AddInfoBar(infobar_service->CreateConfirmInfoBar(
34 std::unique_ptr<ConfirmInfoBarDelegate>( 33 std::unique_ptr<ConfirmInfoBarDelegate>(
35 new AppBannerInfoBarDelegateDesktop(weak_manager, bookmark_app_helper, 34 new AppBannerInfoBarDelegateDesktop(weak_manager, bookmark_app_helper,
36 manifest, event_request_id)))); 35 manifest))));
37 } 36 }
38 37
39 AppBannerInfoBarDelegateDesktop::AppBannerInfoBarDelegateDesktop( 38 AppBannerInfoBarDelegateDesktop::AppBannerInfoBarDelegateDesktop(
40 base::WeakPtr<AppBannerManager> weak_manager, 39 base::WeakPtr<AppBannerManager> weak_manager,
41 extensions::BookmarkAppHelper* bookmark_app_helper, 40 extensions::BookmarkAppHelper* bookmark_app_helper,
42 const content::Manifest& manifest, 41 const content::Manifest& manifest)
43 int event_request_id)
44 : ConfirmInfoBarDelegate(), 42 : ConfirmInfoBarDelegate(),
45 weak_manager_(weak_manager), 43 weak_manager_(weak_manager),
46 bookmark_app_helper_(bookmark_app_helper), 44 bookmark_app_helper_(bookmark_app_helper),
47 manifest_(manifest), 45 manifest_(manifest),
48 event_request_id_(event_request_id), 46 has_user_interaction_(false) {}
49 has_user_interaction_(false) {
50 }
51 47
52 AppBannerInfoBarDelegateDesktop::~AppBannerInfoBarDelegateDesktop() { 48 AppBannerInfoBarDelegateDesktop::~AppBannerInfoBarDelegateDesktop() {
53 if (!has_user_interaction_) 49 if (!has_user_interaction_)
54 TrackUserResponse(USER_RESPONSE_WEB_APP_IGNORED); 50 TrackUserResponse(USER_RESPONSE_WEB_APP_IGNORED);
55 } 51 }
56 52
57 infobars::InfoBarDelegate::Type 53 infobars::InfoBarDelegate::Type
58 AppBannerInfoBarDelegateDesktop::GetInfoBarType() const { 54 AppBannerInfoBarDelegateDesktop::GetInfoBarType() const {
59 return PAGE_ACTION_TYPE; 55 return PAGE_ACTION_TYPE;
60 } 56 }
61 57
62 infobars::InfoBarDelegate::InfoBarIdentifier 58 infobars::InfoBarDelegate::InfoBarIdentifier
63 AppBannerInfoBarDelegateDesktop::GetIdentifier() const { 59 AppBannerInfoBarDelegateDesktop::GetIdentifier() const {
64 return APP_BANNER_INFOBAR_DELEGATE_DESKTOP; 60 return APP_BANNER_INFOBAR_DELEGATE_DESKTOP;
65 } 61 }
66 62
67 const gfx::VectorIcon& AppBannerInfoBarDelegateDesktop::GetVectorIcon() const { 63 const gfx::VectorIcon& AppBannerInfoBarDelegateDesktop::GetVectorIcon() const {
68 return kAppsIcon; 64 return kAppsIcon;
69 } 65 }
70 66
71 void AppBannerInfoBarDelegateDesktop::InfoBarDismissed() { 67 void AppBannerInfoBarDelegateDesktop::InfoBarDismissed() {
72 TrackUserResponse(USER_RESPONSE_WEB_APP_DISMISSED); 68 TrackUserResponse(USER_RESPONSE_WEB_APP_DISMISSED);
73 has_user_interaction_ = true; 69 has_user_interaction_ = true;
74 70
75 content::WebContents* web_contents = 71 content::WebContents* web_contents =
76 InfoBarService::WebContentsFromInfoBar(infobar()); 72 InfoBarService::WebContentsFromInfoBar(infobar());
77 if (web_contents) { 73 if (web_contents) {
78 if (weak_manager_) 74 if (weak_manager_)
79 weak_manager_->SendBannerDismissed(event_request_id_); 75 weak_manager_->SendBannerDismissed();
80 76
81 AppBannerSettingsHelper::RecordBannerDismissEvent( 77 AppBannerSettingsHelper::RecordBannerDismissEvent(
82 web_contents, manifest_.start_url.spec(), AppBannerSettingsHelper::WEB); 78 web_contents, manifest_.start_url.spec(), AppBannerSettingsHelper::WEB);
83 } 79 }
84 } 80 }
85 81
86 base::string16 AppBannerInfoBarDelegateDesktop::GetMessageText() const { 82 base::string16 AppBannerInfoBarDelegateDesktop::GetMessageText() const {
87 return l10n_util::GetStringUTF16(IDS_ADD_TO_SHELF_INFOBAR_TITLE); 83 return l10n_util::GetStringUTF16(IDS_ADD_TO_SHELF_INFOBAR_TITLE);
88 } 84 }
89 85
(...skipping 11 matching lines...) Expand all
101 has_user_interaction_ = true; 97 has_user_interaction_ = true;
102 98
103 bookmark_app_helper_->CreateFromAppBanner( 99 bookmark_app_helper_->CreateFromAppBanner(
104 base::Bind(&AppBannerManager::DidFinishCreatingBookmarkApp, 100 base::Bind(&AppBannerManager::DidFinishCreatingBookmarkApp,
105 weak_manager_), 101 weak_manager_),
106 manifest_); 102 manifest_);
107 return true; 103 return true;
108 } 104 }
109 105
110 } // namespace banners 106 } // namespace banners
OLDNEW
« no previous file with comments | « chrome/browser/banners/app_banner_infobar_delegate_desktop.h ('k') | chrome/browser/banners/app_banner_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698