| 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/callback.h" | 10 #include "base/callback.h" |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 128 binding_.Close(); | 128 binding_.Close(); |
| 129 | 129 |
| 130 manager_->GetData( | 130 manager_->GetData( |
| 131 ParamsToGetManifest(), | 131 ParamsToGetManifest(), |
| 132 base::Bind(&AppBannerManager::OnDidGetManifest, GetWeakPtr())); | 132 base::Bind(&AppBannerManager::OnDidGetManifest, GetWeakPtr())); |
| 133 } | 133 } |
| 134 | 134 |
| 135 void AppBannerManager::OnInstall() { | 135 void AppBannerManager::OnInstall() { |
| 136 blink::mojom::InstallationServicePtr installation_service; | 136 blink::mojom::InstallationServicePtr installation_service; |
| 137 web_contents()->GetMainFrame()->GetRemoteInterfaces()->GetInterface( | 137 web_contents()->GetMainFrame()->GetRemoteInterfaces()->GetInterface( |
| 138 mojo::GetProxy(&installation_service)); | 138 mojo::MakeRequest(&installation_service)); |
| 139 DCHECK(installation_service); | 139 DCHECK(installation_service); |
| 140 installation_service->OnInstall(); | 140 installation_service->OnInstall(); |
| 141 } | 141 } |
| 142 | 142 |
| 143 void AppBannerManager::SendBannerAccepted(int request_id) { | 143 void AppBannerManager::SendBannerAccepted(int request_id) { |
| 144 if (request_id != gCurrentRequestID) | 144 if (request_id != gCurrentRequestID) |
| 145 return; | 145 return; |
| 146 | 146 |
| 147 DCHECK(event_.is_bound()); | 147 DCHECK(event_.is_bound()); |
| 148 event_->BannerAccepted(GetBannerType()); | 148 event_->BannerAccepted(GetBannerType()); |
| (...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 351 // for stopping now is that the app has been added to the homescreen. | 351 // for stopping now is that the app has been added to the homescreen. |
| 352 if (!IsDebugMode() && !CheckIfShouldShowBanner()) { | 352 if (!IsDebugMode() && !CheckIfShouldShowBanner()) { |
| 353 Stop(); | 353 Stop(); |
| 354 return; | 354 return; |
| 355 } | 355 } |
| 356 | 356 |
| 357 TrackBeforeInstallEvent(BEFORE_INSTALL_EVENT_CREATED); | 357 TrackBeforeInstallEvent(BEFORE_INSTALL_EVENT_CREATED); |
| 358 event_request_id_ = ++gCurrentRequestID; | 358 event_request_id_ = ++gCurrentRequestID; |
| 359 | 359 |
| 360 web_contents()->GetMainFrame()->GetRemoteInterfaces()->GetInterface( | 360 web_contents()->GetMainFrame()->GetRemoteInterfaces()->GetInterface( |
| 361 mojo::GetProxy(&controller_)); | 361 mojo::MakeRequest(&controller_)); |
| 362 | 362 |
| 363 controller_->BannerPromptRequest( | 363 controller_->BannerPromptRequest( |
| 364 binding_.CreateInterfacePtrAndBind(), mojo::GetProxy(&event_), | 364 binding_.CreateInterfacePtrAndBind(), mojo::MakeRequest(&event_), |
| 365 {GetBannerType()}, | 365 {GetBannerType()}, |
| 366 base::Bind(&AppBannerManager::OnBannerPromptReply, GetWeakPtr())); | 366 base::Bind(&AppBannerManager::OnBannerPromptReply, GetWeakPtr())); |
| 367 } | 367 } |
| 368 | 368 |
| 369 void AppBannerManager::DidStartNavigation(content::NavigationHandle* handle) { | 369 void AppBannerManager::DidStartNavigation(content::NavigationHandle* handle) { |
| 370 if (!handle->IsInMainFrame() || handle->IsSamePage()) | 370 if (!handle->IsInMainFrame() || handle->IsSamePage()) |
| 371 return; | 371 return; |
| 372 | 372 |
| 373 load_finished_ = false; | 373 load_finished_ = false; |
| 374 if (GetSiteEngagementService() == nullptr) { | 374 if (GetSiteEngagementService() == nullptr) { |
| (...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 545 // Simulate a non-canceled OnBannerPromptReply to show the delayed banner. | 545 // Simulate a non-canceled OnBannerPromptReply to show the delayed banner. |
| 546 // Don't reset |was_canceled_by_page_| yet for metrics purposes. | 546 // Don't reset |was_canceled_by_page_| yet for metrics purposes. |
| 547 OnBannerPromptReply(blink::mojom::AppBannerPromptReply::NONE, referrer_); | 547 OnBannerPromptReply(blink::mojom::AppBannerPromptReply::NONE, referrer_); |
| 548 } else { | 548 } else { |
| 549 // Log that the prompt request was made for when we get the prompt reply. | 549 // Log that the prompt request was made for when we get the prompt reply. |
| 550 page_requested_prompt_ = true; | 550 page_requested_prompt_ = true; |
| 551 } | 551 } |
| 552 } | 552 } |
| 553 | 553 |
| 554 } // namespace banners | 554 } // namespace banners |
| OLD | NEW |