Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(455)

Side by Side Diff: chrome/browser/banners/app_banner_manager.cc

Issue 2553013004: Remove the app banner navigation heuristic. (Closed)
Patch Set: Rebase Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 return base::Time::Now() + 65 return base::Time::Now() +
66 base::TimeDelta::FromDays(gTimeDeltaInDaysForTesting); 66 base::TimeDelta::FromDays(gTimeDeltaInDaysForTesting);
67 } 67 }
68 68
69 // static 69 // static
70 void AppBannerManager::SetTimeDeltaForTesting(int days) { 70 void AppBannerManager::SetTimeDeltaForTesting(int days) {
71 gTimeDeltaInDaysForTesting = days; 71 gTimeDeltaInDaysForTesting = days;
72 } 72 }
73 73
74 // static 74 // static
75 void AppBannerManager::SetEngagementWeights(double direct_engagement, 75 void AppBannerManager::SetTotalEngagementToTrigger(double engagement) {
76 double indirect_engagement) { 76 AppBannerSettingsHelper::SetTotalEngagementToTrigger(engagement);
77 AppBannerSettingsHelper::SetEngagementWeights(direct_engagement,
78 indirect_engagement);
79 } 77 }
80 78
81 // static 79 // static
82 bool AppBannerManager::URLsAreForTheSamePage(const GURL& first, 80 bool AppBannerManager::URLsAreForTheSamePage(const GURL& first,
83 const GURL& second) { 81 const GURL& second) {
84 return first.GetWithEmptyPath() == second.GetWithEmptyPath() && 82 return first.GetWithEmptyPath() == second.GetWithEmptyPath() &&
85 first.path_piece() == second.path_piece() && 83 first.path_piece() == second.path_piece() &&
86 first.query_piece() == second.query_piece(); 84 first.query_piece() == second.query_piece();
87 } 85 }
88 86
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after
356 binding_.CreateInterfacePtrAndBind(), mojo::GetProxy(&event_), 354 binding_.CreateInterfacePtrAndBind(), mojo::GetProxy(&event_),
357 {GetBannerType()}, 355 {GetBannerType()},
358 base::Bind(&AppBannerManager::OnBannerPromptReply, GetWeakPtr())); 356 base::Bind(&AppBannerManager::OnBannerPromptReply, GetWeakPtr()));
359 } 357 }
360 358
361 void AppBannerManager::DidStartNavigation(content::NavigationHandle* handle) { 359 void AppBannerManager::DidStartNavigation(content::NavigationHandle* handle) {
362 if (!handle->IsInMainFrame() || handle->IsSamePage()) 360 if (!handle->IsInMainFrame() || handle->IsSamePage())
363 return; 361 return;
364 362
365 load_finished_ = false; 363 load_finished_ = false;
366 if (AppBannerSettingsHelper::ShouldUseSiteEngagementScore() && 364 if (GetSiteEngagementService() == nullptr) {
367 GetSiteEngagementService() == nullptr) {
368 // Ensure that we are observing the site engagement service on navigation 365 // Ensure that we are observing the site engagement service on navigation
369 // start. This may be the first navigation, or we may have stopped 366 // start. This may be the first navigation, or we may have stopped
370 // observing if the banner flow was triggered on the previous page. 367 // observing if the banner flow was triggered on the previous page.
371 SiteEngagementObserver::Observe(SiteEngagementService::Get( 368 SiteEngagementObserver::Observe(SiteEngagementService::Get(
372 Profile::FromBrowserContext(web_contents()->GetBrowserContext()))); 369 Profile::FromBrowserContext(web_contents()->GetBrowserContext())));
373 } 370 }
374 } 371 }
375 372
376 void AppBannerManager::DidFinishNavigation(content::NavigationHandle* handle) { 373 void AppBannerManager::DidFinishNavigation(content::NavigationHandle* handle) {
377 if (handle->IsInMainFrame() && handle->HasCommitted() && 374 if (handle->IsInMainFrame() && handle->HasCommitted() &&
378 !handle->IsSamePage()) { 375 !handle->IsSamePage()) {
379 last_transition_type_ = handle->GetPageTransition();
380 active_media_players_.clear(); 376 active_media_players_.clear();
381 if (is_active_) 377 if (is_active_)
382 Stop(); 378 Stop();
383 } 379 }
384 } 380 }
385 381
386 void AppBannerManager::DidFinishLoad( 382 void AppBannerManager::DidFinishLoad(
387 content::RenderFrameHost* render_frame_host, 383 content::RenderFrameHost* render_frame_host,
388 const GURL& validated_url) { 384 const GURL& validated_url) {
389 // Don't start the banner flow unless the main frame has finished loading. 385 // Don't start the banner flow unless the main frame has finished loading.
390 if (render_frame_host->GetParent()) 386 if (render_frame_host->GetParent())
391 return; 387 return;
392 388
393 load_finished_ = true; 389 load_finished_ = true;
394 validated_url_ = validated_url; 390 validated_url_ = validated_url;
395 // Start the pipeline immediately if we aren't using engagement, or if 0 391 // Start the pipeline immediately if 0 engagement is required or if we've
396 // engagement is required. 392 // queued a banner request.
397 if (!AppBannerSettingsHelper::ShouldUseSiteEngagementScore() || 393 if (banner_request_queued_ ||
398 banner_request_queued_ ||
399 AppBannerSettingsHelper::HasSufficientEngagement(0)) { 394 AppBannerSettingsHelper::HasSufficientEngagement(0)) {
400 SiteEngagementObserver::Observe(nullptr); 395 SiteEngagementObserver::Observe(nullptr);
401 banner_request_queued_ = false; 396 banner_request_queued_ = false;
402 397
403 RequestAppBanner(validated_url, false /* is_debug_mode */); 398 RequestAppBanner(validated_url, false /* is_debug_mode */);
404 } 399 }
405 } 400 }
406 401
407 void AppBannerManager::MediaStartedPlaying(const MediaPlayerInfo& media_info, 402 void AppBannerManager::MediaStartedPlaying(const MediaPlayerInfo& media_info,
408 const MediaPlayerId& id) { 403 const MediaPlayerId& id) {
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
441 // be safe to start this in response to user input. 436 // be safe to start this in response to user input.
442 RequestAppBanner(url, false /* is_debug_mode */); 437 RequestAppBanner(url, false /* is_debug_mode */);
443 } 438 }
444 } 439 }
445 } 440 }
446 441
447 void AppBannerManager::RecordCouldShowBanner() { 442 void AppBannerManager::RecordCouldShowBanner() {
448 content::WebContents* contents = web_contents(); 443 content::WebContents* contents = web_contents();
449 DCHECK(contents); 444 DCHECK(contents);
450 445
451 AppBannerSettingsHelper::RecordBannerCouldShowEvent( 446 AppBannerSettingsHelper::RecordBannerEvent(
452 contents, validated_url_, GetAppIdentifier(), 447 contents, validated_url_, GetAppIdentifier(),
453 GetCurrentTime(), last_transition_type_); 448 AppBannerSettingsHelper::APP_BANNER_EVENT_COULD_SHOW, GetCurrentTime());
454 } 449 }
455 450
456 bool AppBannerManager::CheckIfShouldShowBanner() { 451 bool AppBannerManager::CheckIfShouldShowBanner() {
457 content::WebContents* contents = web_contents(); 452 content::WebContents* contents = web_contents();
458 DCHECK(contents); 453 DCHECK(contents);
459 454
460 InstallableStatusCode code = AppBannerSettingsHelper::ShouldShowBanner( 455 InstallableStatusCode code = AppBannerSettingsHelper::ShouldShowBanner(
461 contents, validated_url_, GetAppIdentifier(), GetCurrentTime()); 456 contents, validated_url_, GetAppIdentifier(), GetCurrentTime());
462 if (code == NO_ERROR_DETECTED) 457 if (code == NO_ERROR_DETECTED)
463 return true; 458 return true;
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
540 // Simulate a non-canceled OnBannerPromptReply to show the delayed banner. 535 // Simulate a non-canceled OnBannerPromptReply to show the delayed banner.
541 // Don't reset |was_canceled_by_page_| yet for metrics purposes. 536 // Don't reset |was_canceled_by_page_| yet for metrics purposes.
542 OnBannerPromptReply(blink::mojom::AppBannerPromptReply::NONE, referrer_); 537 OnBannerPromptReply(blink::mojom::AppBannerPromptReply::NONE, referrer_);
543 } else { 538 } else {
544 // Log that the prompt request was made for when we get the prompt reply. 539 // Log that the prompt request was made for when we get the prompt reply.
545 page_requested_prompt_ = true; 540 page_requested_prompt_ = true;
546 } 541 }
547 } 542 }
548 543
549 } // namespace banners 544 } // namespace banners
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698