| 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.h" | 5 #include "chrome/browser/banners/app_banner_manager.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 132 } | 132 } |
| 133 | 133 |
| 134 void AppBannerManager::SendBannerDismissed(int request_id) { | 134 void AppBannerManager::SendBannerDismissed(int request_id) { |
| 135 if (request_id != gCurrentRequestID) | 135 if (request_id != gCurrentRequestID) |
| 136 return; | 136 return; |
| 137 | 137 |
| 138 DCHECK(event_.is_bound()); | 138 DCHECK(event_.is_bound()); |
| 139 event_->BannerDismissed(); | 139 event_->BannerDismissed(); |
| 140 } | 140 } |
| 141 | 141 |
| 142 base::WeakPtr<AppBannerManager> AppBannerManager::GetWeakPtr() { |
| 143 return weak_factory_.GetWeakPtr(); |
| 144 } |
| 145 |
| 142 AppBannerManager::AppBannerManager(content::WebContents* web_contents) | 146 AppBannerManager::AppBannerManager(content::WebContents* web_contents) |
| 143 : content::WebContentsObserver(web_contents), | 147 : content::WebContentsObserver(web_contents), |
| 144 SiteEngagementObserver(SiteEngagementService::Get( | 148 SiteEngagementObserver(SiteEngagementService::Get( |
| 145 Profile::FromBrowserContext(web_contents->GetBrowserContext()))), | 149 Profile::FromBrowserContext(web_contents->GetBrowserContext()))), |
| 146 state_(State::INACTIVE), | 150 state_(State::INACTIVE), |
| 147 manager_(nullptr), | 151 manager_(nullptr), |
| 148 event_request_id_(-1), | 152 event_request_id_(-1), |
| 149 binding_(this), | 153 binding_(this), |
| 150 has_sufficient_engagement_(false), | 154 has_sufficient_engagement_(false), |
| 151 load_finished_(false), | 155 load_finished_(false), |
| (...skipping 29 matching lines...) Expand all Loading... |
| 181 } | 185 } |
| 182 | 186 |
| 183 int AppBannerManager::GetIdealPrimaryIconSizeInPx() { | 187 int AppBannerManager::GetIdealPrimaryIconSizeInPx() { |
| 184 return InstallableManager::GetMinimumIconSizeInPx(); | 188 return InstallableManager::GetMinimumIconSizeInPx(); |
| 185 } | 189 } |
| 186 | 190 |
| 187 int AppBannerManager::GetMinimumPrimaryIconSizeInPx() { | 191 int AppBannerManager::GetMinimumPrimaryIconSizeInPx() { |
| 188 return InstallableManager::GetMinimumIconSizeInPx(); | 192 return InstallableManager::GetMinimumIconSizeInPx(); |
| 189 } | 193 } |
| 190 | 194 |
| 191 base::WeakPtr<AppBannerManager> AppBannerManager::GetWeakPtr() { | |
| 192 return weak_factory_.GetWeakPtr(); | |
| 193 } | |
| 194 | |
| 195 bool AppBannerManager::IsDebugMode() const { | 195 bool AppBannerManager::IsDebugMode() const { |
| 196 return is_debug_mode_ || | 196 return is_debug_mode_ || |
| 197 base::CommandLine::ForCurrentProcess()->HasSwitch( | 197 base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 198 switches::kBypassAppBannerEngagementChecks); | 198 switches::kBypassAppBannerEngagementChecks); |
| 199 } | 199 } |
| 200 | 200 |
| 201 bool AppBannerManager::IsWebAppInstalled( | 201 bool AppBannerManager::IsWebAppInstalled( |
| 202 content::BrowserContext* browser_context, | 202 content::BrowserContext* browser_context, |
| 203 const GURL& start_url, | 203 const GURL& start_url, |
| 204 const GURL& manifest_url) { | 204 const GURL& manifest_url) { |
| (...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 550 if (is_pending_event()) { | 550 if (is_pending_event()) { |
| 551 // Simulate a non-canceled OnBannerPromptReply to show the delayed banner. | 551 // Simulate a non-canceled OnBannerPromptReply to show the delayed banner. |
| 552 OnBannerPromptReply(blink::mojom::AppBannerPromptReply::NONE, referrer_); | 552 OnBannerPromptReply(blink::mojom::AppBannerPromptReply::NONE, referrer_); |
| 553 } else { | 553 } else { |
| 554 // Log that the prompt request was made for when we get the prompt reply. | 554 // Log that the prompt request was made for when we get the prompt reply. |
| 555 page_requested_prompt_ = true; | 555 page_requested_prompt_ = true; |
| 556 } | 556 } |
| 557 } | 557 } |
| 558 | 558 |
| 559 } // namespace banners | 559 } // namespace banners |
| OLD | NEW |