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/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
336 web_contents()->GetMainFrame()->GetRemoteInterfaces()->GetInterface( | 336 web_contents()->GetMainFrame()->GetRemoteInterfaces()->GetInterface( |
337 mojo::MakeRequest(&controller_)); | 337 mojo::MakeRequest(&controller_)); |
338 | 338 |
339 controller_->BannerPromptRequest( | 339 controller_->BannerPromptRequest( |
340 binding_.CreateInterfacePtrAndBind(), mojo::MakeRequest(&event_), | 340 binding_.CreateInterfacePtrAndBind(), mojo::MakeRequest(&event_), |
341 {GetBannerType()}, | 341 {GetBannerType()}, |
342 base::Bind(&AppBannerManager::OnBannerPromptReply, GetWeakPtr())); | 342 base::Bind(&AppBannerManager::OnBannerPromptReply, GetWeakPtr())); |
343 } | 343 } |
344 | 344 |
345 void AppBannerManager::DidStartNavigation(content::NavigationHandle* handle) { | 345 void AppBannerManager::DidStartNavigation(content::NavigationHandle* handle) { |
346 if (!handle->IsInMainFrame() || handle->IsSamePage()) | 346 if (!handle->IsInMainFrame() || handle->IsSameDocument()) |
347 return; | 347 return; |
348 | 348 |
349 load_finished_ = false; | 349 load_finished_ = false; |
350 if (GetSiteEngagementService() == nullptr) { | 350 if (GetSiteEngagementService() == nullptr) { |
351 // Ensure that we are observing the site engagement service on navigation | 351 // Ensure that we are observing the site engagement service on navigation |
352 // start. This may be the first navigation, or we may have stopped | 352 // start. This may be the first navigation, or we may have stopped |
353 // observing if the banner flow was triggered on the previous page. | 353 // observing if the banner flow was triggered on the previous page. |
354 SiteEngagementObserver::Observe(SiteEngagementService::Get( | 354 SiteEngagementObserver::Observe(SiteEngagementService::Get( |
355 Profile::FromBrowserContext(web_contents()->GetBrowserContext()))); | 355 Profile::FromBrowserContext(web_contents()->GetBrowserContext()))); |
356 } | 356 } |
357 } | 357 } |
358 | 358 |
359 void AppBannerManager::DidFinishNavigation(content::NavigationHandle* handle) { | 359 void AppBannerManager::DidFinishNavigation(content::NavigationHandle* handle) { |
360 if (handle->IsInMainFrame() && handle->HasCommitted() && | 360 if (handle->IsInMainFrame() && handle->HasCommitted() && |
361 !handle->IsSamePage()) { | 361 !handle->IsSameDocument()) { |
362 ResetCurrentPageData(); | 362 ResetCurrentPageData(); |
363 if (is_active_) | 363 if (is_active_) |
364 Stop(); | 364 Stop(); |
365 } | 365 } |
366 } | 366 } |
367 | 367 |
368 void AppBannerManager::DidFinishLoad( | 368 void AppBannerManager::DidFinishLoad( |
369 content::RenderFrameHost* render_frame_host, | 369 content::RenderFrameHost* render_frame_host, |
370 const GURL& validated_url) { | 370 const GURL& validated_url) { |
371 // Don't start the banner flow unless the main frame has finished loading. | 371 // Don't start the banner flow unless the main frame has finished loading. |
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
527 // Simulate a non-canceled OnBannerPromptReply to show the delayed banner. | 527 // Simulate a non-canceled OnBannerPromptReply to show the delayed banner. |
528 // Don't reset |was_canceled_by_page_| yet for metrics purposes. | 528 // Don't reset |was_canceled_by_page_| yet for metrics purposes. |
529 OnBannerPromptReply(blink::mojom::AppBannerPromptReply::NONE, referrer_); | 529 OnBannerPromptReply(blink::mojom::AppBannerPromptReply::NONE, referrer_); |
530 } else { | 530 } else { |
531 // Log that the prompt request was made for when we get the prompt reply. | 531 // Log that the prompt request was made for when we get the prompt reply. |
532 page_requested_prompt_ = true; | 532 page_requested_prompt_ = true; |
533 } | 533 } |
534 } | 534 } |
535 | 535 |
536 } // namespace banners | 536 } // namespace banners |
OLD | NEW |