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

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

Issue 2156113002: Replace AppBannerDataFetcher with InstallableManager. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@banner-refactor
Patch Set: Naming, includes Created 4 years, 4 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/banners/app_banner_data_fetcher_desktop.h"
6
7 #include "chrome/browser/banners/app_banner_infobar_delegate_desktop.h"
8 #include "chrome/browser/banners/app_banner_metrics.h"
9 #include "chrome/browser/banners/app_banner_settings_helper.h"
10 #include "chrome/browser/extensions/bookmark_app_helper.h"
11 #include "chrome/browser/profiles/profile.h"
12 #include "chrome/common/render_messages.h"
13 #include "chrome/common/web_application_info.h"
14 #include "content/public/browser/render_frame_host.h"
15
16 namespace infobars {
17 class InfoBar;
18 } // namespace infobars
19
20 namespace banners {
21
22 AppBannerDataFetcherDesktop::AppBannerDataFetcherDesktop(
23 content::WebContents* web_contents,
24 base::WeakPtr<Delegate> weak_delegate,
25 int ideal_icon_size_in_dp,
26 int minimum_icon_size_in_dp,
27 bool is_debug_mode)
28 : AppBannerDataFetcher(web_contents,
29 weak_delegate,
30 ideal_icon_size_in_dp,
31 minimum_icon_size_in_dp,
32 is_debug_mode) {}
33
34 AppBannerDataFetcherDesktop::~AppBannerDataFetcherDesktop() {
35 }
36
37 bool AppBannerDataFetcherDesktop::IsWebAppInstalled(
38 content::BrowserContext* browser_context,
39 const GURL& start_url) {
40 return extensions::BookmarkAppHelper::BookmarkOrHostedAppInstalled(
41 browser_context, start_url);
42 }
43
44 void AppBannerDataFetcherDesktop::ShowBanner(const GURL& icon_url,
45 const SkBitmap* icon,
46 const base::string16& title,
47 const std::string& referrer) {
48 content::WebContents* web_contents = GetWebContents();
49 DCHECK(web_contents && !manifest().IsEmpty());
50
51 Profile* profile =
52 Profile::FromBrowserContext(web_contents->GetBrowserContext());
53 WebApplicationInfo web_app_info;
54
55 bookmark_app_helper_.reset(
56 new extensions::BookmarkAppHelper(profile, web_app_info, web_contents));
57
58 // This differs from the Android infobar creation, which has an explicit
59 // InfoBarAndroid class interfacing with Java. On Android, the data fetcher
60 // calls the InfoBarService to show the banner. On desktop, an InfoBar class
61 // is not required, so the InfoBarService call is made within the delegate.
62 infobars::InfoBar* infobar = AppBannerInfoBarDelegateDesktop::Create(
63 make_scoped_refptr(this), web_contents, manifest(),
64 bookmark_app_helper_.get(), event_request_id());
65 if (infobar) {
66 RecordDidShowBanner("AppBanner.WebApp.Shown");
67 TrackDisplayEvent(DISPLAY_EVENT_WEB_APP_BANNER_CREATED);
68 }
69 }
70
71 void AppBannerDataFetcherDesktop::FinishCreateBookmarkApp(
72 const extensions::Extension* extension,
73 const WebApplicationInfo& web_app_info) {
74 content::WebContents* web_contents = GetWebContents();
75 if (web_contents) {
76 // A null extension pointer indicates that the bookmark app install was
77 // not successful.
78 if (extension == nullptr) {
79 web_contents->GetMainFrame()->Send(
80 new ChromeViewMsg_AppBannerDismissed(
81 web_contents->GetMainFrame()->GetRoutingID(),
82 event_request_id()));
83
84 AppBannerSettingsHelper::RecordBannerDismissEvent(
85 web_contents, manifest().start_url.spec(),
86 AppBannerSettingsHelper::WEB);
87 } else {
88 web_contents->GetMainFrame()->Send(
89 new ChromeViewMsg_AppBannerAccepted(
90 web_contents->GetMainFrame()->GetRoutingID(),
91 event_request_id(), "web"));
92
93 AppBannerSettingsHelper::RecordBannerInstallEvent(
94 web_contents, manifest().start_url.spec(),
95 AppBannerSettingsHelper::WEB);
96 }
97 }
98 }
99
100 } // namespace banners
OLDNEW
« no previous file with comments | « chrome/browser/banners/app_banner_data_fetcher_desktop.h ('k') | chrome/browser/banners/app_banner_data_fetcher_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698