| 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 <utility> |
| 8 |
| 7 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 8 #include "base/strings/string_number_conversions.h" | |
| 9 #include "build/build_config.h" | 10 #include "build/build_config.h" |
| 10 #include "chrome/browser/banners/app_banner_infobar_delegate_desktop.h" | 11 #include "chrome/browser/banners/app_banner_infobar_delegate_desktop.h" |
| 11 #include "chrome/browser/banners/app_banner_metrics.h" | 12 #include "chrome/browser/banners/app_banner_metrics.h" |
| 12 #include "chrome/browser/banners/app_banner_settings_helper.h" | 13 #include "chrome/browser/banners/app_banner_settings_helper.h" |
| 13 #include "chrome/browser/extensions/bookmark_app_helper.h" | 14 #include "chrome/browser/extensions/bookmark_app_helper.h" |
| 14 #include "chrome/browser/profiles/profile.h" | 15 #include "chrome/browser/profiles/profile.h" |
| 15 #include "chrome/common/chrome_switches.h" | 16 #include "chrome/common/chrome_switches.h" |
| 16 #include "chrome/common/render_messages.h" | |
| 17 #include "chrome/common/web_application_info.h" | 17 #include "chrome/common/web_application_info.h" |
| 18 #include "content/public/browser/render_frame_host.h" | 18 #include "content/public/browser/render_frame_host.h" |
| 19 #include "extensions/common/constants.h" | 19 #include "extensions/common/constants.h" |
| 20 | 20 |
| 21 DEFINE_WEB_CONTENTS_USER_DATA_KEY(banners::AppBannerManagerDesktop); | 21 DEFINE_WEB_CONTENTS_USER_DATA_KEY(banners::AppBannerManagerDesktop); |
| 22 | 22 |
| 23 namespace banners { | 23 namespace banners { |
| 24 | 24 |
| 25 bool AppBannerManagerDesktop::IsEnabled() { | 25 bool AppBannerManagerDesktop::IsEnabled() { |
| 26 #if defined(OS_CHROMEOS) | 26 #if defined(OS_CHROMEOS) |
| (...skipping 10 matching lines...) Expand all Loading... |
| 37 : AppBannerManager(web_contents) { } | 37 : AppBannerManager(web_contents) { } |
| 38 | 38 |
| 39 AppBannerManagerDesktop::~AppBannerManagerDesktop() { } | 39 AppBannerManagerDesktop::~AppBannerManagerDesktop() { } |
| 40 | 40 |
| 41 void AppBannerManagerDesktop::DidFinishCreatingBookmarkApp( | 41 void AppBannerManagerDesktop::DidFinishCreatingBookmarkApp( |
| 42 const extensions::Extension* extension, | 42 const extensions::Extension* extension, |
| 43 const WebApplicationInfo& web_app_info) { | 43 const WebApplicationInfo& web_app_info) { |
| 44 content::WebContents* contents = web_contents(); | 44 content::WebContents* contents = web_contents(); |
| 45 if (contents) { | 45 if (contents) { |
| 46 // A null extension pointer indicates that the bookmark app install was | 46 // A null extension pointer indicates that the bookmark app install was |
| 47 // not successful. | 47 // not successful. Call Stop() to terminate the flow. Don't record a dismiss |
| 48 // metric here because the banner isn't necessarily dismissed. |
| 48 if (extension == nullptr) { | 49 if (extension == nullptr) { |
| 49 contents->GetMainFrame()->Send(new ChromeViewMsg_AppBannerDismissed( | 50 Stop(); |
| 50 contents->GetMainFrame()->GetRoutingID(), event_request_id())); | |
| 51 | |
| 52 AppBannerSettingsHelper::RecordBannerDismissEvent( | |
| 53 contents, GetAppIdentifier(), AppBannerSettingsHelper::WEB); | |
| 54 } else { | 51 } else { |
| 55 contents->GetMainFrame()->Send(new ChromeViewMsg_AppBannerAccepted( | 52 SendBannerAccepted(event_request_id()); |
| 56 contents->GetMainFrame()->GetRoutingID(), event_request_id(), | |
| 57 GetBannerType())); | |
| 58 | 53 |
| 59 AppBannerSettingsHelper::RecordBannerInstallEvent( | 54 AppBannerSettingsHelper::RecordBannerInstallEvent( |
| 60 contents, GetAppIdentifier(), AppBannerSettingsHelper::WEB); | 55 contents, GetAppIdentifier(), AppBannerSettingsHelper::WEB); |
| 61 } | 56 } |
| 62 } | 57 } |
| 63 } | 58 } |
| 64 | 59 |
| 65 bool AppBannerManagerDesktop::IsWebAppInstalled( | 60 bool AppBannerManagerDesktop::IsWebAppInstalled( |
| 66 content::BrowserContext* browser_context, | 61 content::BrowserContext* browser_context, |
| 67 const GURL& start_url) { | 62 const GURL& start_url) { |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 112 double score) { | 107 double score) { |
| 113 // Explicitly forbid banners from triggering on navigation unless this is | 108 // Explicitly forbid banners from triggering on navigation unless this is |
| 114 // enabled. | 109 // enabled. |
| 115 if (!IsEnabled()) | 110 if (!IsEnabled()) |
| 116 return; | 111 return; |
| 117 | 112 |
| 118 AppBannerManager::OnEngagementIncreased(web_contents, url, score); | 113 AppBannerManager::OnEngagementIncreased(web_contents, url, score); |
| 119 } | 114 } |
| 120 | 115 |
| 121 } // namespace banners | 116 } // namespace banners |
| OLD | NEW |