| 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/page_load_metrics/metrics_web_contents_observer.h" | 5 #include "chrome/browser/page_load_metrics/metrics_web_contents_observer.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <ostream> | 8 #include <ostream> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 97 host->GetWidget()->RemoveInputEventObserver(this); | 97 host->GetWidget()->RemoveInputEventObserver(this); |
| 98 } | 98 } |
| 99 | 99 |
| 100 void MetricsWebContentsObserver::RenderViewHostChanged( | 100 void MetricsWebContentsObserver::RenderViewHostChanged( |
| 101 content::RenderViewHost* old_host, | 101 content::RenderViewHost* old_host, |
| 102 content::RenderViewHost* new_host) { | 102 content::RenderViewHost* new_host) { |
| 103 UnregisterInputEventObserver(old_host); | 103 UnregisterInputEventObserver(old_host); |
| 104 RegisterInputEventObserver(new_host); | 104 RegisterInputEventObserver(new_host); |
| 105 } | 105 } |
| 106 | 106 |
| 107 void MetricsWebContentsObserver::MediaStartedPlaying( |
| 108 const content::WebContentsObserver::MediaPlayerInfo& video_type, |
| 109 const content::WebContentsObserver::MediaPlayerId& id) { |
| 110 content::RenderFrameHost* render_frame_host = id.first; |
| 111 if (!render_frame_host->GetRenderViewHost() || |
| 112 render_frame_host->GetRenderViewHost()->GetMainFrame() != |
| 113 web_contents()->GetMainFrame()) { |
| 114 // Ignore media that starts playing in a document that was navigated away |
| 115 // from. |
| 116 return; |
| 117 } |
| 118 if (committed_load_) |
| 119 committed_load_->MediaStartedPlaying( |
| 120 video_type, render_frame_host == web_contents()->GetMainFrame()); |
| 121 } |
| 122 |
| 107 bool MetricsWebContentsObserver::OnMessageReceived( | 123 bool MetricsWebContentsObserver::OnMessageReceived( |
| 108 const IPC::Message& message, | 124 const IPC::Message& message, |
| 109 content::RenderFrameHost* render_frame_host) { | 125 content::RenderFrameHost* render_frame_host) { |
| 110 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 126 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| 111 bool handled = true; | 127 bool handled = true; |
| 112 IPC_BEGIN_MESSAGE_MAP_WITH_PARAM(MetricsWebContentsObserver, message, | 128 IPC_BEGIN_MESSAGE_MAP_WITH_PARAM(MetricsWebContentsObserver, message, |
| 113 render_frame_host) | 129 render_frame_host) |
| 114 IPC_MESSAGE_HANDLER(PageLoadMetricsMsg_TimingUpdated, OnTimingUpdated) | 130 IPC_MESSAGE_HANDLER(PageLoadMetricsMsg_TimingUpdated, OnTimingUpdated) |
| 115 IPC_MESSAGE_UNHANDLED(handled = false) | 131 IPC_MESSAGE_UNHANDLED(handled = false) |
| 116 IPC_END_MESSAGE_MAP() | 132 IPC_END_MESSAGE_MAP() |
| (...skipping 441 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 558 content::NavigationHandle* navigation_handle) const { | 574 content::NavigationHandle* navigation_handle) const { |
| 559 DCHECK(navigation_handle->IsInMainFrame()); | 575 DCHECK(navigation_handle->IsInMainFrame()); |
| 560 DCHECK(!navigation_handle->HasCommitted() || | 576 DCHECK(!navigation_handle->HasCommitted() || |
| 561 !navigation_handle->IsSameDocument()); | 577 !navigation_handle->IsSameDocument()); |
| 562 | 578 |
| 563 return BrowserPageTrackDecider(embedder_interface_.get(), web_contents(), | 579 return BrowserPageTrackDecider(embedder_interface_.get(), web_contents(), |
| 564 navigation_handle).ShouldTrack(); | 580 navigation_handle).ShouldTrack(); |
| 565 } | 581 } |
| 566 | 582 |
| 567 } // namespace page_load_metrics | 583 } // namespace page_load_metrics |
| OLD | NEW |