| 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/android/omnibox/autocomplete_controller_android.h" | 5 #include "chrome/browser/android/omnibox/autocomplete_controller_android.h" |
| 6 | 6 |
| 7 #include "base/android/jni_android.h" | 7 #include "base/android/jni_android.h" |
| 8 #include "base/android/jni_string.h" | 8 #include "base/android/jni_string.h" |
| 9 #include "base/prefs/pref_service.h" | 9 #include "base/prefs/pref_service.h" |
| 10 #include "base/strings/string16.h" | 10 #include "base/strings/string16.h" |
| (...skipping 23 matching lines...) Expand all Loading... |
| 34 #include "components/bookmarks/browser/bookmark_model.h" | 34 #include "components/bookmarks/browser/bookmark_model.h" |
| 35 #include "components/keyed_service/content/browser_context_dependency_manager.h" | 35 #include "components/keyed_service/content/browser_context_dependency_manager.h" |
| 36 #include "components/metrics/proto/omnibox_event.pb.h" | 36 #include "components/metrics/proto/omnibox_event.pb.h" |
| 37 #include "components/omnibox/autocomplete_input.h" | 37 #include "components/omnibox/autocomplete_input.h" |
| 38 #include "components/omnibox/autocomplete_match.h" | 38 #include "components/omnibox/autocomplete_match.h" |
| 39 #include "components/omnibox/autocomplete_match_type.h" | 39 #include "components/omnibox/autocomplete_match_type.h" |
| 40 #include "components/omnibox/omnibox_field_trial.h" | 40 #include "components/omnibox/omnibox_field_trial.h" |
| 41 #include "components/omnibox/search_provider.h" | 41 #include "components/omnibox/search_provider.h" |
| 42 #include "components/search/search.h" | 42 #include "components/search/search.h" |
| 43 #include "components/search_engines/template_url_service.h" | 43 #include "components/search_engines/template_url_service.h" |
| 44 #include "components/url_formatter/url_formatter.h" |
| 44 #include "content/public/browser/notification_details.h" | 45 #include "content/public/browser/notification_details.h" |
| 45 #include "content/public/browser/notification_service.h" | 46 #include "content/public/browser/notification_service.h" |
| 46 #include "content/public/browser/notification_source.h" | 47 #include "content/public/browser/notification_source.h" |
| 47 #include "content/public/browser/web_contents.h" | 48 #include "content/public/browser/web_contents.h" |
| 48 #include "content/public/common/url_constants.h" | 49 #include "content/public/common/url_constants.h" |
| 49 #include "jni/AutocompleteController_jni.h" | 50 #include "jni/AutocompleteController_jni.h" |
| 50 #include "net/base/escape.h" | 51 #include "net/base/escape.h" |
| 51 #include "net/base/net_util.h" | |
| 52 #include "net/base/registry_controlled_domains/registry_controlled_domain.h" | 52 #include "net/base/registry_controlled_domains/registry_controlled_domain.h" |
| 53 | 53 |
| 54 using base::android::AttachCurrentThread; | 54 using base::android::AttachCurrentThread; |
| 55 using base::android::ConvertJavaStringToUTF16; | 55 using base::android::ConvertJavaStringToUTF16; |
| 56 using base::android::ConvertUTF8ToJavaString; | 56 using base::android::ConvertUTF8ToJavaString; |
| 57 using base::android::ConvertUTF16ToJavaString; | 57 using base::android::ConvertUTF16ToJavaString; |
| 58 using bookmarks::BookmarkModel; | 58 using bookmarks::BookmarkModel; |
| 59 using metrics::OmniboxEventProto; | 59 using metrics::OmniboxEventProto; |
| 60 | 60 |
| 61 namespace { | 61 namespace { |
| (...skipping 401 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 463 } | 463 } |
| 464 | 464 |
| 465 base::string16 AutocompleteControllerAndroid::FormatURLUsingAcceptLanguages( | 465 base::string16 AutocompleteControllerAndroid::FormatURLUsingAcceptLanguages( |
| 466 GURL url) { | 466 GURL url) { |
| 467 if (profile_ == NULL) | 467 if (profile_ == NULL) |
| 468 return base::string16(); | 468 return base::string16(); |
| 469 | 469 |
| 470 std::string languages( | 470 std::string languages( |
| 471 profile_->GetPrefs()->GetString(prefs::kAcceptLanguages)); | 471 profile_->GetPrefs()->GetString(prefs::kAcceptLanguages)); |
| 472 | 472 |
| 473 return net::FormatUrl(url, languages, net::kFormatUrlOmitAll, | 473 return url_formatter::FormatUrl( |
| 474 net::UnescapeRule::SPACES, NULL, NULL, NULL); | 474 url, languages, url_formatter::kFormatUrlOmitAll, |
| 475 net::UnescapeRule::SPACES, nullptr, nullptr, nullptr); |
| 475 } | 476 } |
| 476 | 477 |
| 477 ScopedJavaLocalRef<jobject> | 478 ScopedJavaLocalRef<jobject> |
| 478 AutocompleteControllerAndroid::GetTopSynchronousResult( | 479 AutocompleteControllerAndroid::GetTopSynchronousResult( |
| 479 JNIEnv* env, | 480 JNIEnv* env, |
| 480 jobject obj, | 481 jobject obj, |
| 481 jstring j_text, | 482 jstring j_text, |
| 482 bool prevent_inline_autocomplete) { | 483 bool prevent_inline_autocomplete) { |
| 483 if (!autocomplete_controller_) | 484 if (!autocomplete_controller_) |
| 484 return ScopedJavaLocalRef<jobject>(); | 485 return ScopedJavaLocalRef<jobject>(); |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 549 return; | 550 return; |
| 550 | 551 |
| 551 // ZeroSuggestPrefetcher deletes itself after it's done prefetching. | 552 // ZeroSuggestPrefetcher deletes itself after it's done prefetching. |
| 552 new ZeroSuggestPrefetcher(profile); | 553 new ZeroSuggestPrefetcher(profile); |
| 553 } | 554 } |
| 554 | 555 |
| 555 // Register native methods | 556 // Register native methods |
| 556 bool RegisterAutocompleteControllerAndroid(JNIEnv* env) { | 557 bool RegisterAutocompleteControllerAndroid(JNIEnv* env) { |
| 557 return RegisterNativesImpl(env); | 558 return RegisterNativesImpl(env); |
| 558 } | 559 } |
| OLD | NEW |