1 // Copyright 2014 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 "components/dom_distiller/core/url_utils_android.h"
9 #include "base/android/jni_string.h"
10 #include "components/dom_distiller/core/url_constants.h"
11 #include "components/dom_distiller/core/url_utils.h"
12 #include "jni/DomDistillerUrlUtils_jni.h"
13 #include "net/base/url_util.h"
16 namespace dom_distiller
{
22 jstring
GetDistillerViewUrlFromUrl(JNIEnv
* env
,
26 std::string
scheme(base::android::ConvertJavaStringToUTF8(env
, j_scheme
));
27 GURL
url(base::android::ConvertJavaStringToUTF8(env
, j_url
));
28 if (!url
.is_valid()) {
32 dom_distiller::url_utils::GetDistillerViewUrlFromUrl(scheme
, url
);
33 if (!view_url
.is_valid()) {
36 return base::android::ConvertUTF8ToJavaString(env
, view_url
.spec()).Release();
39 jstring
GetOriginalUrlFromDistillerUrl(JNIEnv
* env
,
42 GURL
url(base::android::ConvertJavaStringToUTF8(env
, j_url
));
46 std::string original_url_str
;
47 net::GetValueForKeyInQuery(url
, kUrlKey
, &original_url_str
);
48 GURL
original_url(original_url_str
);
49 if (!original_url
.is_valid())
52 return base::android::ConvertUTF8ToJavaString(env
, original_url
.spec())
56 jboolean
IsUrlReportable(JNIEnv
* env
,
60 std::string
scheme(base::android::ConvertJavaStringToUTF8(env
, j_scheme
));
61 GURL
url(base::android::ConvertJavaStringToUTF8(env
, j_url
));
62 return dom_distiller::url_utils::IsUrlReportable(scheme
, url
);
65 bool RegisterUrlUtils(JNIEnv
* env
) { return RegisterNativesImpl(env
); }
67 } // namespace android
69 } // namespace url_utils
71 } // namespace dom_distiller