| 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 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 142 | 142 |
| 143 base::WeakPtr<AppBannerManager> AppBannerManager::GetWeakPtr() { | 143 base::WeakPtr<AppBannerManager> AppBannerManager::GetWeakPtr() { |
| 144 return weak_factory_.GetWeakPtr(); | 144 return weak_factory_.GetWeakPtr(); |
| 145 } | 145 } |
| 146 | 146 |
| 147 AppBannerManager::AppBannerManager(content::WebContents* web_contents) | 147 AppBannerManager::AppBannerManager(content::WebContents* web_contents) |
| 148 : content::WebContentsObserver(web_contents), | 148 : content::WebContentsObserver(web_contents), |
| 149 SiteEngagementObserver(SiteEngagementService::Get( | 149 SiteEngagementObserver(SiteEngagementService::Get( |
| 150 Profile::FromBrowserContext(web_contents->GetBrowserContext()))), | 150 Profile::FromBrowserContext(web_contents->GetBrowserContext()))), |
| 151 state_(State::INACTIVE), | 151 state_(State::INACTIVE), |
| 152 manager_(nullptr), | 152 manager_(InstallableManager::FromWebContents(web_contents)), |
| 153 event_request_id_(-1), | 153 event_request_id_(-1), |
| 154 binding_(this), | 154 binding_(this), |
| 155 has_sufficient_engagement_(false), | 155 has_sufficient_engagement_(false), |
| 156 load_finished_(false), | 156 load_finished_(false), |
| 157 page_requested_prompt_(false), | 157 page_requested_prompt_(false), |
| 158 triggered_by_devtools_(false), | 158 triggered_by_devtools_(false), |
| 159 need_to_log_status_(false), | 159 need_to_log_status_(false), |
| 160 weak_factory_(this) { | 160 weak_factory_(this) { |
| 161 // Ensure the InstallableManager exists since we have a hard dependency on it. | |
| 162 InstallableManager::CreateForWebContents(web_contents); | |
| 163 manager_ = InstallableManager::FromWebContents(web_contents); | |
| 164 DCHECK(manager_); | 161 DCHECK(manager_); |
| 165 | 162 |
| 166 AppBannerSettingsHelper::UpdateFromFieldTrial(); | 163 AppBannerSettingsHelper::UpdateFromFieldTrial(); |
| 167 } | 164 } |
| 168 | 165 |
| 169 AppBannerManager::~AppBannerManager() { } | 166 AppBannerManager::~AppBannerManager() { } |
| 170 | 167 |
| 171 std::string AppBannerManager::GetAppIdentifier() { | 168 std::string AppBannerManager::GetAppIdentifier() { |
| 172 DCHECK(!manifest_.IsEmpty()); | 169 DCHECK(!manifest_.IsEmpty()); |
| 173 return manifest_.start_url.spec(); | 170 return manifest_.start_url.spec(); |
| (...skipping 413 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 587 if (is_pending_event()) { | 584 if (is_pending_event()) { |
| 588 // Simulate a non-canceled OnBannerPromptReply to show the delayed banner. | 585 // Simulate a non-canceled OnBannerPromptReply to show the delayed banner. |
| 589 OnBannerPromptReply(blink::mojom::AppBannerPromptReply::NONE, referrer_); | 586 OnBannerPromptReply(blink::mojom::AppBannerPromptReply::NONE, referrer_); |
| 590 } else { | 587 } else { |
| 591 // Log that the prompt request was made for when we get the prompt reply. | 588 // Log that the prompt request was made for when we get the prompt reply. |
| 592 page_requested_prompt_ = true; | 589 page_requested_prompt_ = true; |
| 593 } | 590 } |
| 594 } | 591 } |
| 595 | 592 |
| 596 } // namespace banners | 593 } // namespace banners |
| OLD | NEW |