OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/android/dom_distiller/external_feedback_reporter_androi
d.h" | 5 #include "chrome/browser/android/dom_distiller/distiller_ui_handle_android.h" |
6 | 6 |
7 #include "base/android/jni_string.h" | 7 #include "base/android/jni_string.h" |
8 #include "chrome/browser/ui/android/window_android_helper.h" | 8 #include "chrome/browser/ui/android/window_android_helper.h" |
9 #include "components/dom_distiller/core/url_utils.h" | 9 #include "components/dom_distiller/core/url_utils.h" |
10 #include "content/public/browser/web_contents.h" | 10 #include "content/public/browser/web_contents.h" |
11 #include "jni/DomDistillerFeedbackReporter_jni.h" | 11 #include "jni/DomDistillerUIUtils_jni.h" |
12 #include "ui/android/window_android.h" | 12 #include "ui/android/window_android.h" |
13 #include "url/gurl.h" | 13 #include "url/gurl.h" |
14 | 14 |
15 namespace dom_distiller { | 15 namespace dom_distiller { |
16 | 16 |
17 namespace android { | 17 namespace android { |
18 | 18 |
19 // ExternalFeedbackReporter implementation. | 19 // static |
20 void ExternalFeedbackReporterAndroid::ReportExternalFeedback( | 20 void DistillerUIHandleAndroid::ReportExternalFeedback( |
21 content::WebContents* web_contents, | 21 content::WebContents* web_contents, |
22 const GURL& url, | 22 const GURL& url, |
23 const bool good) { | 23 const bool good) { |
24 if (!web_contents) | 24 if (!web_contents) |
25 return; | 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 | 26 |
34 JNIEnv* env = base::android::AttachCurrentThread(); | 27 JNIEnv* env = base::android::AttachCurrentThread(); |
35 ScopedJavaLocalRef<jstring> jurl = base::android::ConvertUTF8ToJavaString( | 28 ScopedJavaLocalRef<jstring> jurl = base::android::ConvertUTF8ToJavaString( |
36 env, url_utils::GetOriginalUrlFromDistillerUrl(url).spec()); | 29 env, url_utils::GetOriginalUrlFromDistillerUrl(url).spec()); |
37 | 30 |
38 Java_DomDistillerFeedbackReporter_reportFeedbackWithWindow( | 31 Java_DomDistillerUIUtils_reportFeedbackWithWebContents( |
39 env, window->GetJavaObject().obj(), jurl.obj(), good); | 32 env, web_contents->GetJavaWebContents().obj(), jurl.obj(), good); |
40 } | 33 } |
41 | 34 |
42 // static | 35 // static |
43 bool RegisterFeedbackReporter(JNIEnv* env) { | 36 void DistillerUIHandleAndroid::OpenSettings( |
| 37 content::WebContents* web_contents) { |
| 38 JNIEnv* env = base::android::AttachCurrentThread(); |
| 39 Java_DomDistillerUIUtils_openSettings(env, |
| 40 web_contents->GetJavaWebContents().obj()); |
| 41 } |
| 42 |
| 43 // static |
| 44 bool RegisterUIHandle(JNIEnv* env) { |
44 return RegisterNativesImpl(env); | 45 return RegisterNativesImpl(env); |
45 } | 46 } |
46 | 47 |
47 } // namespace android | 48 } // namespace android |
48 | 49 |
49 } // namespace dom_distiller | 50 } // namespace dom_distiller |
OLD | NEW |