Add new certificateProvider extension API.
[chromium-blink-merge.git] / chrome / browser / android / dom_distiller / external_feedback_reporter_android.cc
blob04cf18ae96735b39ccd78a42dd3bd8251ebeb287
1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "chrome/browser/android/dom_distiller/external_feedback_reporter_android.h"
7 #include "base/android/jni_string.h"
8 #include "chrome/browser/ui/android/window_android_helper.h"
9 #include "components/dom_distiller/core/url_utils.h"
10 #include "content/public/browser/web_contents.h"
11 #include "jni/DomDistillerFeedbackReporter_jni.h"
12 #include "ui/android/window_android.h"
13 #include "url/gurl.h"
15 namespace dom_distiller {
17 namespace android {
19 // ExternalFeedbackReporter implementation.
20 void ExternalFeedbackReporterAndroid::ReportExternalFeedback(
21 content::WebContents* web_contents,
22 const GURL& url,
23 const bool good) {
24 if (!web_contents)
25 return;
26 WindowAndroidHelper* helper =
27 content::WebContentsUserData<WindowAndroidHelper>::FromWebContents(
28 web_contents);
29 DCHECK(helper);
31 ui::WindowAndroid* window = helper->GetWindowAndroid();
32 DCHECK(window);
34 JNIEnv* env = base::android::AttachCurrentThread();
35 ScopedJavaLocalRef<jstring> jurl = base::android::ConvertUTF8ToJavaString(
36 env, url_utils::GetOriginalUrlFromDistillerUrl(url).spec());
38 Java_DomDistillerFeedbackReporter_reportFeedbackWithWindow(
39 env, window->GetJavaObject().obj(), jurl.obj(), good);
42 // static
43 bool RegisterFeedbackReporter(JNIEnv* env) {
44 return RegisterNativesImpl(env);
47 } // namespace android
49 } // namespace dom_distiller