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

Side by Side Diff: chrome/browser/android/url_utilities.cc

Issue 1357563002: Expose FormatUrlForSecurityDisplay to Java on Android. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Using a fake scheme in the test makes formatUrlForSecurityDisplay be conservative, breaking the tes… Created 5 years, 3 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
« no previous file with comments | « chrome/android/javatests/src/org/chromium/chrome/browser/webapps/WebappUrlBarTest.java ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 <string>
6
5 #include "base/android/jni_android.h" 7 #include "base/android/jni_android.h"
6 #include "base/android/jni_string.h" 8 #include "base/android/jni_string.h"
7 #include "components/google/core/browser/google_util.h" 9 #include "components/google/core/browser/google_util.h"
10 #include "components/url_formatter/elide_url.h"
8 #include "components/url_formatter/url_fixer.h" 11 #include "components/url_formatter/url_fixer.h"
9 #include "jni/UrlUtilities_jni.h" 12 #include "jni/UrlUtilities_jni.h"
10 #include "net/base/registry_controlled_domains/registry_controlled_domain.h" 13 #include "net/base/registry_controlled_domains/registry_controlled_domain.h"
11 #include "url/gurl.h" 14 #include "url/gurl.h"
12 15
13 using base::android::ConvertJavaStringToUTF8; 16 using base::android::ConvertJavaStringToUTF8;
14 17
15 namespace { 18 namespace {
16 19
17 GURL ConvertJavaStringToGURL(JNIEnv*env, jstring url) { 20 GURL ConvertJavaStringToGURL(JNIEnv*env, jstring url) {
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 66
64 static jboolean IsGoogleSearchUrl(JNIEnv* env, 67 static jboolean IsGoogleSearchUrl(JNIEnv* env,
65 const JavaParamRef<jclass>& clazz, 68 const JavaParamRef<jclass>& clazz,
66 const JavaParamRef<jstring>& url) { 69 const JavaParamRef<jstring>& url) {
67 GURL gurl = ConvertJavaStringToGURL(env, url); 70 GURL gurl = ConvertJavaStringToGURL(env, url);
68 if (gurl.is_empty()) 71 if (gurl.is_empty())
69 return false; 72 return false;
70 return google_util::IsGoogleSearchUrl(gurl); 73 return google_util::IsGoogleSearchUrl(gurl);
71 } 74 }
72 75
76 static ScopedJavaLocalRef<jstring> FormatUrlForSecurityDisplay(
77 JNIEnv* env,
78 const JavaParamRef<jclass>& clazz,
79 const JavaParamRef<jstring>& url) {
80 return base::android::ConvertUTF16ToJavaString(
81 env, url_formatter::FormatUrlForSecurityDisplay(
82 ConvertJavaStringToGURL(env, url), std::string()));
83 }
84
85 static ScopedJavaLocalRef<jstring> FormatUrlForSecurityDisplayOmitScheme(
86 JNIEnv* env,
87 const JavaParamRef<jclass>& clazz,
88 const JavaParamRef<jstring>& url) {
89 return base::android::ConvertUTF16ToJavaString(
90 env, url_formatter::FormatUrlForSecurityDisplayOmitScheme(
91 ConvertJavaStringToGURL(env, url), std::string()));
92 }
93
73 static jboolean IsGoogleHomePageUrl(JNIEnv* env, 94 static jboolean IsGoogleHomePageUrl(JNIEnv* env,
74 const JavaParamRef<jclass>& clazz, 95 const JavaParamRef<jclass>& clazz,
75 const JavaParamRef<jstring>& url) { 96 const JavaParamRef<jstring>& url) {
76 GURL gurl = ConvertJavaStringToGURL(env, url); 97 GURL gurl = ConvertJavaStringToGURL(env, url);
77 if (gurl.is_empty()) 98 if (gurl.is_empty())
78 return false; 99 return false;
79 return google_util::IsGoogleHomePageUrl(gurl); 100 return google_util::IsGoogleHomePageUrl(gurl);
80 } 101 }
81 102
82 static ScopedJavaLocalRef<jstring> FixupUrl( 103 static ScopedJavaLocalRef<jstring> FixupUrl(
(...skipping 10 matching lines...) Expand all
93 114
94 return fixed_url.is_valid() 115 return fixed_url.is_valid()
95 ? base::android::ConvertUTF8ToJavaString(env, fixed_url.spec()) 116 ? base::android::ConvertUTF8ToJavaString(env, fixed_url.spec())
96 : ScopedJavaLocalRef<jstring>(); 117 : ScopedJavaLocalRef<jstring>();
97 } 118 }
98 119
99 // Register native methods 120 // Register native methods
100 bool RegisterUrlUtilities(JNIEnv* env) { 121 bool RegisterUrlUtilities(JNIEnv* env) {
101 return RegisterNativesImpl(env); 122 return RegisterNativesImpl(env);
102 } 123 }
OLDNEW
« no previous file with comments | « chrome/android/javatests/src/org/chromium/chrome/browser/webapps/WebappUrlBarTest.java ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698