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
3 // found in the LICENSE file.
5 #include "chrome/browser/ui/android/omnibox/omnibox_url_emphasizer.h"
7 #include "base/android/jni_array.h"
8 #include "base/android/jni_string.h"
9 #include "chrome/browser/autocomplete/chrome_autocomplete_scheme_classifier.h"
10 #include "chrome/browser/profiles/profile_android.h"
11 #include "components/omnibox/browser/autocomplete_input.h"
12 #include "jni/OmniboxUrlEmphasizer_jni.h"
15 ScopedJavaLocalRef
<jintArray
> ParseForEmphasizeComponents(
17 const JavaParamRef
<jclass
>& clazz
,
18 const JavaParamRef
<jobject
>& jprofile
,
19 const JavaParamRef
<jstring
>& jtext
) {
20 Profile
* profile
= ProfileAndroid::FromProfileAndroid(jprofile
);
23 base::string16
text(base::android::ConvertJavaStringToUTF16(env
, jtext
));
25 url::Component scheme
, host
;
26 AutocompleteInput::ParseForEmphasizeComponents(
27 text
, ChromeAutocompleteSchemeClassifier(profile
), &scheme
, &host
);
29 int emphasize_values
[] = {scheme
.begin
, scheme
.len
, host
.begin
, host
.len
};
30 return base::android::ToJavaIntArray(env
, emphasize_values
, 4);
34 bool OmniboxUrlEmphasizer::RegisterOmniboxUrlEmphasizer(JNIEnv
* env
) {
35 return RegisterNativesImpl(env
);