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

Unified Diff: components/web_contents_delegate_android/color_chooser_android.cc

Issue 639703004: Optimizing DateTimeAndroid and ColorChooserAndroid initializations. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed the review comments. Created 6 years, 2 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 d946fa9364aa23d07f11b22c3adc8da32e7e3c6b..8c49f478d24404c2f9149a55700e588969b5d1c7 100644
--- a/components/web_contents_delegate_android/color_chooser_android.cc
+++ b/components/web_contents_delegate_android/color_chooser_android.cc
@@ -6,10 +6,10 @@
#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/base/android/window_android.h"
using base::android::ConvertUTF16ToJavaString;
@@ -21,10 +21,6 @@ ColorChooserAndroid::ColorChooserAndroid(
const std::vector<content::ColorSuggestion>& suggestions)
: web_contents_(web_contents) {
JNIEnv* env = AttachCurrentThread();
- content::ContentViewCore* content_view_core =
- content::ContentViewCore::FromWebContents(web_contents);
- DCHECK(content_view_core);
-
ScopedJavaLocalRef<jobjectArray> suggestions_array;
if (suggestions.size() > 0) {
@@ -46,9 +42,11 @@ ColorChooserAndroid::ColorChooserAndroid(
j_color_chooser_.Reset(Java_ColorChooserAndroid_createColorChooserAndroid(
env,
reinterpret_cast<intptr_t>(this),
- content_view_core->GetJavaObject().obj(),
+ web_contents->GetTopLevelNativeWindow()->GetJavaObject().obj(),
initial_color,
suggestions_array.obj()));
+ if (j_color_chooser_.is_null())
+ OnColorChosen(env, j_color_chooser_.obj(), initial_color);
}
ColorChooserAndroid::~ColorChooserAndroid() {

Powered by Google App Engine
This is Rietveld 408576698