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

Unified Diff: components/web_contents_delegate_android/color_chooser_android.cc

Issue 1156883004: Fix color pickers on WebView. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 7 months 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/color_chooser_android.cc
diff --git a/components/web_contents_delegate_android/color_chooser_android.cc b/components/web_contents_delegate_android/color_chooser_android.cc
index b08f36b46aa5aaf3cd8f526472ac2744cdf5fb5d..e4d99274252a4d75b86a298cc2dc1f2063caaf43 100644
--- a/components/web_contents_delegate_android/color_chooser_android.cc
+++ b/components/web_contents_delegate_android/color_chooser_android.cc
@@ -6,12 +6,14 @@
#include "base/android/jni_array.h"
#include "base/android/jni_string.h"
+#include "content/public/browser/android/content_view_core.h"
#include "content/public/browser/web_contents.h"
#include "content/public/common/color_suggestion.h"
#include "jni/ColorChooserAndroid_jni.h"
#include "ui/android/window_android.h"
using base::android::ConvertUTF16ToJavaString;
+using content::ContentViewCore;
namespace web_contents_delegate_android {
@@ -39,12 +41,21 @@ ColorChooserAndroid::ColorChooserAndroid(
label.obj());
}
}
- j_color_chooser_.Reset(Java_ColorChooserAndroid_createColorChooserAndroid(
- env,
- reinterpret_cast<intptr_t>(this),
- web_contents->GetTopLevelNativeWindow()->GetJavaObject().obj(),
- initial_color,
- suggestions_array.obj()));
+
+ ContentViewCore* content_view_core =
+ ContentViewCore::FromWebContents(web_contents);
+ if (content_view_core) {
+ base::android::ScopedJavaLocalRef<jobject> java_content_view_core =
+ content_view_core->GetJavaObject();
+ if (!java_content_view_core.is_null()) {
+ j_color_chooser_.Reset(Java_ColorChooserAndroid_createColorChooserAndroid(
+ env,
+ reinterpret_cast<intptr_t>(this),
+ java_content_view_core.obj(),
+ initial_color,
+ suggestions_array.obj()));
+ }
+ }
if (j_color_chooser_.is_null())
OnColorChosen(env, j_color_chooser_.obj(), initial_color);
}

Powered by Google App Engine
This is Rietveld 408576698