| 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 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 166 */ | 164 */ |
| 167 public void didChangeThemeColor(int color) {} | 165 public void didChangeThemeColor(int color) {} |
| 168 | 166 |
| 169 /** | 167 /** |
| 170 * Called when we started navigation to the pending entry. | 168 * Called when we started navigation to the pending entry. |
| 171 * @param url The URL that we are navigating to. | 169 * @param url The URL that we are navigating to. |
| 172 */ | 170 */ |
| 173 public void didStartNavigationToPendingEntry(String url) {} | 171 public void didStartNavigationToPendingEntry(String url) {} |
| 174 | 172 |
| 175 /** | 173 /** |
| 176 * Called when the media session state changed. | |
| 177 * @param isControllable if the session can be resumed or suspended. | |
| 178 * @param isSuspended if the session currently suspended or not. | |
| 179 */ | |
| 180 public void mediaSessionStateChanged(boolean isControllable, boolean isSuspe
nded) {} | |
| 181 | |
| 182 /** | |
| 183 * Called when the media session metadata changed. | |
| 184 * @param metadata the new MediaMetadata after change. | |
| 185 */ | |
| 186 public void mediaSessionMetadataChanged(MediaMetadata metadata) {} | |
| 187 | |
| 188 /** | |
| 189 * Stop observing the web contents and clean up associated references. | 174 * Stop observing the web contents and clean up associated references. |
| 190 */ | 175 */ |
| 191 public void destroy() { | 176 public void destroy() { |
| 192 if (mWebContents == null) return; | 177 if (mWebContents == null) return; |
| 193 final WebContents webContents = mWebContents.get(); | 178 final WebContents webContents = mWebContents.get(); |
| 194 mWebContents = null; | 179 mWebContents = null; |
| 195 if (webContents == null) return; | 180 if (webContents == null) return; |
| 196 webContents.removeObserver(this); | 181 webContents.removeObserver(this); |
| 197 } | 182 } |
| 198 | 183 |
| 199 protected WebContentsObserver() {} | 184 protected WebContentsObserver() {} |
| 200 } | 185 } |
| OLD | NEW |