| Index: android/java/src/org/chromium/base/BaseChromiumApplication.java
 | 
| diff --git a/android/java/src/org/chromium/base/BaseChromiumApplication.java b/android/java/src/org/chromium/base/BaseChromiumApplication.java
 | 
| index d7c7b05ea58d88808aef44d10e798448e74ec0ca..b71b6463b49c38c75e8e153dbaa6b1a81f63def8 100644
 | 
| --- a/android/java/src/org/chromium/base/BaseChromiumApplication.java
 | 
| +++ b/android/java/src/org/chromium/base/BaseChromiumApplication.java
 | 
| @@ -8,18 +8,19 @@ import android.app.Activity;
 | 
|  import android.app.Application;
 | 
|  import android.content.Context;
 | 
|  import android.os.Bundle;
 | 
| -import android.view.KeyEvent;
 | 
|  import android.view.Window;
 | 
|  
 | 
| -import java.lang.reflect.InvocationHandler;
 | 
| -import java.lang.reflect.InvocationTargetException;
 | 
| -import java.lang.reflect.Method;
 | 
| -import java.lang.reflect.Proxy;
 | 
| -
 | 
|  /**
 | 
|   * Basic application functionality that should be shared among all browser applications.
 | 
|   */
 | 
|  public class BaseChromiumApplication extends Application {
 | 
| +    private static final String TAG = "cr.base";
 | 
| +
 | 
| +    @Override
 | 
| +    protected void attachBaseContext(Context base) {
 | 
| +        super.attachBaseContext(base);
 | 
| +    }
 | 
| +
 | 
|      /**
 | 
|       * Interface to be implemented by listeners for window focus events.
 | 
|       */
 | 
| @@ -35,66 +36,6 @@ public class BaseChromiumApplication extends Application {
 | 
|      private ObserverList<WindowFocusChangedListener> mWindowFocusListeners =
 | 
|              new ObserverList<WindowFocusChangedListener>();
 | 
|  
 | 
| -    /**
 | 
| -     * Intercepts calls to an existing Window.Callback. Most invocations are passed on directly
 | 
| -     * to the composed Window.Callback but enables intercepting/manipulating others.
 | 
| -     *
 | 
| -     * This is used to relay window focus changes throughout the app and remedy a bug in the
 | 
| -     * appcompat library.
 | 
| -     */
 | 
| -    private class WindowCallbackProxy implements InvocationHandler {
 | 
| -        private final Window.Callback mCallback;
 | 
| -        private final Activity mActivity;
 | 
| -
 | 
| -        public WindowCallbackProxy(Activity activity, Window.Callback callback) {
 | 
| -            mCallback = callback;
 | 
| -            mActivity = activity;
 | 
| -        }
 | 
| -
 | 
| -        @Override
 | 
| -        public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
 | 
| -            if (method.getName().equals("onWindowFocusChanged") && args.length == 1
 | 
| -                    && args[0] instanceof Boolean) {
 | 
| -                onWindowFocusChanged((boolean) args[0]);
 | 
| -                return null;
 | 
| -            } else if (method.getName().equals("dispatchKeyEvent") && args.length == 1
 | 
| -                    && args[0] instanceof KeyEvent) {
 | 
| -                return dispatchKeyEvent((KeyEvent) args[0]);
 | 
| -            } else {
 | 
| -                try {
 | 
| -                    return method.invoke(mCallback, args);
 | 
| -                } catch (InvocationTargetException e) {
 | 
| -                    // Special-case for when a method is not defined on the underlying
 | 
| -                    // Window.Callback object. Because we're using a Proxy to forward all method
 | 
| -                    // calls, this breaks the Android framework's handling for apps built against
 | 
| -                    // an older SDK. The framework expects an AbstractMethodError but due to
 | 
| -                    // reflection it becomes wrapped inside an InvocationTargetException. Undo the
 | 
| -                    // wrapping to signal the framework accordingly.
 | 
| -                    if (e.getCause() instanceof AbstractMethodError) {
 | 
| -                        throw e.getCause();
 | 
| -                    }
 | 
| -                    throw e;
 | 
| -                }
 | 
| -            }
 | 
| -        }
 | 
| -
 | 
| -        public void onWindowFocusChanged(boolean hasFocus) {
 | 
| -            mCallback.onWindowFocusChanged(hasFocus);
 | 
| -
 | 
| -            for (WindowFocusChangedListener listener : mWindowFocusListeners) {
 | 
| -                listener.onWindowFocusChanged(mActivity, hasFocus);
 | 
| -            }
 | 
| -        }
 | 
| -
 | 
| -        public boolean dispatchKeyEvent(KeyEvent event) {
 | 
| -            // TODO(aurimas): remove this once AppCompatDelegateImpl no longer steals
 | 
| -            // KEYCODE_MENU. (see b/20529185)
 | 
| -            if (event.getKeyCode() == KeyEvent.KEYCODE_MENU && mActivity.dispatchKeyEvent(event)) {
 | 
| -                return true;
 | 
| -            }
 | 
| -            return mCallback.dispatchKeyEvent(event);
 | 
| -        }
 | 
| -    }
 | 
|      @Override
 | 
|      public void onCreate() {
 | 
|          super.onCreate();
 | 
| @@ -103,39 +44,45 @@ public class BaseChromiumApplication extends Application {
 | 
|              @Override
 | 
|              public void onActivityCreated(final Activity activity, Bundle savedInstanceState) {
 | 
|                  Window.Callback callback = activity.getWindow().getCallback();
 | 
| -                activity.getWindow().setCallback((Window.Callback) Proxy.newProxyInstance(
 | 
| -                        Window.Callback.class.getClassLoader(), new Class[] {Window.Callback.class},
 | 
| -                        new WindowCallbackProxy(activity, callback)));
 | 
| +                activity.getWindow().setCallback(new WindowCallbackWrapper(callback) {
 | 
| +                    @Override
 | 
| +                    public void onWindowFocusChanged(boolean hasFocus) {
 | 
| +                        super.onWindowFocusChanged(hasFocus);
 | 
| +                        for (WindowFocusChangedListener listener : mWindowFocusListeners) {
 | 
| +                            listener.onWindowFocusChanged(activity, hasFocus);
 | 
| +                        }
 | 
| +                    }
 | 
| +                });
 | 
|              }
 | 
|  
 | 
|              @Override
 | 
|              public void onActivityDestroyed(Activity activity) {
 | 
| -                assert Proxy.isProxyClass(activity.getWindow().getCallback().getClass());
 | 
| +                assert activity.getWindow().getCallback() instanceof WindowCallbackWrapper;
 | 
|              }
 | 
|  
 | 
|              @Override
 | 
|              public void onActivityPaused(Activity activity) {
 | 
| -                assert Proxy.isProxyClass(activity.getWindow().getCallback().getClass());
 | 
| +                assert activity.getWindow().getCallback() instanceof WindowCallbackWrapper;
 | 
|              }
 | 
|  
 | 
|              @Override
 | 
|              public void onActivityResumed(Activity activity) {
 | 
| -                assert Proxy.isProxyClass(activity.getWindow().getCallback().getClass());
 | 
| +                assert activity.getWindow().getCallback() instanceof WindowCallbackWrapper;
 | 
|              }
 | 
|  
 | 
|              @Override
 | 
|              public void onActivitySaveInstanceState(Activity activity, Bundle outState) {
 | 
| -                assert Proxy.isProxyClass(activity.getWindow().getCallback().getClass());
 | 
| +                assert activity.getWindow().getCallback() instanceof WindowCallbackWrapper;
 | 
|              }
 | 
|  
 | 
|              @Override
 | 
|              public void onActivityStarted(Activity activity) {
 | 
| -                assert Proxy.isProxyClass(activity.getWindow().getCallback().getClass());
 | 
| +                assert activity.getWindow().getCallback() instanceof WindowCallbackWrapper;
 | 
|              }
 | 
|  
 | 
|              @Override
 | 
|              public void onActivityStopped(Activity activity) {
 | 
| -                assert Proxy.isProxyClass(activity.getWindow().getCallback().getClass());
 | 
| +                assert activity.getWindow().getCallback() instanceof WindowCallbackWrapper;
 | 
|              }
 | 
|          });
 | 
|      }
 | 
| @@ -166,5 +113,5 @@ public class BaseChromiumApplication extends Application {
 | 
|      @VisibleForTesting
 | 
|      public static void initCommandLine(Context context) {
 | 
|          ((BaseChromiumApplication) context.getApplicationContext()).initCommandLine();
 | 
| -    };
 | 
| +    }
 | 
|  }
 | 
| 
 |