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

Unified Diff: chrome/browser/banners/app_banner_data_fetcher_desktop.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: Reuploading 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_desktop.cc
diff --git a/chrome/browser/banners/app_banner_data_fetcher_desktop.cc b/chrome/browser/banners/app_banner_data_fetcher_desktop.cc
new file mode 100644
index 0000000000000000000000000000000000000000..c8a2bdbb6d9b00ddcfa5c2a08914489ca1915df0
--- /dev/null
+++ b/chrome/browser/banners/app_banner_data_fetcher_desktop.cc
@@ -0,0 +1,81 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/banners/app_banner_data_fetcher_desktop.h"
+
+#include "chrome/browser/banners/app_banner_infobar_delegate_desktop.h"
+#include "chrome/browser/banners/app_banner_settings_helper.h"
+#include "chrome/browser/extensions/bookmark_app_helper.h"
+#include "chrome/browser/profiles/profile.h"
+#include "chrome/common/render_messages.h"
+#include "chrome/common/web_application_info.h"
+#include "content/public/browser/render_frame_host.h"
+
+namespace banners {
+
+AppBannerDataFetcherDesktop::AppBannerDataFetcherDesktop(
+ content::WebContents* web_contents,
+ base::WeakPtr<Delegate> weak_delegate,
+ int ideal_icon_size)
+ : AppBannerDataFetcher(web_contents, weak_delegate, ideal_icon_size) {
+}
+
+AppBannerDataFetcherDesktop::~AppBannerDataFetcherDesktop() {
+}
+
+void AppBannerDataFetcherDesktop::ShowBanner(const SkBitmap* icon,
+ const base::string16& title) {
+ content::WebContents* web_contents = GetWebContents();
+ DCHECK(web_contents && !web_app_data().IsEmpty());
+ infobars::InfoBar* infobar = nullptr;
benwells 2015/06/03 06:13:55 Nit: This decl can just go down to line 44.
dominickn (DO NOT USE) 2015/06/03 07:10:36 Done.
+
+ Profile* profile =
+ Profile::FromBrowserContext(web_contents->GetBrowserContext());
+ WebApplicationInfo web_app_info;
benwells 2015/06/03 06:13:55 Nit: You don't need this variable, you can just pu
dominickn (DO NOT USE) 2015/06/03 07:10:36 Done.
+
+ bookmark_app_helper_.reset(
+ new extensions::BookmarkAppHelper(profile, web_app_info, web_contents));
+
+ // This differs from the Android infobar creation, which has an explicit
+ // InfoBarAndroid class interfacing with Java. On Android, the data fetcher
+ // calls the InfoBarService to show the banner. On desktop, an InfoBar class
+ // is not required, so the InfoBarService call is made within the delegate.
+ infobar = AppBannerInfoBarDelegateDesktop::Create(
+ make_scoped_refptr(this), web_contents, web_app_data(),
+ bookmark_app_helper_.get(), event_request_id());
+ if (infobar) {
+ RecordDidShowBanner("AppBanner.WebApp.Shown");
+ }
+}
+
+void AppBannerDataFetcherDesktop::FinishCreateBookmarkApp(
+ const extensions::Extension* extension,
+ const WebApplicationInfo& web_app_info) {
+ content::WebContents* web_contents = GetWebContents();
+ if (web_contents) {
+ // A null extension pointer indicates that the bookmark app install was
+ // not successful.
+ if (extension == nullptr) {
+ web_contents->GetMainFrame()->Send(
+ new ChromeViewMsg_AppBannerDismissed(
+ web_contents->GetMainFrame()->GetRoutingID(),
+ event_request_id()));
+
+ AppBannerSettingsHelper::RecordBannerDismissEvent(
+ web_contents, web_app_data().start_url.spec(),
+ AppBannerSettingsHelper::WEB);
+ } else {
+ web_contents->GetMainFrame()->Send(
+ new ChromeViewMsg_AppBannerAccepted(
+ web_contents->GetMainFrame()->GetRoutingID(),
+ event_request_id(), "web"));
+
+ AppBannerSettingsHelper::RecordBannerInstallEvent(
+ web_contents, web_app_data().start_url.spec(),
+ AppBannerSettingsHelper::WEB);
+ }
+ }
+}
+
+} // namespace banners

Powered by Google App Engine
This is Rietveld 408576698