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