OLD | NEW |
| (Empty) |
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. | |
4 | |
5 #include "chrome/browser/android/dom_distiller/external_feedback_reporter_androi
d.h" | |
6 | |
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" | |
14 | |
15 namespace dom_distiller { | |
16 | |
17 namespace android { | |
18 | |
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); | |
30 | |
31 ui::WindowAndroid* window = helper->GetWindowAndroid(); | |
32 DCHECK(window); | |
33 | |
34 JNIEnv* env = base::android::AttachCurrentThread(); | |
35 ScopedJavaLocalRef<jstring> jurl = base::android::ConvertUTF8ToJavaString( | |
36 env, url_utils::GetOriginalUrlFromDistillerUrl(url).spec()); | |
37 | |
38 Java_DomDistillerFeedbackReporter_reportFeedbackWithWindow( | |
39 env, window->GetJavaObject().obj(), jurl.obj(), good); | |
40 } | |
41 | |
42 // static | |
43 bool RegisterFeedbackReporter(JNIEnv* env) { | |
44 return RegisterNativesImpl(env); | |
45 } | |
46 | |
47 } // namespace android | |
48 | |
49 } // namespace dom_distiller | |
OLD | NEW |