| OLD | NEW |
| 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_manager_desktop.h" | 5 #include "chrome/browser/banners/app_banner_manager_desktop.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/feature_list.h" | 8 #include "base/feature_list.h" |
| 9 #include "build/build_config.h" | 9 #include "build/build_config.h" |
| 10 #include "chrome/browser/banners/app_banner_infobar_delegate_desktop.h" | 10 #include "chrome/browser/banners/app_banner_infobar_delegate_desktop.h" |
| (...skipping 24 matching lines...) Expand all Loading... |
| 35 const extensions::Extension* extension, | 35 const extensions::Extension* extension, |
| 36 const WebApplicationInfo& web_app_info) { | 36 const WebApplicationInfo& web_app_info) { |
| 37 content::WebContents* contents = web_contents(); | 37 content::WebContents* contents = web_contents(); |
| 38 if (contents) { | 38 if (contents) { |
| 39 // A null extension pointer indicates that the bookmark app install was | 39 // A null extension pointer indicates that the bookmark app install was |
| 40 // not successful. Call Stop() to terminate the flow. Don't record a dismiss | 40 // not successful. Call Stop() to terminate the flow. Don't record a dismiss |
| 41 // metric here because the banner isn't necessarily dismissed. | 41 // metric here because the banner isn't necessarily dismissed. |
| 42 if (extension == nullptr) { | 42 if (extension == nullptr) { |
| 43 Stop(); | 43 Stop(); |
| 44 } else { | 44 } else { |
| 45 SendBannerAccepted(event_request_id()); | 45 SendBannerAccepted(); |
| 46 | 46 |
| 47 AppBannerSettingsHelper::RecordBannerInstallEvent( | 47 AppBannerSettingsHelper::RecordBannerInstallEvent( |
| 48 contents, GetAppIdentifier(), AppBannerSettingsHelper::WEB); | 48 contents, GetAppIdentifier(), AppBannerSettingsHelper::WEB); |
| 49 } | 49 } |
| 50 } | 50 } |
| 51 } | 51 } |
| 52 | 52 |
| 53 bool AppBannerManagerDesktop::IsWebAppInstalled( | 53 bool AppBannerManagerDesktop::IsWebAppInstalled( |
| 54 content::BrowserContext* browser_context, | 54 content::BrowserContext* browser_context, |
| 55 const GURL& start_url, | 55 const GURL& start_url, |
| (...skipping 10 matching lines...) Expand all Loading... |
| 66 WebApplicationInfo web_app_info; | 66 WebApplicationInfo web_app_info; |
| 67 | 67 |
| 68 bookmark_app_helper_.reset( | 68 bookmark_app_helper_.reset( |
| 69 new extensions::BookmarkAppHelper(profile, web_app_info, contents)); | 69 new extensions::BookmarkAppHelper(profile, web_app_info, contents)); |
| 70 | 70 |
| 71 // This differs from Android, where there is a concrete | 71 // This differs from Android, where there is a concrete |
| 72 // AppBannerInfoBarAndroid class to interface with Java, and the manager calls | 72 // AppBannerInfoBarAndroid class to interface with Java, and the manager calls |
| 73 // the InfoBarService to show the banner. On desktop, an InfoBar class | 73 // the InfoBarService to show the banner. On desktop, an InfoBar class |
| 74 // is not required, and the delegate calls the InfoBarService. | 74 // is not required, and the delegate calls the InfoBarService. |
| 75 infobars::InfoBar* infobar = AppBannerInfoBarDelegateDesktop::Create( | 75 infobars::InfoBar* infobar = AppBannerInfoBarDelegateDesktop::Create( |
| 76 contents, GetWeakPtr(), bookmark_app_helper_.get(), manifest_, | 76 contents, GetWeakPtr(), bookmark_app_helper_.get(), manifest_); |
| 77 event_request_id()); | |
| 78 if (infobar) { | 77 if (infobar) { |
| 79 RecordDidShowBanner("AppBanner.WebApp.Shown"); | 78 RecordDidShowBanner("AppBanner.WebApp.Shown"); |
| 80 TrackDisplayEvent(DISPLAY_EVENT_WEB_APP_BANNER_CREATED); | 79 TrackDisplayEvent(DISPLAY_EVENT_WEB_APP_BANNER_CREATED); |
| 81 ReportStatus(contents, SHOWING_WEB_APP_BANNER); | 80 ReportStatus(contents, SHOWING_WEB_APP_BANNER); |
| 82 } else { | 81 } else { |
| 83 ReportStatus(contents, FAILED_TO_CREATE_BANNER); | 82 ReportStatus(contents, FAILED_TO_CREATE_BANNER); |
| 84 } | 83 } |
| 85 } | 84 } |
| 86 | 85 |
| 87 void AppBannerManagerDesktop::DidFinishLoad( | 86 void AppBannerManagerDesktop::DidFinishLoad( |
| (...skipping 13 matching lines...) Expand all Loading... |
| 101 double score) { | 100 double score) { |
| 102 // Explicitly forbid banners from triggering on navigation unless this is | 101 // Explicitly forbid banners from triggering on navigation unless this is |
| 103 // enabled. | 102 // enabled. |
| 104 if (!IsEnabled()) | 103 if (!IsEnabled()) |
| 105 return; | 104 return; |
| 106 | 105 |
| 107 AppBannerManager::OnEngagementIncreased(web_contents, url, score); | 106 AppBannerManager::OnEngagementIncreased(web_contents, url, score); |
| 108 } | 107 } |
| 109 | 108 |
| 110 } // namespace banners | 109 } // namespace banners |
| OLD | NEW |