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 // static | 14 // static |
15 ScopedJavaLocalRef<jintArray> ParseForEmphasizeComponents(JNIEnv* env, | 15 ScopedJavaLocalRef<jintArray> ParseForEmphasizeComponents( |
16 jclass clazz, | 16 JNIEnv* env, |
17 jobject jprofile, | 17 const JavaParamRef<jclass>& clazz, |
18 jstring jtext) { | 18 const JavaParamRef<jobject>& jprofile, |
| 19 const JavaParamRef<jstring>& jtext) { |
19 Profile* profile = ProfileAndroid::FromProfileAndroid(jprofile); | 20 Profile* profile = ProfileAndroid::FromProfileAndroid(jprofile); |
20 DCHECK(profile); | 21 DCHECK(profile); |
21 | 22 |
22 base::string16 text(base::android::ConvertJavaStringToUTF16(env, jtext)); | 23 base::string16 text(base::android::ConvertJavaStringToUTF16(env, jtext)); |
23 | 24 |
24 url::Component scheme, host; | 25 url::Component scheme, host; |
25 AutocompleteInput::ParseForEmphasizeComponents( | 26 AutocompleteInput::ParseForEmphasizeComponents( |
26 text, ChromeAutocompleteSchemeClassifier(profile), &scheme, &host); | 27 text, ChromeAutocompleteSchemeClassifier(profile), &scheme, &host); |
27 | 28 |
28 int emphasize_values[] = {scheme.begin, scheme.len, host.begin, host.len}; | 29 int emphasize_values[] = {scheme.begin, scheme.len, host.begin, host.len}; |
29 return base::android::ToJavaIntArray(env, emphasize_values, 4); | 30 return base::android::ToJavaIntArray(env, emphasize_values, 4); |
30 } | 31 } |
31 | 32 |
32 // static | 33 // static |
33 bool OmniboxUrlEmphasizer::RegisterOmniboxUrlEmphasizer(JNIEnv* env) { | 34 bool OmniboxUrlEmphasizer::RegisterOmniboxUrlEmphasizer(JNIEnv* env) { |
34 return RegisterNativesImpl(env); | 35 return RegisterNativesImpl(env); |
35 } | 36 } |
OLD | NEW |