Merge to M65: Android Accessibility: Avoiding crash on unregistering broadcast receiver.

There might be cases where unregistering broadcast receiver can throw
IllegalArgumentException if the context is not handled in an appropriate
manner. This CL avoids the crash.

(cherry picked from commit 8839385d34f511f6498bc20edba638944b67d0cd)

Bug: 780261
Change-Id: Ibd244879237aea099787c37ebc2141366840e7a0
Reviewed-on: https://chromium-review.googlesource.com/891458
Reviewed-by: Bo <boliu@chromium.org>
Reviewed-by: Dominic Mazzoni <dmazzoni@chromium.org>
Commit-Queue: Isha Bobra <ibobra@google.com>
Cr-Original-Commit-Position: refs/heads/master@{#532578}
Reviewed-on: https://chromium-review.googlesource.com/929303
Cr-Commit-Position: refs/branch-heads/3325@{#536}
Cr-Branched-From: bc084a8b5afa3744a74927344e304c02ae54189f-refs/heads/master@{#530369}
diff --git a/content/public/android/java/src/org/chromium/content/browser/accessibility/LollipopWebContentsAccessibility.java b/content/public/android/java/src/org/chromium/content/browser/accessibility/LollipopWebContentsAccessibility.java
index 55c19d0..f656066 100644
--- a/content/public/android/java/src/org/chromium/content/browser/accessibility/LollipopWebContentsAccessibility.java
+++ b/content/public/android/java/src/org/chromium/content/browser/accessibility/LollipopWebContentsAccessibility.java
@@ -153,14 +153,14 @@
 
     @Override
     public void onDetachedFromWindow() {
-        mContext.unregisterReceiver(mBroadcastReceiver);
+        mContext.getApplicationContext().unregisterReceiver(mBroadcastReceiver);
     }
 
     @Override
     public void onAttachedToWindow() {
         try {
             IntentFilter filter = new IntentFilter(Intent.ACTION_LOCALE_CHANGED);
-            mContext.registerReceiver(mBroadcastReceiver, filter);
+            mContext.getApplicationContext().registerReceiver(mBroadcastReceiver, filter);
         } catch (ReceiverCallNotAllowedException e) {
             // WebView may be running inside a BroadcastReceiver, in which case registerReceiver is
             // not allowed.