| 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" |
| 11 #include "base/command_line.h" | 11 #include "base/command_line.h" |
| 12 #include "base/strings/string_number_conversions.h" | 12 #include "base/strings/string_number_conversions.h" |
| 13 #include "base/time/time.h" | 13 #include "base/time/time.h" |
| 14 #include "chrome/browser/banners/app_banner_metrics.h" | 14 #include "chrome/browser/banners/app_banner_metrics.h" |
| 15 #include "chrome/browser/banners/app_banner_settings_helper.h" | 15 #include "chrome/browser/banners/app_banner_settings_helper.h" |
| 16 #include "chrome/browser/browser_process.h" | 16 #include "chrome/browser/browser_process.h" |
| 17 #include "chrome/browser/engagement/site_engagement_service.h" | 17 #include "chrome/browser/engagement/site_engagement_service.h" |
| 18 #include "chrome/browser/profiles/profile.h" | 18 #include "chrome/browser/profiles/profile.h" |
| 19 #include "chrome/common/chrome_switches.h" | 19 #include "chrome/common/chrome_switches.h" |
| 20 #include "components/rappor/public/rappor_utils.h" | 20 #include "components/rappor/public/rappor_utils.h" |
| 21 #include "components/rappor/rappor_service_impl.h" | 21 #include "components/rappor/rappor_service_impl.h" |
| 22 #include "content/public/browser/navigation_handle.h" | 22 #include "content/public/browser/navigation_handle.h" |
| 23 #include "content/public/browser/render_frame_host.h" | 23 #include "content/public/browser/render_frame_host.h" |
| 24 #include "content/public/browser/web_contents.h" | 24 #include "content/public/browser/web_contents.h" |
| 25 #include "content/public/common/origin_util.h" | 25 #include "content/public/common/origin_util.h" |
| 26 #include "mojo/public/cpp/bindings/interface_request.h" |
| 26 #include "services/service_manager/public/cpp/interface_provider.h" | 27 #include "services/service_manager/public/cpp/interface_provider.h" |
| 27 #include "third_party/skia/include/core/SkBitmap.h" | 28 #include "third_party/skia/include/core/SkBitmap.h" |
| 28 #include "ui/display/display.h" | 29 #include "ui/display/display.h" |
| 29 #include "ui/display/screen.h" | 30 #include "ui/display/screen.h" |
| 30 | 31 |
| 31 namespace { | 32 namespace { |
| 32 | 33 |
| 33 int gCurrentRequestID = -1; | 34 int gCurrentRequestID = -1; |
| 34 int gTimeDeltaInDaysForTesting = 0; | 35 int gTimeDeltaInDaysForTesting = 0; |
| 35 | 36 |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 125 | 126 |
| 126 // Any existing binding is invalid when we request a new banner. | 127 // Any existing binding is invalid when we request a new banner. |
| 127 if (binding_.is_bound()) | 128 if (binding_.is_bound()) |
| 128 binding_.Close(); | 129 binding_.Close(); |
| 129 | 130 |
| 130 manager_->GetData( | 131 manager_->GetData( |
| 131 ParamsToGetManifest(), | 132 ParamsToGetManifest(), |
| 132 base::Bind(&AppBannerManager::OnDidGetManifest, GetWeakPtr())); | 133 base::Bind(&AppBannerManager::OnDidGetManifest, GetWeakPtr())); |
| 133 } | 134 } |
| 134 | 135 |
| 136 void AppBannerManager::OnInstall() { |
| 137 if (!installation_service_) { |
| 138 web_contents()->GetMainFrame()->GetRemoteInterfaces()->GetInterface( |
| 139 mojo::GetProxy(&installation_service_)); |
| 140 DCHECK(installation_service_); |
| 141 } |
| 142 installation_service_->OnInstall(); |
| 143 } |
| 144 |
| 135 void AppBannerManager::SendBannerAccepted(int request_id) { | 145 void AppBannerManager::SendBannerAccepted(int request_id) { |
| 136 if (request_id != gCurrentRequestID) | 146 if (request_id != gCurrentRequestID) |
| 137 return; | 147 return; |
| 138 | 148 |
| 139 DCHECK(event_.is_bound()); | 149 DCHECK(event_.is_bound()); |
| 140 event_->BannerAccepted(GetBannerType()); | 150 event_->BannerAccepted(GetBannerType()); |
| 141 } | 151 } |
| 142 | 152 |
| 143 void AppBannerManager::SendBannerDismissed(int request_id) { | 153 void AppBannerManager::SendBannerDismissed(int request_id) { |
| 144 if (request_id != gCurrentRequestID) | 154 if (request_id != gCurrentRequestID) |
| (...skipping 395 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 540 // Simulate a non-canceled OnBannerPromptReply to show the delayed banner. | 550 // Simulate a non-canceled OnBannerPromptReply to show the delayed banner. |
| 541 // Don't reset |was_canceled_by_page_| yet for metrics purposes. | 551 // Don't reset |was_canceled_by_page_| yet for metrics purposes. |
| 542 OnBannerPromptReply(blink::mojom::AppBannerPromptReply::NONE, referrer_); | 552 OnBannerPromptReply(blink::mojom::AppBannerPromptReply::NONE, referrer_); |
| 543 } else { | 553 } else { |
| 544 // 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. |
| 545 page_requested_prompt_ = true; | 555 page_requested_prompt_ = true; |
| 546 } | 556 } |
| 547 } | 557 } |
| 548 | 558 |
| 549 } // namespace banners | 559 } // namespace banners |
| OLD | NEW |