Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1000)

Side by Side Diff: chrome/browser/dom_distiller/tab_utils_android.cc

Issue 1841653003: Drop |languages| from {Format,Elide}Url* and IDNToUnicode (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix typo in elide_url.cc Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 "chrome/browser/dom_distiller/tab_utils.h" 10 #include "chrome/browser/dom_distiller/tab_utils.h"
11 #include "chrome/browser/profiles/profile.h" 11 #include "chrome/browser/profiles/profile.h"
12 #include "chrome/browser/profiles/profile_manager.h" 12 #include "chrome/browser/profiles/profile_manager.h"
13 #include "chrome/common/pref_names.h"
14 #include "components/dom_distiller/core/experiments.h" 13 #include "components/dom_distiller/core/experiments.h"
15 #include "components/prefs/pref_service.h"
16 #include "components/url_formatter/url_formatter.h" 14 #include "components/url_formatter/url_formatter.h"
17 #include "content/public/browser/web_contents.h" 15 #include "content/public/browser/web_contents.h"
18 #include "content/public/common/content_constants.h" 16 #include "content/public/common/content_constants.h"
19 #include "jni/DomDistillerTabUtils_jni.h" 17 #include "jni/DomDistillerTabUtils_jni.h"
20 #include "url/gurl.h" 18 #include "url/gurl.h"
21 19
22 namespace android { 20 namespace android {
23 21
24 void DistillCurrentPageAndView(JNIEnv* env, 22 void DistillCurrentPageAndView(JNIEnv* env,
25 const JavaParamRef<jclass>& clazz, 23 const JavaParamRef<jclass>& clazz,
(...skipping 12 matching lines...) Expand all
38 content::WebContents* destination_web_contents = 36 content::WebContents* destination_web_contents =
39 content::WebContents::FromJavaWebContents(j_destination_web_contents); 37 content::WebContents::FromJavaWebContents(j_destination_web_contents);
40 ::DistillAndView(source_web_contents, destination_web_contents); 38 ::DistillAndView(source_web_contents, destination_web_contents);
41 } 39 }
42 40
43 ScopedJavaLocalRef<jstring> GetFormattedUrlFromOriginalDistillerUrl( 41 ScopedJavaLocalRef<jstring> GetFormattedUrlFromOriginalDistillerUrl(
44 JNIEnv* env, 42 JNIEnv* env,
45 const JavaParamRef<jclass>& clazz, 43 const JavaParamRef<jclass>& clazz,
46 const JavaParamRef<jstring>& j_url) { 44 const JavaParamRef<jstring>& j_url) {
47 GURL url(base::android::ConvertJavaStringToUTF8(env, j_url)); 45 GURL url(base::android::ConvertJavaStringToUTF8(env, j_url));
48 Profile* profile = ProfileManager::GetLastUsedProfile();
49 std::string languages; // Empty if Profile cannot be retrieved.
50 if (profile) {
51 languages = profile->GetPrefs()->GetString(prefs::kAcceptLanguages);
52 }
53 46
54 if (url.spec().length() > content::kMaxURLDisplayChars) 47 if (url.spec().length() > content::kMaxURLDisplayChars)
55 url = url.IsStandard() ? url.GetOrigin() : GURL(url.scheme() + ":"); 48 url = url.IsStandard() ? url.GetOrigin() : GURL(url.scheme() + ":");
56 49
57 // Note that we can't unescape spaces here, because if the user copies this 50 // Note that we can't unescape spaces here, because if the user copies this
58 // and pastes it into another program, that program may think the URL ends at 51 // and pastes it into another program, that program may think the URL ends at
59 // the space. 52 // the space.
60 return base::android::ConvertUTF16ToJavaString( 53 return base::android::ConvertUTF16ToJavaString(
61 env, url_formatter::FormatUrl( 54 env, url_formatter::FormatUrl(
62 url, languages, url_formatter::kFormatUrlOmitAll, 55 url, url_formatter::kFormatUrlOmitAll,
63 net::UnescapeRule::NORMAL, nullptr, nullptr, nullptr)); 56 net::UnescapeRule::NORMAL, nullptr, nullptr, nullptr));
64 } 57 }
65 58
66 // Returns true if the distiller experiment is set to use any heuristic other 59 // Returns true if the distiller experiment is set to use any heuristic other
67 // than "NONE". This is used to prevent the Reader Mode panel from loading 60 // than "NONE". This is used to prevent the Reader Mode panel from loading
68 // when it would otherwise never be shown. 61 // when it would otherwise never be shown.
69 jboolean IsDistillerHeuristicsEnabled(JNIEnv* env, 62 jboolean IsDistillerHeuristicsEnabled(JNIEnv* env,
70 const JavaParamRef<jclass>& clazz) { 63 const JavaParamRef<jclass>& clazz) {
71 return dom_distiller::GetDistillerHeuristicsType() 64 return dom_distiller::GetDistillerHeuristicsType()
72 != dom_distiller::DistillerHeuristicsType::NONE; 65 != dom_distiller::DistillerHeuristicsType::NONE;
73 } 66 }
74 67
75 } // namespace android 68 } // namespace android
76 69
77 bool RegisterDomDistillerTabUtils(JNIEnv* env) { 70 bool RegisterDomDistillerTabUtils(JNIEnv* env) {
78 return android::RegisterNativesImpl(env); 71 return android::RegisterNativesImpl(env);
79 } 72 }
OLDNEW
« no previous file with comments | « chrome/browser/custom_home_pages_table_model.cc ('k') | chrome/browser/download/download_query.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698