| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 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/dom_distiller/tab_utils_android.h" | 5 #include "chrome/browser/dom_distiller/tab_utils_android.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/android/jni_string.h" | 9 #include "base/android/jni_string.h" |
| 10 #include "base/prefs/pref_service.h" | 10 #include "base/prefs/pref_service.h" |
| 11 #include "chrome/browser/dom_distiller/tab_utils.h" | 11 #include "chrome/browser/dom_distiller/tab_utils.h" |
| 12 #include "chrome/browser/profiles/profile.h" | 12 #include "chrome/browser/profiles/profile.h" |
| 13 #include "chrome/browser/profiles/profile_manager.h" | 13 #include "chrome/browser/profiles/profile_manager.h" |
| 14 #include "chrome/common/pref_names.h" | 14 #include "chrome/common/pref_names.h" |
| 15 #include "components/url_formatter/url_formatter.h" |
| 15 #include "content/public/browser/web_contents.h" | 16 #include "content/public/browser/web_contents.h" |
| 16 #include "content/public/common/content_constants.h" | 17 #include "content/public/common/content_constants.h" |
| 17 #include "jni/DomDistillerTabUtils_jni.h" | 18 #include "jni/DomDistillerTabUtils_jni.h" |
| 18 #include "net/base/net_util.h" | 19 #include "net/base/net_util.h" |
| 19 #include "url/gurl.h" | 20 #include "url/gurl.h" |
| 20 | 21 |
| 21 namespace android { | 22 namespace android { |
| 22 | 23 |
| 23 void DistillCurrentPageAndView(JNIEnv* env, | 24 void DistillCurrentPageAndView(JNIEnv* env, |
| 24 jclass clazz, | 25 jclass clazz, |
| (...skipping 24 matching lines...) Expand all Loading... |
| 49 languages = profile->GetPrefs()->GetString(prefs::kAcceptLanguages); | 50 languages = profile->GetPrefs()->GetString(prefs::kAcceptLanguages); |
| 50 } | 51 } |
| 51 | 52 |
| 52 if (url.spec().length() > content::kMaxURLDisplayChars) | 53 if (url.spec().length() > content::kMaxURLDisplayChars) |
| 53 url = url.IsStandard() ? url.GetOrigin() : GURL(url.scheme() + ":"); | 54 url = url.IsStandard() ? url.GetOrigin() : GURL(url.scheme() + ":"); |
| 54 | 55 |
| 55 // Note that we can't unescape spaces here, because if the user copies this | 56 // Note that we can't unescape spaces here, because if the user copies this |
| 56 // and pastes it into another program, that program may think the URL ends at | 57 // and pastes it into another program, that program may think the URL ends at |
| 57 // the space. | 58 // the space. |
| 58 return base::android::ConvertUTF16ToJavaString( | 59 return base::android::ConvertUTF16ToJavaString( |
| 59 env, | 60 env, url_formatter::FormatUrl( |
| 60 net::FormatUrl(url, | 61 url, languages, url_formatter::kFormatUrlOmitAll, |
| 61 languages, | 62 net::UnescapeRule::NORMAL, nullptr, nullptr, nullptr)) |
| 62 net::kFormatUrlOmitAll, | 63 .Release(); |
| 63 net::UnescapeRule::NORMAL, | |
| 64 NULL, | |
| 65 NULL, | |
| 66 NULL)).Release(); | |
| 67 } | 64 } |
| 68 | 65 |
| 69 } // namespace android | 66 } // namespace android |
| 70 | 67 |
| 71 bool RegisterDomDistillerTabUtils(JNIEnv* env) { | 68 bool RegisterDomDistillerTabUtils(JNIEnv* env) { |
| 72 return android::RegisterNativesImpl(env); | 69 return android::RegisterNativesImpl(env); |
| 73 } | 70 } |
| OLD | NEW |