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

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

Issue 2515793002: 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 "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"
(...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after
328 } 328 }
329 329
330 TrackBeforeInstallEvent(BEFORE_INSTALL_EVENT_CREATED); 330 TrackBeforeInstallEvent(BEFORE_INSTALL_EVENT_CREATED);
331 event_request_id_ = ++gCurrentRequestID; 331 event_request_id_ = ++gCurrentRequestID;
332 content::RenderFrameHost* frame = web_contents()->GetMainFrame(); 332 content::RenderFrameHost* frame = web_contents()->GetMainFrame();
333 frame->Send(new ChromeViewMsg_AppBannerPromptRequest( 333 frame->Send(new ChromeViewMsg_AppBannerPromptRequest(
334 frame->GetRoutingID(), event_request_id_, GetBannerType())); 334 frame->GetRoutingID(), event_request_id_, GetBannerType()));
335 } 335 }
336 336
337 void AppBannerManager::DidStartNavigation(content::NavigationHandle* handle) { 337 void AppBannerManager::DidStartNavigation(content::NavigationHandle* handle) {
338 if (!handle->IsInMainFrame()) 338 if (!handle->IsInMainFrame() || handle->IsSamePage())
339 return; 339 return;
340 340
341 load_finished_ = false; 341 load_finished_ = false;
342 if (AppBannerSettingsHelper::ShouldUseSiteEngagementScore() && 342 if (AppBannerSettingsHelper::ShouldUseSiteEngagementScore() &&
343 GetSiteEngagementService() == nullptr) { 343 GetSiteEngagementService() == nullptr) {
344 // Ensure that we are observing the site engagement service on navigation 344 // Ensure that we are observing the site engagement service on navigation
345 // start. This may be the first navigation, or we may have stopped 345 // start. This may be the first navigation, or we may have stopped
346 // observing if the banner flow was triggered on the previous page. 346 // observing if the banner flow was triggered on the previous page.
347 SiteEngagementObserver::Observe(SiteEngagementService::Get( 347 SiteEngagementObserver::Observe(SiteEngagementService::Get(
348 Profile::FromBrowserContext(web_contents()->GetBrowserContext()))); 348 Profile::FromBrowserContext(web_contents()->GetBrowserContext())));
349 } 349 }
350 } 350 }
351 351
352 void AppBannerManager::DidFinishNavigation(content::NavigationHandle* handle) { 352 void AppBannerManager::DidFinishNavigation(content::NavigationHandle* handle) {
353 if (handle->IsInMainFrame() && handle->HasCommitted()) { 353 if (handle->IsInMainFrame() && handle->HasCommitted() &&
354 !handle->IsSamePage()) {
354 last_transition_type_ = handle->GetPageTransition(); 355 last_transition_type_ = handle->GetPageTransition();
355 active_media_players_.clear(); 356 active_media_players_.clear();
356 if (is_active_) 357 if (is_active_)
357 Stop(); 358 Stop();
358 } 359 }
359 } 360 }
360 361
361 void AppBannerManager::DidFinishLoad( 362 void AppBannerManager::DidFinishLoad(
362 content::RenderFrameHost* render_frame_host, 363 content::RenderFrameHost* render_frame_host,
363 const GURL& validated_url) { 364 const GURL& validated_url) {
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
533 // Don't reset |was_canceled_by_page_| yet for metrics purposes. 534 // Don't reset |was_canceled_by_page_| yet for metrics purposes.
534 OnBannerPromptReply(render_frame_host, request_id, 535 OnBannerPromptReply(render_frame_host, request_id,
535 blink::WebAppBannerPromptReply::None, referrer_); 536 blink::WebAppBannerPromptReply::None, referrer_);
536 } else { 537 } else {
537 // Log that the prompt request was made for when we get the prompt reply. 538 // Log that the prompt request was made for when we get the prompt reply.
538 page_requested_prompt_ = true; 539 page_requested_prompt_ = true;
539 } 540 }
540 } 541 }
541 542
542 } // namespace banners 543 } // 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