Index: components/web_contents_delegate_android/android/java/src/org/chromium/components/web_contents_delegate_android/ColorChooserAndroid.java |
diff --git a/components/web_contents_delegate_android/android/java/src/org/chromium/components/web_contents_delegate_android/ColorChooserAndroid.java b/components/web_contents_delegate_android/android/java/src/org/chromium/components/web_contents_delegate_android/ColorChooserAndroid.java |
index 207fee2dd4335ec8cc21f94117115fbd341944e1..25f5f62fd1896098f86f740adab9858905b5bd6e 100644 |
--- a/components/web_contents_delegate_android/android/java/src/org/chromium/components/web_contents_delegate_android/ColorChooserAndroid.java |
+++ b/components/web_contents_delegate_android/android/java/src/org/chromium/components/web_contents_delegate_android/ColorChooserAndroid.java |
@@ -12,6 +12,7 @@ import org.chromium.content.browser.ContentViewCore; |
import org.chromium.ui.ColorPickerDialog; |
import org.chromium.ui.ColorSuggestion; |
import org.chromium.ui.OnColorChangedListener; |
+import org.chromium.ui.base.WindowAndroid; |
/** |
* ColorChooserAndroid communicates with the java ColorPickerDialog and the |
@@ -51,8 +52,11 @@ public class ColorChooserAndroid { |
ContentViewCore contentViewCore, |
int initialColor, |
ColorSuggestion[] suggestions) { |
+ if (contentViewCore.getWindowAndroid() == null) return null; |
+ Context windowContext = contentViewCore.getWindowAndroid().getContext().get(); |
+ if (WindowAndroid.activityFromContext(windowContext) == null) return null; |
ColorChooserAndroid chooser = new ColorChooserAndroid(nativeColorChooserAndroid, |
- contentViewCore.getContext(), initialColor, suggestions); |
+ windowContext, initialColor, suggestions); |
chooser.openColorChooser(); |
return chooser; |
} |