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/ui/android/omnibox/omnibox_url_emphasizer.h" | 5 #include "chrome/browser/ui/android/omnibox/omnibox_url_emphasizer.h" |
6 | 6 |
7 #include "base/android/jni_array.h" | 7 #include "base/android/jni_array.h" |
8 #include "base/android/jni_string.h" | 8 #include "base/android/jni_string.h" |
9 #include "chrome/browser/autocomplete/chrome_autocomplete_scheme_classifier.h" | 9 #include "chrome/browser/autocomplete/chrome_autocomplete_scheme_classifier.h" |
10 #include "chrome/browser/profiles/profile_android.h" | 10 #include "chrome/browser/profiles/profile_android.h" |
11 #include "components/omnibox/browser/autocomplete_input.h" | 11 #include "components/omnibox/browser/autocomplete_input.h" |
12 #include "jni/OmniboxUrlEmphasizer_jni.h" | 12 #include "jni/OmniboxUrlEmphasizer_jni.h" |
13 | 13 |
| 14 using base::android::JavaParamRef; |
| 15 using base::android::ScopedJavaLocalRef; |
| 16 |
14 // static | 17 // static |
15 ScopedJavaLocalRef<jintArray> ParseForEmphasizeComponents( | 18 ScopedJavaLocalRef<jintArray> ParseForEmphasizeComponents( |
16 JNIEnv* env, | 19 JNIEnv* env, |
17 const JavaParamRef<jclass>& clazz, | 20 const JavaParamRef<jclass>& clazz, |
18 const JavaParamRef<jobject>& jprofile, | 21 const JavaParamRef<jobject>& jprofile, |
19 const JavaParamRef<jstring>& jtext) { | 22 const JavaParamRef<jstring>& jtext) { |
20 Profile* profile = ProfileAndroid::FromProfileAndroid(jprofile); | 23 Profile* profile = ProfileAndroid::FromProfileAndroid(jprofile); |
21 DCHECK(profile); | 24 DCHECK(profile); |
22 | 25 |
23 base::string16 text(base::android::ConvertJavaStringToUTF16(env, jtext)); | 26 base::string16 text(base::android::ConvertJavaStringToUTF16(env, jtext)); |
24 | 27 |
25 url::Component scheme, host; | 28 url::Component scheme, host; |
26 AutocompleteInput::ParseForEmphasizeComponents( | 29 AutocompleteInput::ParseForEmphasizeComponents( |
27 text, ChromeAutocompleteSchemeClassifier(profile), &scheme, &host); | 30 text, ChromeAutocompleteSchemeClassifier(profile), &scheme, &host); |
28 | 31 |
29 int emphasize_values[] = {scheme.begin, scheme.len, host.begin, host.len}; | 32 int emphasize_values[] = {scheme.begin, scheme.len, host.begin, host.len}; |
30 return base::android::ToJavaIntArray(env, emphasize_values, 4); | 33 return base::android::ToJavaIntArray(env, emphasize_values, 4); |
31 } | 34 } |
32 | 35 |
33 // static | 36 // static |
34 bool OmniboxUrlEmphasizer::RegisterOmniboxUrlEmphasizer(JNIEnv* env) { | 37 bool OmniboxUrlEmphasizer::RegisterOmniboxUrlEmphasizer(JNIEnv* env) { |
35 return RegisterNativesImpl(env); | 38 return RegisterNativesImpl(env); |
36 } | 39 } |
OLD | NEW |