Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(394)

Unified Diff: components/web_contents_delegate_android/android/java/src/org/chromium/components/web_contents_delegate_android/ColorChooserAndroid.java

Issue 1528733002: Pull the Activity context from WindowAndroid if possible (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Changed AwContents logic and moved the static call to WindowAndroid Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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;
}

Powered by Google App Engine
This is Rietveld 408576698