Revert "[Media History] Fix watchtime recording"

This reverts commit c5b00d82d8a218f28296851c4b31e73eb9795822.

Reason for revert: Crash loop after login on Chrome OS (tested on Nocturne), got segfault at content/browser/web_contents/web_contents_impl.cc:7318

Original change's description:
> [Media History] Fix watchtime recording
> 
> Media History does not always record watchtime
> because the callback might be called after
> the WebContentsObserver has been destroyed.
> This moves it to WebContentsDelegate and adds
> some tests.
> 
> BUG=1051176
> 
> Change-Id: Ic60066535e3039cee07b2d0994c97e0279bd36e0
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2051289
> Reviewed-by: Kinuko Yasuda <[email protected]>
> Reviewed-by: Elly Fong-Jones <[email protected]>
> Reviewed-by: Tommy Steimel <[email protected]>
> Commit-Queue: Becca Hughes <[email protected]>
> Cr-Commit-Position: refs/heads/master@{#749888}

[email protected],[email protected],[email protected],[email protected]

Change-Id: I58f709c5268d1bf89c016e90f583ea8a7f6840d3
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: 1051176
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2101406
Reviewed-by: Shik Chen <[email protected]>
Commit-Queue: Shik Chen <[email protected]>
Cr-Commit-Position: refs/heads/master@{#750079}
diff --git a/content/browser/web_contents/web_contents_impl.cc b/content/browser/web_contents/web_contents_impl.cc
index df4e8b7..b57520fe 100644
--- a/content/browser/web_contents/web_contents_impl.cc
+++ b/content/browser/web_contents/web_contents_impl.cc
@@ -7301,12 +7301,18 @@
     observer.AudioContextPlaybackStopped(audio_context_id);
 }
 
+void WebContentsImpl::MediaWatchTimeChanged(
+    const content::MediaPlayerWatchTime& watch_time) {
+  for (auto& observer : observers_)
+    observer.MediaWatchTimeChanged(watch_time);
+}
+
 media::MediaMetricsProvider::RecordAggregateWatchTimeCallback
 WebContentsImpl::GetRecordAggregateWatchTimeCallback() {
   return base::BindRepeating(
-      [](base::WeakPtr<WebContentsDelegate> delegate, GURL last_committed_url,
-         base::TimeDelta total_watch_time, base::TimeDelta time_stamp,
-         bool has_video, bool has_audio) {
+      [](base::WeakPtr<RenderFrameHostDelegate> delegate,
+         GURL last_committed_url, base::TimeDelta total_watch_time,
+         base::TimeDelta time_stamp, bool has_video, bool has_audio) {
         content::MediaPlayerWatchTime watch_time(
             last_committed_url, last_committed_url.GetOrigin(),
             total_watch_time, time_stamp, has_video, has_audio);
@@ -7315,7 +7321,7 @@
         if (delegate)
           delegate->MediaWatchTimeChanged(watch_time);
       },
-      delegate_->GetDelegateWeakPtr(), GetMainFrameLastCommittedURL());
+      weak_factory_.GetWeakPtr(), GetMainFrameLastCommittedURL());
 }
 
 RenderFrameHostImpl* WebContentsImpl::GetMainFrameForInnerDelegate(