| 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 "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/callback.h" | 8 #include "base/callback.h" |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
| 11 #include "base/time/time.h" | 11 #include "base/time/time.h" |
| 12 #include "chrome/browser/banners/app_banner_metrics.h" | 12 #include "chrome/browser/banners/app_banner_metrics.h" |
| 13 #include "chrome/browser/banners/app_banner_settings_helper.h" | 13 #include "chrome/browser/banners/app_banner_settings_helper.h" |
| 14 #include "chrome/browser/browser_process.h" | 14 #include "chrome/browser/browser_process.h" |
| 15 #include "chrome/browser/engagement/site_engagement_service.h" | 15 #include "chrome/browser/engagement/site_engagement_service.h" |
| 16 #include "chrome/browser/installable/installable_logging.h" | 16 #include "chrome/browser/installable/installable_logging.h" |
| 17 #include "chrome/browser/installable/installable_manager.h" | 17 #include "chrome/browser/installable/installable_manager.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 "chrome/common/render_messages.h" | 20 #include "chrome/common/render_messages.h" |
| 21 #include "components/rappor/rappor_utils.h" | 21 #include "components/rappor/rappor_utils.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" |
| 27 #include "services/shell/public/cpp/interface_provider.h" |
| 26 #include "third_party/WebKit/public/platform/modules/app_banner/WebAppBannerProm
ptReply.h" | 28 #include "third_party/WebKit/public/platform/modules/app_banner/WebAppBannerProm
ptReply.h" |
| 27 #include "third_party/skia/include/core/SkBitmap.h" | 29 #include "third_party/skia/include/core/SkBitmap.h" |
| 28 #include "ui/display/display.h" | 30 #include "ui/display/display.h" |
| 29 #include "ui/display/screen.h" | 31 #include "ui/display/screen.h" |
| 30 | 32 |
| 31 namespace { | 33 namespace { |
| 32 | 34 |
| 33 bool gDisableSecureCheckForTesting = false; | 35 bool gDisableSecureCheckForTesting = false; |
| 34 int gCurrentRequestID = -1; | 36 int gCurrentRequestID = -1; |
| 35 base::LazyInstance<base::TimeDelta> gTimeDeltaForTesting = | 37 base::LazyInstance<base::TimeDelta> gTimeDeltaForTesting = |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 127 } | 129 } |
| 128 | 130 |
| 129 if (validated_url_.is_empty()) | 131 if (validated_url_.is_empty()) |
| 130 validated_url_ = validated_url; | 132 validated_url_ = validated_url; |
| 131 | 133 |
| 132 manager_->GetData( | 134 manager_->GetData( |
| 133 ParamsToGetManifest(), | 135 ParamsToGetManifest(), |
| 134 base::Bind(&AppBannerManager::OnDidGetManifest, GetWeakPtr())); | 136 base::Bind(&AppBannerManager::OnDidGetManifest, GetWeakPtr())); |
| 135 } | 137 } |
| 136 | 138 |
| 139 void AppBannerManager::OnInstall() { |
| 140 if (!installation_service_) { |
| 141 web_contents()->GetMainFrame()->GetRemoteInterfaces()->GetInterface( |
| 142 mojo::GetProxy(&installation_service_)); |
| 143 DCHECK(installation_service_); |
| 144 } |
| 145 installation_service_->OnInstall(); |
| 146 } |
| 147 |
| 137 base::Closure AppBannerManager::FetchWebappSplashScreenImageCallback( | 148 base::Closure AppBannerManager::FetchWebappSplashScreenImageCallback( |
| 138 const std::string& webapp_id) { | 149 const std::string& webapp_id) { |
| 139 return base::Closure(); | 150 return base::Closure(); |
| 140 } | 151 } |
| 141 | 152 |
| 142 AppBannerManager::AppBannerManager(content::WebContents* web_contents) | 153 AppBannerManager::AppBannerManager(content::WebContents* web_contents) |
| 143 : content::WebContentsObserver(web_contents), | 154 : content::WebContentsObserver(web_contents), |
| 144 SiteEngagementObserver(nullptr), | 155 SiteEngagementObserver(nullptr), |
| 145 manager_(nullptr), | 156 manager_(nullptr), |
| 146 event_request_id_(-1), | 157 event_request_id_(-1), |
| (...skipping 386 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 533 // Don't reset |was_canceled_by_page_| yet for metrics purposes. | 544 // Don't reset |was_canceled_by_page_| yet for metrics purposes. |
| 534 OnBannerPromptReply(render_frame_host, request_id, | 545 OnBannerPromptReply(render_frame_host, request_id, |
| 535 blink::WebAppBannerPromptReply::None, referrer_); | 546 blink::WebAppBannerPromptReply::None, referrer_); |
| 536 } else { | 547 } else { |
| 537 // Log that the prompt request was made for when we get the prompt reply. | 548 // Log that the prompt request was made for when we get the prompt reply. |
| 538 page_requested_prompt_ = true; | 549 page_requested_prompt_ = true; |
| 539 } | 550 } |
| 540 } | 551 } |
| 541 | 552 |
| 542 } // namespace banners | 553 } // namespace banners |
| OLD | NEW |