| OLD | NEW |
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 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 package org.chromium.content_public.browser; | 5 package org.chromium.content_public.browser; |
| 6 | 6 |
| 7 import org.chromium.content_public.common.MediaMetadata; | |
| 8 | |
| 9 import java.lang.ref.WeakReference; | 7 import java.lang.ref.WeakReference; |
| 10 | 8 |
| 11 /** | 9 /** |
| 12 * This class receives callbacks that act as hooks for various a native web cont
ents events related | 10 * This class receives callbacks that act as hooks for various a native web cont
ents events related |
| 13 * to loading a url. A single web contents can have multiple WebContentObservers
. | 11 * to loading a url. A single web contents can have multiple WebContentObservers
. |
| 14 */ | 12 */ |
| 15 public abstract class WebContentsObserver { | 13 public abstract class WebContentsObserver { |
| 16 // TODO(jdduke): Remove the destroy method and hold observer embedders | 14 // TODO(jdduke): Remove the destroy method and hold observer embedders |
| 17 // responsible for explicit observer detachment. | 15 // responsible for explicit observer detachment. |
| 18 // Using a weak reference avoids cycles that might prevent GC of WebView's W
ebContents. | 16 // Using a weak reference avoids cycles that might prevent GC of WebView's W
ebContents. |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 156 */ | 154 */ |
| 157 public void didChangeThemeColor(int color) {} | 155 public void didChangeThemeColor(int color) {} |
| 158 | 156 |
| 159 /** | 157 /** |
| 160 * Called when we started navigation to the pending entry. | 158 * Called when we started navigation to the pending entry. |
| 161 * @param url The URL that we are navigating to. | 159 * @param url The URL that we are navigating to. |
| 162 */ | 160 */ |
| 163 public void didStartNavigationToPendingEntry(String url) {} | 161 public void didStartNavigationToPendingEntry(String url) {} |
| 164 | 162 |
| 165 /** | 163 /** |
| 166 * Called when the media session state changed. | |
| 167 * @param isControllable if the session can be resumed or suspended. | |
| 168 * @param isSuspended if the session currently suspended or not. | |
| 169 */ | |
| 170 public void mediaSessionStateChanged(boolean isControllable, boolean isSuspe
nded) {} | |
| 171 | |
| 172 /** | |
| 173 * Called when the media session metadata changed. | |
| 174 * @param metadata the new MediaMetadata after change. | |
| 175 */ | |
| 176 public void mediaSessionMetadataChanged(MediaMetadata metadata) {} | |
| 177 | |
| 178 /** | |
| 179 * Stop observing the web contents and clean up associated references. | 164 * Stop observing the web contents and clean up associated references. |
| 180 */ | 165 */ |
| 181 public void destroy() { | 166 public void destroy() { |
| 182 if (mWebContents == null) return; | 167 if (mWebContents == null) return; |
| 183 final WebContents webContents = mWebContents.get(); | 168 final WebContents webContents = mWebContents.get(); |
| 184 mWebContents = null; | 169 mWebContents = null; |
| 185 if (webContents == null) return; | 170 if (webContents == null) return; |
| 186 webContents.removeObserver(this); | 171 webContents.removeObserver(this); |
| 187 } | 172 } |
| 188 | 173 |
| 189 protected WebContentsObserver() {} | 174 protected WebContentsObserver() {} |
| 190 } | 175 } |
| OLD | NEW |