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

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

Issue 2507163003: Prevent in-page navigations from stopping the app banner pipeline. (Closed)
Patch Set: Created 4 years, 1 month 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 339 matching lines...) Expand 10 before | Expand all | Expand 10 after
350 web_contents()->GetMainFrame()->GetRemoteInterfaces()->GetInterface( 350 web_contents()->GetMainFrame()->GetRemoteInterfaces()->GetInterface(
351 mojo::GetProxy(&controller_)); 351 mojo::GetProxy(&controller_));
352 352
353 controller_->BannerPromptRequest( 353 controller_->BannerPromptRequest(
354 binding_.CreateInterfacePtrAndBind(), mojo::GetProxy(&event_), 354 binding_.CreateInterfacePtrAndBind(), mojo::GetProxy(&event_),
355 {GetBannerType()}, 355 {GetBannerType()},
356 base::Bind(&AppBannerManager::OnBannerPromptReply, GetWeakPtr())); 356 base::Bind(&AppBannerManager::OnBannerPromptReply, GetWeakPtr()));
357 } 357 }
358 358
359 void AppBannerManager::DidStartNavigation(content::NavigationHandle* handle) { 359 void AppBannerManager::DidStartNavigation(content::NavigationHandle* handle) {
360 if (!handle->IsInMainFrame()) 360 if (!handle->IsInMainFrame() || handle->IsSamePage())
361 return; 361 return;
362 362
363 load_finished_ = false; 363 load_finished_ = false;
364 if (AppBannerSettingsHelper::ShouldUseSiteEngagementScore() && 364 if (AppBannerSettingsHelper::ShouldUseSiteEngagementScore() &&
365 GetSiteEngagementService() == nullptr) { 365 GetSiteEngagementService() == nullptr) {
366 // Ensure that we are observing the site engagement service on navigation 366 // Ensure that we are observing the site engagement service on navigation
367 // start. This may be the first navigation, or we may have stopped 367 // start. This may be the first navigation, or we may have stopped
368 // observing if the banner flow was triggered on the previous page. 368 // observing if the banner flow was triggered on the previous page.
369 SiteEngagementObserver::Observe(SiteEngagementService::Get( 369 SiteEngagementObserver::Observe(SiteEngagementService::Get(
370 Profile::FromBrowserContext(web_contents()->GetBrowserContext()))); 370 Profile::FromBrowserContext(web_contents()->GetBrowserContext())));
371 } 371 }
372 } 372 }
373 373
374 void AppBannerManager::DidFinishNavigation(content::NavigationHandle* handle) { 374 void AppBannerManager::DidFinishNavigation(content::NavigationHandle* handle) {
375 if (handle->IsInMainFrame() && handle->HasCommitted()) { 375 if (handle->IsInMainFrame() && handle->HasCommitted() &&
376 !handle->IsSamePage()) {
376 last_transition_type_ = handle->GetPageTransition(); 377 last_transition_type_ = handle->GetPageTransition();
377 active_media_players_.clear(); 378 active_media_players_.clear();
378 if (is_active_) 379 if (is_active_)
379 Stop(); 380 Stop();
380 } 381 }
381 } 382 }
382 383
383 void AppBannerManager::DidFinishLoad( 384 void AppBannerManager::DidFinishLoad(
384 content::RenderFrameHost* render_frame_host, 385 content::RenderFrameHost* render_frame_host,
385 const GURL& validated_url) { 386 const GURL& validated_url) {
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
535 // Simulate a non-canceled OnBannerPromptReply to show the delayed banner. 536 // Simulate a non-canceled OnBannerPromptReply to show the delayed banner.
536 // Don't reset |was_canceled_by_page_| yet for metrics purposes. 537 // Don't reset |was_canceled_by_page_| yet for metrics purposes.
537 OnBannerPromptReply(blink::mojom::AppBannerPromptReply::NONE, referrer_); 538 OnBannerPromptReply(blink::mojom::AppBannerPromptReply::NONE, referrer_);
538 } else { 539 } else {
539 // Log that the prompt request was made for when we get the prompt reply. 540 // Log that the prompt request was made for when we get the prompt reply.
540 page_requested_prompt_ = true; 541 page_requested_prompt_ = true;
541 } 542 }
542 } 543 }
543 544
544 } // namespace banners 545 } // namespace banners
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698