Chromium Code Reviews| 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" |
|
dominickn
2017/02/06 05:22:00
#include "base/macros.h" for DISALLOW_COPY_AND_ASS
| |
| 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" |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 85 // invalidate our weak pointers so it terminates. | 85 // invalidate our weak pointers so it terminates. |
| 86 if (is_active_) { | 86 if (is_active_) { |
| 87 if (URLsAreForTheSamePage(validated_url, contents->GetLastCommittedURL())) | 87 if (URLsAreForTheSamePage(validated_url, contents->GetLastCommittedURL())) |
| 88 return; | 88 return; |
| 89 else | 89 else |
| 90 weak_factory_.InvalidateWeakPtrs(); | 90 weak_factory_.InvalidateWeakPtrs(); |
| 91 } | 91 } |
| 92 | 92 |
| 93 is_active_ = true; | 93 is_active_ = true; |
| 94 is_debug_mode_ = is_debug_mode; | 94 is_debug_mode_ = is_debug_mode; |
| 95 was_canceled_by_page_ = false; | |
| 96 page_requested_prompt_ = false; | |
| 95 | 97 |
| 96 // We only need to call ReportStatus if we aren't in debug mode (this avoids | 98 // We only need to call ReportStatus if we aren't in debug mode (this avoids |
| 97 // skew from testing). | 99 // skew from testing). |
| 98 DCHECK(!need_to_log_status_); | 100 DCHECK(!need_to_log_status_); |
| 99 need_to_log_status_ = !IsDebugMode(); | 101 need_to_log_status_ = !IsDebugMode(); |
| 100 | 102 |
| 101 // Exit if this is an incognito window, non-main frame, or insecure context. | 103 // Exit if this is an incognito window, non-main frame, or insecure context. |
| 102 InstallableStatusCode code = NO_ERROR_DETECTED; | 104 InstallableStatusCode code = NO_ERROR_DETECTED; |
| 103 if (Profile::FromBrowserContext(contents->GetBrowserContext()) | 105 if (Profile::FromBrowserContext(contents->GetBrowserContext()) |
| 104 ->IsOffTheRecord()) { | 106 ->IsOffTheRecord()) { |
| (...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 325 // InstallableManager (e.g. the renderer crashes or the browser is shutting | 327 // InstallableManager (e.g. the renderer crashes or the browser is shutting |
| 326 // down). These situations are explicitly not logged. | 328 // down). These situations are explicitly not logged. |
| 327 DCHECK(!need_to_log_status_ || is_active_); | 329 DCHECK(!need_to_log_status_ || is_active_); |
| 328 | 330 |
| 329 weak_factory_.InvalidateWeakPtrs(); | 331 weak_factory_.InvalidateWeakPtrs(); |
| 330 binding_.Close(); | 332 binding_.Close(); |
| 331 controller_.reset(); | 333 controller_.reset(); |
| 332 event_.reset(); | 334 event_.reset(); |
| 333 | 335 |
| 334 is_active_ = false; | 336 is_active_ = false; |
| 335 was_canceled_by_page_ = false; | |
| 336 page_requested_prompt_ = false; | |
| 337 need_to_log_status_ = false; | 337 need_to_log_status_ = false; |
| 338 } | 338 } |
| 339 | 339 |
| 340 void AppBannerManager::SendBannerPromptRequest() { | 340 void AppBannerManager::SendBannerPromptRequest() { |
| 341 RecordCouldShowBanner(); | 341 RecordCouldShowBanner(); |
| 342 | 342 |
| 343 TrackBeforeInstallEvent(BEFORE_INSTALL_EVENT_CREATED); | 343 TrackBeforeInstallEvent(BEFORE_INSTALL_EVENT_CREATED); |
| 344 event_request_id_ = ++gCurrentRequestID; | 344 event_request_id_ = ++gCurrentRequestID; |
| 345 | 345 |
| 346 web_contents()->GetMainFrame()->GetRemoteInterfaces()->GetInterface( | 346 web_contents()->GetMainFrame()->GetRemoteInterfaces()->GetInterface( |
| (...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 537 // Simulate a non-canceled OnBannerPromptReply to show the delayed banner. | 537 // Simulate a non-canceled OnBannerPromptReply to show the delayed banner. |
| 538 // Don't reset |was_canceled_by_page_| yet for metrics purposes. | 538 // Don't reset |was_canceled_by_page_| yet for metrics purposes. |
| 539 OnBannerPromptReply(blink::mojom::AppBannerPromptReply::NONE, referrer_); | 539 OnBannerPromptReply(blink::mojom::AppBannerPromptReply::NONE, referrer_); |
| 540 } else { | 540 } else { |
| 541 // Log that the prompt request was made for when we get the prompt reply. | 541 // Log that the prompt request was made for when we get the prompt reply. |
| 542 page_requested_prompt_ = true; | 542 page_requested_prompt_ = true; |
| 543 } | 543 } |
| 544 } | 544 } |
| 545 | 545 |
| 546 } // namespace banners | 546 } // namespace banners |
| OLD | NEW |