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

Unified Diff: chrome/browser/banners/app_banner_data_fetcher.cc

Issue 1161233005: Implement app banner info bars on desktop. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@stop-icon-overgeneration
Patch Set: Fixing display bug on Android Created 5 years, 7 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/banners/app_banner_data_fetcher.cc
diff --git a/chrome/browser/banners/app_banner_data_fetcher.cc b/chrome/browser/banners/app_banner_data_fetcher.cc
index 8f973ce45678d382aa8013f8ff63d597bc113674..2256f26cdf44ef4962b0076a53acbde441ab5db3 100644
--- a/chrome/browser/banners/app_banner_data_fetcher.cc
+++ b/chrome/browser/banners/app_banner_data_fetcher.cc
@@ -16,6 +16,7 @@
#include "chrome/browser/manifest/manifest_icon_selector.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/common/render_messages.h"
+#include "chrome/common/web_application_info.h"
#include "components/infobars/core/infobar.h"
#include "components/rappor/rappor_utils.h"
#include "content/public/browser/browser_context.h"
@@ -28,6 +29,11 @@
#include "third_party/WebKit/public/platform/modules/app_banner/WebAppBannerPromptReply.h"
#include "ui/gfx/screen.h"
+#if !defined(OS_ANDROID)
+#include "chrome/browser/banners/app_banner_infobar_delegate.h"
+#include "chrome/browser/extensions/bookmark_app_helper.h"
+#endif
+
namespace {
base::TimeDelta gTimeDeltaForTesting;
@@ -136,6 +142,23 @@ bool AppBannerDataFetcher::OnMessageReceived(
return handled;
}
+void AppBannerDataFetcher::FinishCreateBookmarkApp(
+ const extensions::Extension* extension,
+ const WebApplicationInfo& web_app_info) {
+ content::WebContents* web_contents = GetWebContents();
+ if (web_contents) {
+ if (extension == nullptr) {
+ AppBannerSettingsHelper::RecordBannerDismissEvent(
+ web_contents, web_app_data_.start_url.spec(),
+ "AppBanner.WebApp.Dismissed", event_request_id_);
+ } else {
+ AppBannerSettingsHelper::RecordBannerWebInstallEvent(
+ web_contents, web_app_data_.start_url.spec(),
+ "AppBanner.WebApp.Installed", event_request_id_);
+ }
+ }
+}
+
void AppBannerDataFetcher::OnBannerPromptReply(
content::RenderFrameHost* render_frame_host,
int request_id,
@@ -158,11 +181,7 @@ void AppBannerDataFetcher::OnBannerPromptReply(
FOR_EACH_OBSERVER(Observer, observer_list_,
OnDecidedWhetherToShow(this, true));
- infobars::InfoBar* infobar = CreateBanner(app_icon_.get(), app_title_);
- if (infobar) {
- InfoBarService::FromWebContents(web_contents)->AddInfoBar(
- make_scoped_ptr(infobar));
- }
+ CreateBanner(app_icon_.get(), app_title_);
is_active_ = false;
}
@@ -205,16 +224,33 @@ bool AppBannerDataFetcher::FetchIcon(const GURL& image_url) {
return true;
}
+// This method is overridden on Android to provide a mobile-specific
+// implementation. The guards are required to avoid missing references to the
+// bookmark app helper, which is *not* compiled on Android.
infobars::InfoBar* AppBannerDataFetcher::CreateBanner(
const SkBitmap* icon,
const base::string16& title) {
content::WebContents* web_contents = GetWebContents();
DCHECK(web_contents && !web_app_data_.IsEmpty());
+ infobars::InfoBar* infobar = nullptr;
+
+#if !defined(OS_ANDROID)
+ Profile* profile =
+ Profile::FromBrowserContext(web_contents->GetBrowserContext());
+ WebApplicationInfo web_app_info;
+
+ bookmark_app_helper_.reset(
+ new extensions::BookmarkAppHelper(profile, web_app_info, web_contents));
+
+ infobar = AppBannerInfoBarDelegate::Create(
+ make_scoped_refptr(this), web_contents, web_app_data(),
+ bookmark_app_helper_.get(), event_request_id());
+ if (infobar) {
+ RecordDidShowBanner("AppBanner.WebApp.Shown");
+ }
+#endif
- // TODO(dfalcantara): Desktop doesn't display app banners, yet. Just pretend
- // that a banner was shown for testing purposes.
- RecordDidShowBanner("AppBanner.WebApp.Shown");
- return nullptr;
+ return infobar;
}
void AppBannerDataFetcher::RecordDidShowBanner(const std::string& event_name) {

Powered by Google App Engine
This is Rietveld 408576698