Commit f4f83ead authored by John Abd-El-Malek's avatar John Abd-El-Malek Committed by Commit Bot

Rename NavigationObserver and BrowserObserver to NavigationCallback and BrowserCallback.

This is more aligned with Android style guide.

Change-Id: I503748a796e2e5934e92d6ec9c6963907debabbb
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1890824
Commit-Queue: John Abd-El-Malek <jam@chromium.org>
Reviewed-by: default avatarClark DuVall <cduvall@chromium.org>
Cr-Commit-Position: refs/heads/master@{#711128}
parent c6e60809
...@@ -174,8 +174,8 @@ jumbo_static_library("weblayer_lib") { ...@@ -174,8 +174,8 @@ jumbo_static_library("weblayer_lib") {
sources += [ sources += [
"app/jni_onload.cc", "app/jni_onload.cc",
"app/jni_onload.h", "app/jni_onload.h",
"browser/browser_observer_proxy.cc", "browser/browser_callback_proxy.cc",
"browser/browser_observer_proxy.h", "browser/browser_callback_proxy.h",
"browser/content_view_render_view.cc", "browser/content_view_render_view.cc",
"browser/content_view_render_view.h", "browser/content_view_render_view.h",
"browser/download_delegate_proxy.cc", "browser/download_delegate_proxy.cc",
......
...@@ -2,12 +2,12 @@ ...@@ -2,12 +2,12 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#include "weblayer/browser/browser_observer_proxy.h" #include "weblayer/browser/browser_callback_proxy.h"
#include "base/android/jni_string.h" #include "base/android/jni_string.h"
#include "url/gurl.h" #include "url/gurl.h"
#include "weblayer/browser/browser_controller_impl.h" #include "weblayer/browser/browser_controller_impl.h"
#include "weblayer/browser/java/jni/BrowserObserverProxy_jni.h" #include "weblayer/browser/java/jni/BrowserCallbackProxy_jni.h"
using base::android::AttachCurrentThread; using base::android::AttachCurrentThread;
using base::android::ConvertUTF8ToJavaString; using base::android::ConvertUTF8ToJavaString;
...@@ -15,7 +15,7 @@ using base::android::ScopedJavaLocalRef; ...@@ -15,7 +15,7 @@ using base::android::ScopedJavaLocalRef;
namespace weblayer { namespace weblayer {
BrowserObserverProxy::BrowserObserverProxy( BrowserCallbackProxy::BrowserCallbackProxy(
JNIEnv* env, JNIEnv* env,
jobject obj, jobject obj,
BrowserController* browser_controller) BrowserController* browser_controller)
...@@ -23,29 +23,29 @@ BrowserObserverProxy::BrowserObserverProxy( ...@@ -23,29 +23,29 @@ BrowserObserverProxy::BrowserObserverProxy(
browser_controller_->AddObserver(this); browser_controller_->AddObserver(this);
} }
BrowserObserverProxy::~BrowserObserverProxy() { BrowserCallbackProxy::~BrowserCallbackProxy() {
browser_controller_->RemoveObserver(this); browser_controller_->RemoveObserver(this);
} }
void BrowserObserverProxy::DisplayedUrlChanged(const GURL& url) { void BrowserCallbackProxy::DisplayedUrlChanged(const GURL& url) {
JNIEnv* env = AttachCurrentThread(); JNIEnv* env = AttachCurrentThread();
ScopedJavaLocalRef<jstring> jstring_url( ScopedJavaLocalRef<jstring> jstring_url(
ConvertUTF8ToJavaString(env, url.spec())); ConvertUTF8ToJavaString(env, url.spec()));
Java_BrowserObserverProxy_visibleUrlChanged(env, java_observer_, jstring_url); Java_BrowserCallbackProxy_visibleUrlChanged(env, java_observer_, jstring_url);
} }
static jlong JNI_BrowserObserverProxy_CreateBrowserObserverProxy( static jlong JNI_BrowserCallbackProxy_CreateBrowserCallbackProxy(
JNIEnv* env, JNIEnv* env,
const base::android::JavaParamRef<jobject>& proxy, const base::android::JavaParamRef<jobject>& proxy,
jlong browser_controller) { jlong browser_controller) {
return reinterpret_cast<jlong>(new BrowserObserverProxy( return reinterpret_cast<jlong>(new BrowserCallbackProxy(
env, proxy, env, proxy,
reinterpret_cast<BrowserControllerImpl*>(browser_controller))); reinterpret_cast<BrowserControllerImpl*>(browser_controller)));
} }
static void JNI_BrowserObserverProxy_DeleteBrowserObserverProxy(JNIEnv* env, static void JNI_BrowserCallbackProxy_DeleteBrowserCallbackProxy(JNIEnv* env,
jlong proxy) { jlong proxy) {
delete reinterpret_cast<BrowserObserverProxy*>(proxy); delete reinterpret_cast<BrowserCallbackProxy*>(proxy);
} }
} // namespace weblayer } // namespace weblayer
...@@ -2,8 +2,8 @@ ...@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#ifndef WEBLAYER_BROWSER_BROWSER_OBSERVER_PROXY_H_ #ifndef WEBLAYER_BROWSER_BROWSER_CALLBACK_PROXY_H_
#define WEBLAYER_BROWSER_BROWSER_OBSERVER_PROXY_H_ #define WEBLAYER_BROWSER_BROWSER_CALLBACK_PROXY_H_
#include <jni.h> #include <jni.h>
...@@ -15,14 +15,14 @@ namespace weblayer { ...@@ -15,14 +15,14 @@ namespace weblayer {
class BrowserController; class BrowserController;
// BrowserObserverProxy forwards all BrowserObserver functions to the Java // BrowserCallbackProxy forwards all BrowserObserver functions to the Java
// side. There is one BrowserObserverProxy per BrowserController. // side. There is one BrowserCallbackProxy per BrowserController.
class BrowserObserverProxy : public BrowserObserver { class BrowserCallbackProxy : public BrowserObserver {
public: public:
BrowserObserverProxy(JNIEnv* env, BrowserCallbackProxy(JNIEnv* env,
jobject obj, jobject obj,
BrowserController* browser_controller); BrowserController* browser_controller);
~BrowserObserverProxy() override; ~BrowserCallbackProxy() override;
// BrowserObserver: // BrowserObserver:
void DisplayedUrlChanged(const GURL& url) override; void DisplayedUrlChanged(const GURL& url) override;
...@@ -31,9 +31,9 @@ class BrowserObserverProxy : public BrowserObserver { ...@@ -31,9 +31,9 @@ class BrowserObserverProxy : public BrowserObserver {
BrowserController* browser_controller_; BrowserController* browser_controller_;
base::android::ScopedJavaGlobalRef<jobject> java_observer_; base::android::ScopedJavaGlobalRef<jobject> java_observer_;
DISALLOW_COPY_AND_ASSIGN(BrowserObserverProxy); DISALLOW_COPY_AND_ASSIGN(BrowserCallbackProxy);
}; };
} // namespace weblayer } // namespace weblayer
#endif // WEBLAYER_BROWSER_BROWSER_OBSERVER_PROXY_H_ #endif // WEBLAYER_BROWSER_BROWSER_CALLBACK_PROXY_H_
...@@ -26,7 +26,7 @@ android_library("java") { ...@@ -26,7 +26,7 @@ android_library("java") {
"org/chromium/weblayer_private/BrowserControllerImpl.java", "org/chromium/weblayer_private/BrowserControllerImpl.java",
"org/chromium/weblayer_private/BrowserFragmentControllerImpl.java", "org/chromium/weblayer_private/BrowserFragmentControllerImpl.java",
"org/chromium/weblayer_private/BrowserFragmentImpl.java", "org/chromium/weblayer_private/BrowserFragmentImpl.java",
"org/chromium/weblayer_private/BrowserObserverProxy.java", "org/chromium/weblayer_private/BrowserCallbackProxy.java",
"org/chromium/weblayer_private/ChildProcessServiceImpl.java", "org/chromium/weblayer_private/ChildProcessServiceImpl.java",
"org/chromium/weblayer_private/ContentView.java", "org/chromium/weblayer_private/ContentView.java",
"org/chromium/weblayer_private/ContentViewRenderView.java", "org/chromium/weblayer_private/ContentViewRenderView.java",
...@@ -69,8 +69,8 @@ android_library("java") { ...@@ -69,8 +69,8 @@ android_library("java") {
generate_jni("jni") { generate_jni("jni") {
sources = [ sources = [
"org/chromium/weblayer_private/BrowserCallbackProxy.java",
"org/chromium/weblayer_private/BrowserControllerImpl.java", "org/chromium/weblayer_private/BrowserControllerImpl.java",
"org/chromium/weblayer_private/BrowserObserverProxy.java",
"org/chromium/weblayer_private/ContentViewRenderView.java", "org/chromium/weblayer_private/ContentViewRenderView.java",
"org/chromium/weblayer_private/DownloadDelegateProxy.java", "org/chromium/weblayer_private/DownloadDelegateProxy.java",
"org/chromium/weblayer_private/FullscreenDelegateProxy.java", "org/chromium/weblayer_private/FullscreenDelegateProxy.java",
......
...@@ -12,24 +12,24 @@ import org.chromium.base.annotations.NativeMethods; ...@@ -12,24 +12,24 @@ import org.chromium.base.annotations.NativeMethods;
import org.chromium.weblayer_private.aidl.IBrowserControllerClient; import org.chromium.weblayer_private.aidl.IBrowserControllerClient;
/** /**
* Owns the c++ BrowserObserverProxy class, which is responsible for forwarding all * Owns the C++ BrowserCallbackProxy class, which is responsible for forwarding all
* BrowserObserver calls to this class, which in turn forwards to the BrowserControllerClient. * BrowserObserver calls to this class, which in turn forwards to the BrowserControllerClient.
* To avoid unnecessary IPC only one BrowserObserverProxy is created per BrowserController. * To avoid unnecessary IPC only one BrowserCallbackProxy is created per BrowserController.
*/ */
@JNINamespace("weblayer") @JNINamespace("weblayer")
public final class BrowserObserverProxy { public final class BrowserCallbackProxy {
private long mNativeBrowserObserverProxy; private long mNativeBrowserCallbackProxy;
private IBrowserControllerClient mClient; private IBrowserControllerClient mClient;
BrowserObserverProxy(long browserController, IBrowserControllerClient client) { BrowserCallbackProxy(long browserController, IBrowserControllerClient client) {
mClient = client; mClient = client;
mNativeBrowserObserverProxy = mNativeBrowserCallbackProxy =
BrowserObserverProxyJni.get().createBrowserObserverProxy(this, browserController); BrowserCallbackProxyJni.get().createBrowserCallbackProxy(this, browserController);
} }
public void destroy() { public void destroy() {
BrowserObserverProxyJni.get().deleteBrowserObserverProxy(mNativeBrowserObserverProxy); BrowserCallbackProxyJni.get().deleteBrowserCallbackProxy(mNativeBrowserCallbackProxy);
mNativeBrowserObserverProxy = 0; mNativeBrowserCallbackProxy = 0;
} }
@CalledByNative @CalledByNative
...@@ -39,7 +39,7 @@ public final class BrowserObserverProxy { ...@@ -39,7 +39,7 @@ public final class BrowserObserverProxy {
@NativeMethods @NativeMethods
interface Natives { interface Natives {
long createBrowserObserverProxy(BrowserObserverProxy proxy, long browserController); long createBrowserCallbackProxy(BrowserCallbackProxy proxy, long browserController);
void deleteBrowserObserverProxy(long proxy); void deleteBrowserCallbackProxy(long proxy);
} }
} }
...@@ -48,7 +48,7 @@ public final class BrowserControllerImpl extends IBrowserController.Stub ...@@ -48,7 +48,7 @@ public final class BrowserControllerImpl extends IBrowserController.Stub
private TopControlsContainerView mTopControlsContainerView; private TopControlsContainerView mTopControlsContainerView;
private ProfileImpl mProfile; private ProfileImpl mProfile;
private WebContents mWebContents; private WebContents mWebContents;
private BrowserObserverProxy mBrowserObserverProxy; private BrowserCallbackProxy mBrowserCallbackProxy;
private NavigationControllerImpl mNavigationController; private NavigationControllerImpl mNavigationController;
private DownloadDelegateProxy mDownloadDelegateProxy; private DownloadDelegateProxy mDownloadDelegateProxy;
private FullscreenDelegateProxy mFullscreenDelegateProxy; private FullscreenDelegateProxy mFullscreenDelegateProxy;
...@@ -163,7 +163,7 @@ public final class BrowserControllerImpl extends IBrowserController.Stub ...@@ -163,7 +163,7 @@ public final class BrowserControllerImpl extends IBrowserController.Stub
@Override @Override
public void setClient(IBrowserControllerClient client) { public void setClient(IBrowserControllerClient client) {
mBrowserObserverProxy = new BrowserObserverProxy(mNativeBrowserController, client); mBrowserCallbackProxy = new BrowserCallbackProxy(mNativeBrowserController, client);
} }
@Override @Override
...@@ -217,9 +217,9 @@ public final class BrowserControllerImpl extends IBrowserController.Stub ...@@ -217,9 +217,9 @@ public final class BrowserControllerImpl extends IBrowserController.Stub
mNativeBrowserController, BrowserControllerImpl.this, 0); mNativeBrowserController, BrowserControllerImpl.this, 0);
mTopControlsContainerView.destroy(); mTopControlsContainerView.destroy();
mContentViewRenderView.destroy(); mContentViewRenderView.destroy();
if (mBrowserObserverProxy != null) { if (mBrowserCallbackProxy != null) {
mBrowserObserverProxy.destroy(); mBrowserCallbackProxy.destroy();
mBrowserObserverProxy = null; mBrowserCallbackProxy = null;
} }
if (mDownloadDelegateProxy != null) { if (mDownloadDelegateProxy != null) {
mDownloadDelegateProxy.destroy(); mDownloadDelegateProxy.destroy();
......
...@@ -6,7 +6,7 @@ package org.chromium.weblayer_private.aidl; ...@@ -6,7 +6,7 @@ package org.chromium.weblayer_private.aidl;
/** /**
* Interface used by BrowserController to inform the client of changes. This largely duplicates the * Interface used by BrowserController to inform the client of changes. This largely duplicates the
* BrowserObserver interface, but is a singleton to avoid unnecessary IPC. * BrowserCallback interface, but is a singleton to avoid unnecessary IPC.
*/ */
interface IBrowserControllerClient { interface IBrowserControllerClient {
void visibleUrlChanged(in String url) = 0; void visibleUrlChanged(in String url) = 0;
......
...@@ -6,7 +6,7 @@ package org.chromium.weblayer_private.aidl; ...@@ -6,7 +6,7 @@ package org.chromium.weblayer_private.aidl;
/** /**
* Interface used by NavigationController to inform the client of changes. This largely duplicates * Interface used by NavigationController to inform the client of changes. This largely duplicates
* the NavigationObserver interface, but is a singleton to avoid unnecessary IPC. * the NavigationCallback interface, but is a singleton to avoid unnecessary IPC.
*/ */
interface INavigationControllerClient { interface INavigationControllerClient {
IClientNavigation createClientNavigation(in INavigation impl) = 0; IClientNavigation createClientNavigation(in INavigation impl) = 0;
......
...@@ -21,10 +21,10 @@ android_resources("client_resources") { ...@@ -21,10 +21,10 @@ android_resources("client_resources") {
android_library("java") { android_library("java") {
java_files = [ java_files = [
"org/chromium/weblayer/BrowserCallback.java",
"org/chromium/weblayer/BrowserController.java", "org/chromium/weblayer/BrowserController.java",
"org/chromium/weblayer/BrowserFragmentController.java", "org/chromium/weblayer/BrowserFragmentController.java",
"org/chromium/weblayer/BrowserFragment.java", "org/chromium/weblayer/BrowserFragment.java",
"org/chromium/weblayer/BrowserObserver.java",
"org/chromium/weblayer/BrowsingDataType.java", "org/chromium/weblayer/BrowsingDataType.java",
"org/chromium/weblayer/Callback.java", "org/chromium/weblayer/Callback.java",
"org/chromium/weblayer/ChildProcessService.java", "org/chromium/weblayer/ChildProcessService.java",
...@@ -32,16 +32,16 @@ android_library("java") { ...@@ -32,16 +32,16 @@ android_library("java") {
"org/chromium/weblayer/FullscreenDelegate.java", "org/chromium/weblayer/FullscreenDelegate.java",
"org/chromium/weblayer/ListenableFuture.java", "org/chromium/weblayer/ListenableFuture.java",
"org/chromium/weblayer/ListenableResult.java", "org/chromium/weblayer/ListenableResult.java",
"org/chromium/weblayer/WebLayerFileProvider.java", "org/chromium/weblayer/NavigationCallback.java",
"org/chromium/weblayer/NavigationController.java", "org/chromium/weblayer/NavigationController.java",
"org/chromium/weblayer/Navigation.java", "org/chromium/weblayer/Navigation.java",
"org/chromium/weblayer/NavigationObserver.java",
"org/chromium/weblayer/ObserverList.java", "org/chromium/weblayer/ObserverList.java",
"org/chromium/weblayer/Profile.java", "org/chromium/weblayer/Profile.java",
"org/chromium/weblayer/ProfileManager.java", "org/chromium/weblayer/ProfileManager.java",
"org/chromium/weblayer/ThreadCheck.java", "org/chromium/weblayer/ThreadCheck.java",
"org/chromium/weblayer/UnsupportedVersionException.java", "org/chromium/weblayer/UnsupportedVersionException.java",
"org/chromium/weblayer/WebLayer.java", "org/chromium/weblayer/WebLayer.java",
"org/chromium/weblayer/WebLayerFileProvider.java",
] ]
deps = [ deps = [
......
...@@ -11,7 +11,7 @@ import androidx.annotation.NonNull; ...@@ -11,7 +11,7 @@ import androidx.annotation.NonNull;
/** /**
* Informed of interesting events that happen during the lifetime of a BrowserController. * Informed of interesting events that happen during the lifetime of a BrowserController.
*/ */
public abstract class BrowserObserver { public abstract class BrowserCallback {
/** /**
* The Uri that should be displayed in the url-bar has updated. * The Uri that should be displayed in the url-bar has updated.
* *
......
...@@ -24,7 +24,7 @@ import org.chromium.weblayer_private.aidl.ObjectWrapper; ...@@ -24,7 +24,7 @@ import org.chromium.weblayer_private.aidl.ObjectWrapper;
/** /**
* Represents a web-browser. More specifically, owns a NavigationController, and allows configuring * Represents a web-browser. More specifically, owns a NavigationController, and allows configuring
* state of the browser, such as delegates and observers. * state of the browser, such as delegates and callbacks.
*/ */
public final class BrowserController { public final class BrowserController {
/** The top level key of the JSON object returned by executeScript(). */ /** The top level key of the JSON object returned by executeScript(). */
...@@ -33,7 +33,7 @@ public final class BrowserController { ...@@ -33,7 +33,7 @@ public final class BrowserController {
private final IBrowserController mImpl; private final IBrowserController mImpl;
private FullscreenDelegateClientImpl mFullscreenDelegateClient; private FullscreenDelegateClientImpl mFullscreenDelegateClient;
private final NavigationController mNavigationController; private final NavigationController mNavigationController;
private final ObserverList<BrowserObserver> mObservers; private final ObserverList<BrowserCallback> mCallbacks;
private DownloadDelegateClientImpl mDownloadDelegateClient; private DownloadDelegateClientImpl mDownloadDelegateClient;
BrowserController(IBrowserController impl) { BrowserController(IBrowserController impl) {
...@@ -44,7 +44,7 @@ public final class BrowserController { ...@@ -44,7 +44,7 @@ public final class BrowserController {
throw new APICallException(e); throw new APICallException(e);
} }
mObservers = new ObserverList<BrowserObserver>(); mCallbacks = new ObserverList<BrowserCallback>();
mNavigationController = NavigationController.create(mImpl); mNavigationController = NavigationController.create(mImpl);
} }
...@@ -128,14 +128,14 @@ public final class BrowserController { ...@@ -128,14 +128,14 @@ public final class BrowserController {
return mNavigationController; return mNavigationController;
} }
public void addObserver(@Nullable BrowserObserver observer) { public void registerBrowserCallback(@Nullable BrowserCallback callback) {
ThreadCheck.ensureOnUiThread(); ThreadCheck.ensureOnUiThread();
mObservers.addObserver(observer); mCallbacks.addObserver(callback);
} }
public void removeObserver(@Nullable BrowserObserver observer) { public void unregisterBrowserCallback(@Nullable BrowserCallback callback) {
ThreadCheck.ensureOnUiThread(); ThreadCheck.ensureOnUiThread();
mObservers.removeObserver(observer); mCallbacks.removeObserver(callback);
} }
IBrowserController getIBrowserController() { IBrowserController getIBrowserController() {
...@@ -146,8 +146,8 @@ public final class BrowserController { ...@@ -146,8 +146,8 @@ public final class BrowserController {
@Override @Override
public void visibleUrlChanged(String url) { public void visibleUrlChanged(String url) {
Uri uri = Uri.parse(url); Uri uri = Uri.parse(url);
for (BrowserObserver observer : mObservers) { for (BrowserCallback callback : mCallbacks) {
observer.visibleUrlChanged(uri); callback.visibleUrlChanged(uri);
} }
} }
} }
......
...@@ -17,7 +17,7 @@ import androidx.annotation.NonNull; ...@@ -17,7 +17,7 @@ import androidx.annotation.NonNull;
* 4) navigationCompleted() or navigationFailed() * 4) navigationCompleted() or navigationFailed()
* 5) onFirstContentfulPaint * 5) onFirstContentfulPaint
*/ */
public abstract class NavigationObserver { public abstract class NavigationCallback {
/** /**
* Called when a navigation started in the BrowserController. |navigation| is unique to a * Called when a navigation started in the BrowserController. |navigation| is unique to a
* specific navigation. The same |navigation| will be provided on subsequent calls to * specific navigation. The same |navigation| will be provided on subsequent calls to
......
...@@ -21,7 +21,7 @@ import org.chromium.weblayer_private.aidl.INavigationControllerClient; ...@@ -21,7 +21,7 @@ import org.chromium.weblayer_private.aidl.INavigationControllerClient;
*/ */
public final class NavigationController { public final class NavigationController {
private INavigationController mNavigationController; private INavigationController mNavigationController;
private final ObserverList<NavigationObserver> mObservers; private final ObserverList<NavigationCallback> mCallbacks;
static NavigationController create(IBrowserController browserController) { static NavigationController create(IBrowserController browserController) {
NavigationController navigationController = new NavigationController(); NavigationController navigationController = new NavigationController();
...@@ -36,7 +36,7 @@ public final class NavigationController { ...@@ -36,7 +36,7 @@ public final class NavigationController {
} }
private NavigationController() { private NavigationController() {
mObservers = new ObserverList<NavigationObserver>(); mCallbacks = new ObserverList<NavigationCallback>();
} }
public void navigate(@NonNull Uri uri) { public void navigate(@NonNull Uri uri) {
...@@ -130,14 +130,14 @@ public final class NavigationController { ...@@ -130,14 +130,14 @@ public final class NavigationController {
} }
} }
public void addObserver(@NonNull NavigationObserver observer) { public void registerNavigationCallback(@NonNull NavigationCallback callback) {
ThreadCheck.ensureOnUiThread(); ThreadCheck.ensureOnUiThread();
mObservers.addObserver(observer); mCallbacks.addObserver(callback);
} }
public void removeObserver(@NonNull NavigationObserver observer) { public void unregisterNavigationCallback(@NonNull NavigationCallback callback) {
ThreadCheck.ensureOnUiThread(); ThreadCheck.ensureOnUiThread();
mObservers.removeObserver(observer); mCallbacks.removeObserver(callback);
} }
private final class NavigationControllerClientImpl extends INavigationControllerClient.Stub { private final class NavigationControllerClientImpl extends INavigationControllerClient.Stub {
...@@ -148,57 +148,57 @@ public final class NavigationController { ...@@ -148,57 +148,57 @@ public final class NavigationController {
@Override @Override
public void navigationStarted(IClientNavigation navigation) { public void navigationStarted(IClientNavigation navigation) {
for (NavigationObserver observer : mObservers) { for (NavigationCallback callback : mCallbacks) {
observer.navigationStarted((Navigation) navigation); callback.navigationStarted((Navigation) navigation);
} }
} }
@Override @Override
public void navigationRedirected(IClientNavigation navigation) { public void navigationRedirected(IClientNavigation navigation) {
for (NavigationObserver observer : mObservers) { for (NavigationCallback callback : mCallbacks) {
observer.navigationRedirected((Navigation) navigation); callback.navigationRedirected((Navigation) navigation);
} }
} }
@Override @Override
public void readyToCommitNavigation(IClientNavigation navigation) { public void readyToCommitNavigation(IClientNavigation navigation) {
for (NavigationObserver observer : mObservers) { for (NavigationCallback callback : mCallbacks) {
observer.readyToCommitNavigation((Navigation) navigation); callback.readyToCommitNavigation((Navigation) navigation);
} }
} }
@Override @Override
public void navigationCompleted(IClientNavigation navigation) { public void navigationCompleted(IClientNavigation navigation) {
for (NavigationObserver observer : mObservers) { for (NavigationCallback callback : mCallbacks) {
observer.navigationCompleted((Navigation) navigation); callback.navigationCompleted((Navigation) navigation);
} }
} }
@Override @Override
public void navigationFailed(IClientNavigation navigation) { public void navigationFailed(IClientNavigation navigation) {
for (NavigationObserver observer : mObservers) { for (NavigationCallback callback : mCallbacks) {
observer.navigationFailed((Navigation) navigation); callback.navigationFailed((Navigation) navigation);
} }
} }
@Override @Override
public void loadStateChanged(boolean isLoading, boolean toDifferentDocument) { public void loadStateChanged(boolean isLoading, boolean toDifferentDocument) {
for (NavigationObserver observer : mObservers) { for (NavigationCallback callback : mCallbacks) {
observer.loadStateChanged(isLoading, toDifferentDocument); callback.loadStateChanged(isLoading, toDifferentDocument);
} }
} }
@Override @Override
public void loadProgressChanged(double progress) { public void loadProgressChanged(double progress) {
for (NavigationObserver observer : mObservers) { for (NavigationCallback callback : mCallbacks) {
observer.loadProgressChanged(progress); callback.loadProgressChanged(progress);
} }
} }
@Override @Override
public void onFirstContentfulPaint() { public void onFirstContentfulPaint() {
for (NavigationObserver observer : mObservers) { for (NavigationCallback callback : mCallbacks) {
observer.onFirstContentfulPaint(); callback.onFirstContentfulPaint();
} }
} }
} }
......
...@@ -211,7 +211,7 @@ instrumentation_test_apk("weblayer_instrumentation_test_apk") { ...@@ -211,7 +211,7 @@ instrumentation_test_apk("weblayer_instrumentation_test_apk") {
"//third_party/android_support_test_runner:runner_java", "//third_party/android_support_test_runner:runner_java",
] ]
java_files = [ java_files = [
"javatests/src/org/chromium/weblayer/test/BrowserObserverTest.java", "javatests/src/org/chromium/weblayer/test/BrowserCallbackTest.java",
"javatests/src/org/chromium/weblayer/test/DataClearingTest.java", "javatests/src/org/chromium/weblayer/test/DataClearingTest.java",
"javatests/src/org/chromium/weblayer/test/DownloadDelegateTest.java", "javatests/src/org/chromium/weblayer/test/DownloadDelegateTest.java",
"javatests/src/org/chromium/weblayer/test/EventUtils.java", "javatests/src/org/chromium/weblayer/test/EventUtils.java",
......
...@@ -18,9 +18,9 @@ import org.chromium.base.test.util.UrlUtils; ...@@ -18,9 +18,9 @@ import org.chromium.base.test.util.UrlUtils;
import org.chromium.content_public.browser.BrowserStartupController; import org.chromium.content_public.browser.BrowserStartupController;
import org.chromium.native_test.NativeBrowserTest; import org.chromium.native_test.NativeBrowserTest;
import org.chromium.native_test.NativeBrowserTestActivity; import org.chromium.native_test.NativeBrowserTestActivity;
import org.chromium.weblayer.BrowserCallback;
import org.chromium.weblayer.BrowserController; import org.chromium.weblayer.BrowserController;
import org.chromium.weblayer.BrowserFragmentController; import org.chromium.weblayer.BrowserFragmentController;
import org.chromium.weblayer.BrowserObserver;
import org.chromium.weblayer.Profile; import org.chromium.weblayer.Profile;
import org.chromium.weblayer.WebLayer; import org.chromium.weblayer.WebLayer;
...@@ -88,7 +88,7 @@ public class WebLayerBrowserTestsActivity extends NativeBrowserTestActivity { ...@@ -88,7 +88,7 @@ public class WebLayerBrowserTestsActivity extends NativeBrowserTestActivity {
mBrowserFragmentController.setTopView(topContentsContainer); mBrowserFragmentController.setTopView(topContentsContainer);
mBrowserController = mBrowserFragmentController.getBrowserController(); mBrowserController = mBrowserFragmentController.getBrowserController();
mBrowserController.addObserver(new BrowserObserver() { mBrowserController.registerBrowserCallback(new BrowserCallback() {
@Override @Override
public void visibleUrlChanged(Uri uri) { public void visibleUrlChanged(Uri uri) {
mUrlView.setText(uri.toString()); mUrlView.setText(uri.toString());
......
...@@ -15,7 +15,7 @@ import org.chromium.base.test.BaseJUnit4ClassRunner; ...@@ -15,7 +15,7 @@ import org.chromium.base.test.BaseJUnit4ClassRunner;
import org.chromium.content_public.browser.test.util.Criteria; import org.chromium.content_public.browser.test.util.Criteria;
import org.chromium.content_public.browser.test.util.CriteriaHelper; import org.chromium.content_public.browser.test.util.CriteriaHelper;
import org.chromium.content_public.browser.test.util.TestThreadUtils; import org.chromium.content_public.browser.test.util.TestThreadUtils;
import org.chromium.weblayer.BrowserObserver; import org.chromium.weblayer.BrowserCallback;
import org.chromium.weblayer.shell.InstrumentationActivity; import org.chromium.weblayer.shell.InstrumentationActivity;
import java.util.ArrayList; import java.util.ArrayList;
...@@ -23,16 +23,16 @@ import java.util.Collections; ...@@ -23,16 +23,16 @@ import java.util.Collections;
import java.util.List; import java.util.List;
/** /**
* Tests that BrowserObserver methods are invoked as expected. * Tests that BrowserCallback methods are invoked as expected.
*/ */
@RunWith(BaseJUnit4ClassRunner.class) @RunWith(BaseJUnit4ClassRunner.class)
public class BrowserObserverTest { public class BrowserCallbackTest {
@Rule @Rule
public InstrumentationActivityTestRule mActivityTestRule = public InstrumentationActivityTestRule mActivityTestRule =
new InstrumentationActivityTestRule(); new InstrumentationActivityTestRule();
private static class Observer extends BrowserObserver { private static class Callback extends BrowserCallback {
public static class BrowserObserverValueRecorder { public static class BrowserCallbackValueRecorder {
private List<String> mObservedValues = private List<String> mObservedValues =
Collections.synchronizedList(new ArrayList<String>()); Collections.synchronizedList(new ArrayList<String>());
...@@ -57,8 +57,8 @@ public class BrowserObserverTest { ...@@ -57,8 +57,8 @@ public class BrowserObserverTest {
} }
} }
public BrowserObserverValueRecorder visibleUrlChangedCallback = public BrowserCallbackValueRecorder visibleUrlChangedCallback =
new BrowserObserverValueRecorder(); new BrowserCallbackValueRecorder();
@Override @Override
public void visibleUrlChanged(Uri url) { public void visibleUrlChanged(Uri url) {
...@@ -72,14 +72,14 @@ public class BrowserObserverTest { ...@@ -72,14 +72,14 @@ public class BrowserObserverTest {
String startupUrl = "about:blank"; String startupUrl = "about:blank";
InstrumentationActivity activity = mActivityTestRule.launchShellWithUrl(startupUrl); InstrumentationActivity activity = mActivityTestRule.launchShellWithUrl(startupUrl);
Observer observer = new Observer(); Callback calllback = new Callback();
TestThreadUtils.runOnUiThreadBlocking( TestThreadUtils.runOnUiThreadBlocking(
() -> { activity.getBrowserController().addObserver(observer); }); () -> { activity.getBrowserController().registerBrowserCallback(calllback); });
String url = "data:text,foo"; String url = "data:text,foo";
mActivityTestRule.navigateAndWait(url); mActivityTestRule.navigateAndWait(url);
/* Verify that the visible URL changes to the target. */ /* Verify that the visible URL changes to the target. */
observer.visibleUrlChangedCallback.waitUntilValueObserved(url); calllback.visibleUrlChangedCallback.waitUntilValueObserved(url);
} }
} }
...@@ -22,7 +22,7 @@ import org.chromium.content_public.browser.test.util.CriteriaHelper; ...@@ -22,7 +22,7 @@ import org.chromium.content_public.browser.test.util.CriteriaHelper;
import org.chromium.content_public.browser.test.util.TestThreadUtils; import org.chromium.content_public.browser.test.util.TestThreadUtils;
import org.chromium.weblayer.BrowserController; import org.chromium.weblayer.BrowserController;
import org.chromium.weblayer.Navigation; import org.chromium.weblayer.Navigation;
import org.chromium.weblayer.NavigationObserver; import org.chromium.weblayer.NavigationCallback;
import org.chromium.weblayer.shell.InstrumentationActivity; import org.chromium.weblayer.shell.InstrumentationActivity;
import java.lang.reflect.Field; import java.lang.reflect.Field;
...@@ -41,7 +41,7 @@ public class InstrumentationActivityTestRule extends ActivityTestRule<Instrument ...@@ -41,7 +41,7 @@ public class InstrumentationActivityTestRule extends ActivityTestRule<Instrument
private boolean mDoneLoading; private boolean mDoneLoading;
private CallbackHelper mCallbackHelper = new CallbackHelper(); private CallbackHelper mCallbackHelper = new CallbackHelper();
private NavigationObserver mNavigationObserver = new NavigationObserver() { private NavigationCallback mNavigationCallback = new NavigationCallback() {
@Override @Override
public void navigationCompleted(Navigation navigation) { public void navigationCompleted(Navigation navigation) {
if (navigation.getUri().toString().equals(mUrl)) { if (navigation.getUri().toString().equals(mUrl)) {
...@@ -64,7 +64,8 @@ public class InstrumentationActivityTestRule extends ActivityTestRule<Instrument ...@@ -64,7 +64,8 @@ public class InstrumentationActivityTestRule extends ActivityTestRule<Instrument
public void navigateAndWait() { public void navigateAndWait() {
TestThreadUtils.runOnUiThreadBlocking(() -> { TestThreadUtils.runOnUiThreadBlocking(() -> {
mController.getNavigationController().addObserver(mNavigationObserver); mController.getNavigationController().registerNavigationCallback(
mNavigationCallback);
mController.getNavigationController().navigate(Uri.parse(mUrl)); mController.getNavigationController().navigate(Uri.parse(mUrl));
}); });
try { try {
...@@ -73,7 +74,8 @@ public class InstrumentationActivityTestRule extends ActivityTestRule<Instrument ...@@ -73,7 +74,8 @@ public class InstrumentationActivityTestRule extends ActivityTestRule<Instrument
throw new RuntimeException(e); throw new RuntimeException(e);
} }
TestThreadUtils.runOnUiThreadBlocking(() -> { TestThreadUtils.runOnUiThreadBlocking(() -> {
mController.getNavigationController().removeObserver(mNavigationObserver); mController.getNavigationController().unregisterNavigationCallback(
mNavigationCallback);
}); });
} }
......
...@@ -23,8 +23,8 @@ import org.chromium.base.test.util.CallbackHelper; ...@@ -23,8 +23,8 @@ import org.chromium.base.test.util.CallbackHelper;
import org.chromium.content_public.browser.test.util.Criteria; import org.chromium.content_public.browser.test.util.Criteria;
import org.chromium.content_public.browser.test.util.CriteriaHelper; import org.chromium.content_public.browser.test.util.CriteriaHelper;
import org.chromium.weblayer.Navigation; import org.chromium.weblayer.Navigation;
import org.chromium.weblayer.NavigationCallback;
import org.chromium.weblayer.NavigationController; import org.chromium.weblayer.NavigationController;
import org.chromium.weblayer.NavigationObserver;
import org.chromium.weblayer.shell.InstrumentationActivity; import org.chromium.weblayer.shell.InstrumentationActivity;
import java.util.ArrayList; import java.util.ArrayList;
...@@ -46,7 +46,7 @@ public class NavigationTest { ...@@ -46,7 +46,7 @@ public class NavigationTest {
private static final String URL2 = "data:text,bar"; private static final String URL2 = "data:text,bar";
private static final String URL3 = "data:text,baz"; private static final String URL3 = "data:text,baz";
private static class Observer extends NavigationObserver { private static class Callback extends NavigationCallback {
public static class NavigationCallbackHelper extends CallbackHelper { public static class NavigationCallbackHelper extends CallbackHelper {
private Uri mUri; private Uri mUri;
private boolean mIsSameDocument; private boolean mIsSameDocument;
...@@ -75,7 +75,7 @@ public class NavigationTest { ...@@ -75,7 +75,7 @@ public class NavigationTest {
} }
} }
public static class NavigationObserverValueRecorder { public static class NavigationCallbackValueRecorder {
private List<String> mObservedValues = private List<String> mObservedValues =
Collections.synchronizedList(new ArrayList<String>()); Collections.synchronizedList(new ArrayList<String>());
...@@ -103,10 +103,10 @@ public class NavigationTest { ...@@ -103,10 +103,10 @@ public class NavigationTest {
public NavigationCallbackHelper onStartedCallback = new NavigationCallbackHelper(); public NavigationCallbackHelper onStartedCallback = new NavigationCallbackHelper();
public NavigationCallbackHelper onReadyToCommitCallback = new NavigationCallbackHelper(); public NavigationCallbackHelper onReadyToCommitCallback = new NavigationCallbackHelper();
public NavigationCallbackHelper onCompletedCallback = new NavigationCallbackHelper(); public NavigationCallbackHelper onCompletedCallback = new NavigationCallbackHelper();
public NavigationObserverValueRecorder loadStateChangedCallback = public NavigationCallbackValueRecorder loadStateChangedCallback =
new NavigationObserverValueRecorder(); new NavigationCallbackValueRecorder();
public NavigationObserverValueRecorder loadProgressChangedCallback = public NavigationCallbackValueRecorder loadProgressChangedCallback =
new NavigationObserverValueRecorder(); new NavigationCallbackValueRecorder();
public CallbackHelper onFirstContentfulPaintCallback = new CallbackHelper(); public CallbackHelper onFirstContentfulPaintCallback = new CallbackHelper();
@Override @Override
...@@ -142,50 +142,50 @@ public class NavigationTest { ...@@ -142,50 +142,50 @@ public class NavigationTest {
} }
} }
private final Observer mObserver = new Observer(); private final Callback mCallback = new Callback();
@Test @Test
@SmallTest @SmallTest
public void testNavigationEvents() throws Exception { public void testNavigationEvents() throws Exception {
InstrumentationActivity activity = mActivityTestRule.launchShellWithUrl(URL1); InstrumentationActivity activity = mActivityTestRule.launchShellWithUrl(URL1);
setNavigationObserver(activity); setNavigationCallback(activity);
int curStartedCount = mObserver.onStartedCallback.getCallCount(); int curStartedCount = mCallback.onStartedCallback.getCallCount();
int curCommittedCount = mObserver.onReadyToCommitCallback.getCallCount(); int curCommittedCount = mCallback.onReadyToCommitCallback.getCallCount();
int curCompletedCount = mObserver.onCompletedCallback.getCallCount(); int curCompletedCount = mCallback.onCompletedCallback.getCallCount();
int curOnFirstContentfulPaintCount = int curOnFirstContentfulPaintCount =
mObserver.onFirstContentfulPaintCallback.getCallCount(); mCallback.onFirstContentfulPaintCallback.getCallCount();
mActivityTestRule.navigateAndWait(URL2); mActivityTestRule.navigateAndWait(URL2);
mObserver.onStartedCallback.assertCalledWith(curStartedCount, URL2); mCallback.onStartedCallback.assertCalledWith(curStartedCount, URL2);
mObserver.onReadyToCommitCallback.assertCalledWith(curCommittedCount, URL2); mCallback.onReadyToCommitCallback.assertCalledWith(curCommittedCount, URL2);
mObserver.onCompletedCallback.assertCalledWith(curCompletedCount, URL2); mCallback.onCompletedCallback.assertCalledWith(curCompletedCount, URL2);
mObserver.onFirstContentfulPaintCallback.waitForCallback(curOnFirstContentfulPaintCount); mCallback.onFirstContentfulPaintCallback.waitForCallback(curOnFirstContentfulPaintCount);
} }
@Test @Test
@SmallTest @SmallTest
public void testLoadStateUpdates() throws Exception { public void testLoadStateUpdates() throws Exception {
InstrumentationActivity activity = mActivityTestRule.launchShellWithUrl(null); InstrumentationActivity activity = mActivityTestRule.launchShellWithUrl(null);
setNavigationObserver(activity); setNavigationCallback(activity);
mActivityTestRule.navigateAndWait(URL1); mActivityTestRule.navigateAndWait(URL1);
/* Wait until the NavigationObserver is notified of load completion. */ /* Wait until the NavigationCallback is notified of load completion. */
mObserver.loadStateChangedCallback.waitUntilValueObserved("false false"); mCallback.loadStateChangedCallback.waitUntilValueObserved("false false");
mObserver.loadProgressChangedCallback.waitUntilValueObserved("load complete"); mCallback.loadProgressChangedCallback.waitUntilValueObserved("load complete");
/* Verify that the NavigationObserver was notified of load progress /before/ load /* Verify that the NavigationCallback was notified of load progress /before/ load
* completion. * completion.
*/ */
int finishStateIndex = int finishStateIndex =
mObserver.loadStateChangedCallback.getObservedValues().indexOf("false false"); mCallback.loadStateChangedCallback.getObservedValues().indexOf("false false");
int finishProgressIndex = int finishProgressIndex =
mObserver.loadProgressChangedCallback.getObservedValues().indexOf("load complete"); mCallback.loadProgressChangedCallback.getObservedValues().indexOf("load complete");
int startStateIndex = int startStateIndex =
mObserver.loadStateChangedCallback.getObservedValues().lastIndexOf("true true"); mCallback.loadStateChangedCallback.getObservedValues().lastIndexOf("true true");
int startProgressIndex = int startProgressIndex =
mObserver.loadProgressChangedCallback.getObservedValues().lastIndexOf( mCallback.loadProgressChangedCallback.getObservedValues().lastIndexOf(
"load started"); "load started");
assertNotEquals(startStateIndex, -1); assertNotEquals(startStateIndex, -1);
...@@ -201,7 +201,7 @@ public class NavigationTest { ...@@ -201,7 +201,7 @@ public class NavigationTest {
@SmallTest @SmallTest
public void testGoBackAndForward() throws Exception { public void testGoBackAndForward() throws Exception {
InstrumentationActivity activity = mActivityTestRule.launchShellWithUrl(URL1); InstrumentationActivity activity = mActivityTestRule.launchShellWithUrl(URL1);
setNavigationObserver(activity); setNavigationCallback(activity);
mActivityTestRule.navigateAndWait(URL2); mActivityTestRule.navigateAndWait(URL2);
mActivityTestRule.navigateAndWait(URL3); mActivityTestRule.navigateAndWait(URL3);
...@@ -239,26 +239,27 @@ public class NavigationTest { ...@@ -239,26 +239,27 @@ public class NavigationTest {
@SmallTest @SmallTest
public void testSameDocument() throws Exception { public void testSameDocument() throws Exception {
InstrumentationActivity activity = mActivityTestRule.launchShellWithUrl(URL1); InstrumentationActivity activity = mActivityTestRule.launchShellWithUrl(URL1);
setNavigationObserver(activity); setNavigationCallback(activity);
int curCompletedCount = mObserver.onCompletedCallback.getCallCount(); int curCompletedCount = mCallback.onCompletedCallback.getCallCount();
mActivityTestRule.executeScriptSync("history.pushState(null, '', '#bar');"); mActivityTestRule.executeScriptSync("history.pushState(null, '', '#bar');");
mObserver.onCompletedCallback.assertCalledWith( mCallback.onCompletedCallback.assertCalledWith(
curCompletedCount, "data:text,foo#bar", true); curCompletedCount, "data:text,foo#bar", true);
} }
private void setNavigationObserver(InstrumentationActivity activity) { private void setNavigationCallback(InstrumentationActivity activity) {
runOnUiThreadBlocking(() -> runOnUiThreadBlocking(()
activity.getBrowserController().getNavigationController().addObserver(mObserver) -> activity.getBrowserController()
); .getNavigationController()
.registerNavigationCallback(mCallback));
} }
private void navigateAndWaitForCompletion(String expectedUrl, Runnable navigateRunnable) private void navigateAndWaitForCompletion(String expectedUrl, Runnable navigateRunnable)
throws Exception { throws Exception {
int currentCallCount = mObserver.onCompletedCallback.getCallCount(); int currentCallCount = mCallback.onCompletedCallback.getCallCount();
runOnUiThreadBlocking(navigateRunnable); runOnUiThreadBlocking(navigateRunnable);
mObserver.onCompletedCallback.assertCalledWith(currentCallCount, expectedUrl); mCallback.onCompletedCallback.assertCalledWith(currentCallCount, expectedUrl);
} }
} }
...@@ -21,9 +21,9 @@ import android.widget.EditText; ...@@ -21,9 +21,9 @@ import android.widget.EditText;
import android.widget.LinearLayout; import android.widget.LinearLayout;
import android.widget.RelativeLayout; import android.widget.RelativeLayout;
import org.chromium.weblayer.BrowserCallback;
import org.chromium.weblayer.BrowserController; import org.chromium.weblayer.BrowserController;
import org.chromium.weblayer.BrowserFragmentController; import org.chromium.weblayer.BrowserFragmentController;
import org.chromium.weblayer.BrowserObserver;
import org.chromium.weblayer.Profile; import org.chromium.weblayer.Profile;
import org.chromium.weblayer.UnsupportedVersionException; import org.chromium.weblayer.UnsupportedVersionException;
import org.chromium.weblayer.WebLayer; import org.chromium.weblayer.WebLayer;
...@@ -125,7 +125,7 @@ public class InstrumentationActivity extends FragmentActivity { ...@@ -125,7 +125,7 @@ public class InstrumentationActivity extends FragmentActivity {
mBrowserFragmentController.setTopView(mTopContentsContainer); mBrowserFragmentController.setTopView(mTopContentsContainer);
mBrowserController = mBrowserFragmentController.getBrowserController(); mBrowserController = mBrowserFragmentController.getBrowserController();
mBrowserController.addObserver(new BrowserObserver() { mBrowserController.registerBrowserCallback(new BrowserCallback() {
@Override @Override
public void visibleUrlChanged(Uri uri) { public void visibleUrlChanged(Uri uri) {
mUrlView.setText(uri.toString()); mUrlView.setText(uri.toString());
......
...@@ -27,13 +27,13 @@ import android.widget.RelativeLayout; ...@@ -27,13 +27,13 @@ import android.widget.RelativeLayout;
import android.widget.TextView; import android.widget.TextView;
import android.widget.TextView.OnEditorActionListener; import android.widget.TextView.OnEditorActionListener;
import org.chromium.weblayer.BrowserCallback;
import org.chromium.weblayer.BrowserController; import org.chromium.weblayer.BrowserController;
import org.chromium.weblayer.BrowserFragmentController; import org.chromium.weblayer.BrowserFragmentController;
import org.chromium.weblayer.BrowserObserver;
import org.chromium.weblayer.DownloadDelegate; import org.chromium.weblayer.DownloadDelegate;
import org.chromium.weblayer.FullscreenDelegate; import org.chromium.weblayer.FullscreenDelegate;
import org.chromium.weblayer.NavigationCallback;
import org.chromium.weblayer.NavigationController; import org.chromium.weblayer.NavigationController;
import org.chromium.weblayer.NavigationObserver;
import org.chromium.weblayer.Profile; import org.chromium.weblayer.Profile;
import org.chromium.weblayer.UnsupportedVersionException; import org.chromium.weblayer.UnsupportedVersionException;
import org.chromium.weblayer.WebLayer; import org.chromium.weblayer.WebLayer;
...@@ -172,24 +172,25 @@ public class WebLayerShellActivity extends FragmentActivity { ...@@ -172,24 +172,25 @@ public class WebLayerShellActivity extends FragmentActivity {
startupUrl = "http://google.com"; startupUrl = "http://google.com";
} }
loadUrl(startupUrl); loadUrl(startupUrl);
mBrowserController.addObserver(new BrowserObserver() { mBrowserController.registerBrowserCallback(new BrowserCallback() {
@Override @Override
public void visibleUrlChanged(Uri uri) { public void visibleUrlChanged(Uri uri) {
mUrlView.setText(uri.toString()); mUrlView.setText(uri.toString());
} }
}); });
mBrowserController.getNavigationController().addObserver(new NavigationObserver() { mBrowserController.getNavigationController().registerNavigationCallback(
@Override new NavigationCallback() {
public void loadStateChanged(boolean isLoading, boolean toDifferentDocument) { @Override
mLoadProgressBar.setVisibility( public void loadStateChanged(boolean isLoading, boolean toDifferentDocument) {
isLoading && toDifferentDocument ? View.VISIBLE : View.INVISIBLE); mLoadProgressBar.setVisibility(
} isLoading && toDifferentDocument ? View.VISIBLE : View.INVISIBLE);
}
@Override @Override
public void loadProgressChanged(double progress) { public void loadProgressChanged(double progress) {
mLoadProgressBar.setProgress((int) Math.round(100 * progress)); mLoadProgressBar.setProgress((int) Math.round(100 * progress));
} }
}); });
mBrowserController.setDownloadDelegate(new DownloadDelegate() { mBrowserController.setDownloadDelegate(new DownloadDelegate() {
@Override @Override
public void downloadRequested(String url, String userAgent, String contentDisposition, public void downloadRequested(String url, String userAgent, String contentDisposition,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment