| 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/strings/string_number_conversions.h" | 8 #include "base/strings/string_number_conversions.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 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 82 // This differs from Android, where there is a concrete | 82 // This differs from Android, where there is a concrete |
| 83 // AppBannerInfoBarAndroid class to interface with Java, and the manager calls | 83 // AppBannerInfoBarAndroid class to interface with Java, and the manager calls |
| 84 // the InfoBarService to show the banner. On desktop, an InfoBar class | 84 // the InfoBarService to show the banner. On desktop, an InfoBar class |
| 85 // is not required, and the delegate calls the InfoBarService. | 85 // is not required, and the delegate calls the InfoBarService. |
| 86 infobars::InfoBar* infobar = AppBannerInfoBarDelegateDesktop::Create( | 86 infobars::InfoBar* infobar = AppBannerInfoBarDelegateDesktop::Create( |
| 87 contents, GetWeakPtr(), bookmark_app_helper_.get(), manifest_, | 87 contents, GetWeakPtr(), bookmark_app_helper_.get(), manifest_, |
| 88 event_request_id()); | 88 event_request_id()); |
| 89 if (infobar) { | 89 if (infobar) { |
| 90 RecordDidShowBanner("AppBanner.WebApp.Shown"); | 90 RecordDidShowBanner("AppBanner.WebApp.Shown"); |
| 91 TrackDisplayEvent(DISPLAY_EVENT_WEB_APP_BANNER_CREATED); | 91 TrackDisplayEvent(DISPLAY_EVENT_WEB_APP_BANNER_CREATED); |
| 92 ReportStatus(contents, SHOWING_WEB_APP_BANNER); |
| 93 } else { |
| 94 ReportStatus(contents, FAILED_TO_CREATE_BANNER); |
| 92 } | 95 } |
| 93 } | 96 } |
| 94 | 97 |
| 95 void AppBannerManagerDesktop::DidFinishLoad( | 98 void AppBannerManagerDesktop::DidFinishLoad( |
| 96 content::RenderFrameHost* render_frame_host, | 99 content::RenderFrameHost* render_frame_host, |
| 97 const GURL& validated_url) { | 100 const GURL& validated_url) { |
| 98 // Explicitly forbid banners from triggering on navigation unless this is | 101 // Explicitly forbid banners from triggering on navigation unless this is |
| 99 // enabled. | 102 // enabled. |
| 100 if (!IsEnabled()) | 103 if (!IsEnabled()) |
| 101 return; | 104 return; |
| 102 | 105 |
| 103 AppBannerManager::DidFinishLoad(render_frame_host, validated_url); | 106 AppBannerManager::DidFinishLoad(render_frame_host, validated_url); |
| 104 } | 107 } |
| 105 | 108 |
| 106 void AppBannerManagerDesktop::OnEngagementIncreased( | 109 void AppBannerManagerDesktop::OnEngagementIncreased( |
| 107 content::WebContents* web_contents, | 110 content::WebContents* web_contents, |
| 108 const GURL& url, | 111 const GURL& url, |
| 109 double score) { | 112 double score) { |
| 110 // Explicitly forbid banners from triggering on navigation unless this is | 113 // Explicitly forbid banners from triggering on navigation unless this is |
| 111 // enabled. | 114 // enabled. |
| 112 if (!IsEnabled()) | 115 if (!IsEnabled()) |
| 113 return; | 116 return; |
| 114 | 117 |
| 115 AppBannerManager::OnEngagementIncreased(web_contents, url, score); | 118 AppBannerManager::OnEngagementIncreased(web_contents, url, score); |
| 116 } | 119 } |
| 117 | 120 |
| 118 } // namespace banners | 121 } // namespace banners |
| OLD | NEW |