| 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/engagement/site_engagement_helper.h" | 5 #include "chrome/browser/engagement/site_engagement_helper.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/time/time.h" | 9 #include "base/time/time.h" |
| 10 #include "base/trace_event/trace_event.h" | 10 #include "base/trace_event/trace_event.h" |
| (...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 180 } | 180 } |
| 181 | 181 |
| 182 void SiteEngagementService::Helper::RecordMediaPlaying(bool is_hidden) { | 182 void SiteEngagementService::Helper::RecordMediaPlaying(bool is_hidden) { |
| 183 content::WebContents* contents = web_contents(); | 183 content::WebContents* contents = web_contents(); |
| 184 if (contents && service_) | 184 if (contents && service_) |
| 185 service_->HandleMediaPlaying(contents, is_hidden); | 185 service_->HandleMediaPlaying(contents, is_hidden); |
| 186 } | 186 } |
| 187 | 187 |
| 188 void SiteEngagementService::Helper::DidFinishNavigation( | 188 void SiteEngagementService::Helper::DidFinishNavigation( |
| 189 content::NavigationHandle* handle) { | 189 content::NavigationHandle* handle) { |
| 190 input_tracker_.Stop(); | |
| 191 media_tracker_.Stop(); | |
| 192 | |
| 193 // Ignore all schemes except HTTP and HTTPS, as well as uncommitted, non | 190 // Ignore all schemes except HTTP and HTTPS, as well as uncommitted, non |
| 194 // main-frame, same page, or error page navigations. | 191 // main-frame, same page, or error page navigations. |
| 195 record_engagement_ = handle->GetURL().SchemeIsHTTPOrHTTPS(); | 192 record_engagement_ = handle->GetURL().SchemeIsHTTPOrHTTPS(); |
| 196 if (!handle->HasCommitted() || !handle->IsInMainFrame() || | 193 if (!handle->HasCommitted() || !handle->IsInMainFrame() || |
| 197 handle->IsSamePage() || handle->IsErrorPage() || !record_engagement_) { | 194 handle->IsSamePage() || handle->IsErrorPage() || !record_engagement_) { |
| 198 return; | 195 return; |
| 199 } | 196 } |
| 200 | 197 |
| 198 input_tracker_.Stop(); |
| 199 media_tracker_.Stop(); |
| 200 |
| 201 // Ignore prerender loads. This means that prerenders will not receive | 201 // Ignore prerender loads. This means that prerenders will not receive |
| 202 // navigation engagement. The implications are as follows: | 202 // navigation engagement. The implications are as follows: |
| 203 // | 203 // |
| 204 // - Instant search prerenders from the omnibox trigger DidFinishNavigation | 204 // - Instant search prerenders from the omnibox trigger DidFinishNavigation |
| 205 // twice: once for the prerender, and again when the page swaps in. The | 205 // twice: once for the prerender, and again when the page swaps in. The |
| 206 // second trigger has transition GENERATED and receives navigation | 206 // second trigger has transition GENERATED and receives navigation |
| 207 // engagement. | 207 // engagement. |
| 208 // - Prerenders initiated by <link rel="prerender"> (e.g. search results) are | 208 // - Prerenders initiated by <link rel="prerender"> (e.g. search results) are |
| 209 // always assigned the LINK transition, which is ignored for navigation | 209 // always assigned the LINK transition, which is ignored for navigation |
| 210 // engagement. | 210 // engagement. |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 244 void SiteEngagementService::Helper::SetSecondsTrackingDelayAfterNavigation( | 244 void SiteEngagementService::Helper::SetSecondsTrackingDelayAfterNavigation( |
| 245 int seconds) { | 245 int seconds) { |
| 246 g_seconds_delay_after_navigation = seconds; | 246 g_seconds_delay_after_navigation = seconds; |
| 247 } | 247 } |
| 248 | 248 |
| 249 // static | 249 // static |
| 250 void SiteEngagementService::Helper::SetSecondsTrackingDelayAfterShow( | 250 void SiteEngagementService::Helper::SetSecondsTrackingDelayAfterShow( |
| 251 int seconds) { | 251 int seconds) { |
| 252 g_seconds_delay_after_show = seconds; | 252 g_seconds_delay_after_show = seconds; |
| 253 } | 253 } |
| OLD | NEW |