Chromium Code Reviews| OLD | NEW |
|---|---|
| (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_settings_helper.h" | |
| 9 #include "chrome/browser/extensions/bookmark_app_helper.h" | |
| 10 #include "chrome/browser/profiles/profile.h" | |
| 11 #include "chrome/common/render_messages.h" | |
| 12 #include "chrome/common/web_application_info.h" | |
| 13 #include "content/public/browser/render_frame_host.h" | |
| 14 | |
| 15 namespace banners { | |
| 16 | |
| 17 AppBannerDataFetcherDesktop::AppBannerDataFetcherDesktop( | |
| 18 content::WebContents* web_contents, | |
| 19 base::WeakPtr<Delegate> weak_delegate, | |
| 20 int ideal_icon_size) | |
| 21 : AppBannerDataFetcher(web_contents, weak_delegate, ideal_icon_size) { | |
| 22 } | |
| 23 | |
| 24 AppBannerDataFetcherDesktop::~AppBannerDataFetcherDesktop() { | |
| 25 } | |
| 26 | |
| 27 void AppBannerDataFetcherDesktop::ShowBanner(const SkBitmap* icon, | |
| 28 const base::string16& title) { | |
| 29 content::WebContents* web_contents = GetWebContents(); | |
| 30 DCHECK(web_contents && !web_app_data().IsEmpty()); | |
| 31 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.
| |
| 32 | |
| 33 Profile* profile = | |
| 34 Profile::FromBrowserContext(web_contents->GetBrowserContext()); | |
| 35 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.
| |
| 36 | |
| 37 bookmark_app_helper_.reset( | |
| 38 new extensions::BookmarkAppHelper(profile, web_app_info, web_contents)); | |
| 39 | |
| 40 // This differs from the Android infobar creation, which has an explicit | |
| 41 // InfoBarAndroid class interfacing with Java. On Android, the data fetcher | |
| 42 // calls the InfoBarService to show the banner. On desktop, an InfoBar class | |
| 43 // is not required, so the InfoBarService call is made within the delegate. | |
| 44 infobar = AppBannerInfoBarDelegateDesktop::Create( | |
| 45 make_scoped_refptr(this), web_contents, web_app_data(), | |
| 46 bookmark_app_helper_.get(), event_request_id()); | |
| 47 if (infobar) { | |
| 48 RecordDidShowBanner("AppBanner.WebApp.Shown"); | |
| 49 } | |
| 50 } | |
| 51 | |
| 52 void AppBannerDataFetcherDesktop::FinishCreateBookmarkApp( | |
| 53 const extensions::Extension* extension, | |
| 54 const WebApplicationInfo& web_app_info) { | |
| 55 content::WebContents* web_contents = GetWebContents(); | |
| 56 if (web_contents) { | |
| 57 // A null extension pointer indicates that the bookmark app install was | |
| 58 // not successful. | |
| 59 if (extension == nullptr) { | |
| 60 web_contents->GetMainFrame()->Send( | |
| 61 new ChromeViewMsg_AppBannerDismissed( | |
| 62 web_contents->GetMainFrame()->GetRoutingID(), | |
| 63 event_request_id())); | |
| 64 | |
| 65 AppBannerSettingsHelper::RecordBannerDismissEvent( | |
| 66 web_contents, web_app_data().start_url.spec(), | |
| 67 AppBannerSettingsHelper::WEB); | |
| 68 } else { | |
| 69 web_contents->GetMainFrame()->Send( | |
| 70 new ChromeViewMsg_AppBannerAccepted( | |
| 71 web_contents->GetMainFrame()->GetRoutingID(), | |
| 72 event_request_id(), "web")); | |
| 73 | |
| 74 AppBannerSettingsHelper::RecordBannerInstallEvent( | |
| 75 web_contents, web_app_data().start_url.spec(), | |
| 76 AppBannerSettingsHelper::WEB); | |
| 77 } | |
| 78 } | |
| 79 } | |
| 80 | |
| 81 } // namespace banners | |
| OLD | NEW |