| OLD | NEW |
| 1 // Copyright (c) 2016 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2016 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/locale/special_locale_handler.h" | 5 #include "chrome/browser/android/locale/special_locale_handler.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/android/jni_weak_ref.h" | 9 #include "base/android/jni_weak_ref.h" |
| 10 #include "base/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 58 const JavaParamRef<jobject>& obj) { | 58 const JavaParamRef<jobject>& obj) { |
| 59 DCHECK(locale_.length() == 2); | 59 DCHECK(locale_.length() == 2); |
| 60 | 60 |
| 61 std::vector<std::unique_ptr<TemplateURLData>> prepopulated_list = | 61 std::vector<std::unique_ptr<TemplateURLData>> prepopulated_list = |
| 62 GetLocalPrepopulatedEngines(profile_); | 62 GetLocalPrepopulatedEngines(profile_); |
| 63 | 63 |
| 64 if (prepopulated_list.empty()) | 64 if (prepopulated_list.empty()) |
| 65 return false; | 65 return false; |
| 66 | 66 |
| 67 for (const auto& data_url : prepopulated_list) { | 67 for (const auto& data_url : prepopulated_list) { |
| 68 TemplateURL* existing = template_url_service_->GetTemplateURLForKeyword( | 68 const TemplateURL* existing = |
| 69 data_url.get()->keyword()); | 69 template_url_service_->GetTemplateURLForKeyword( |
| 70 data_url.get()->keyword()); |
| 70 // Do not add local engines if there is already one. | 71 // Do not add local engines if there is already one. |
| 71 if (existing) | 72 if (existing) |
| 72 continue; | 73 continue; |
| 73 | 74 |
| 74 data_url.get()->safe_for_autoreplace = true; | 75 data_url.get()->safe_for_autoreplace = true; |
| 75 std::unique_ptr<TemplateURL> turl( | 76 std::unique_ptr<TemplateURL> turl( |
| 76 new TemplateURL(*data_url, TemplateURL::LOCAL)); | 77 new TemplateURL(*data_url, TemplateURL::LOCAL)); |
| 77 TemplateURL* added_turl = template_url_service_->Add(std::move(turl)); | 78 TemplateURL* added_turl = template_url_service_->Add(std::move(turl)); |
| 78 if (added_turl) { | 79 if (added_turl) { |
| 79 prepopulate_ids_.push_back(added_turl->prepopulate_id()); | 80 prepopulate_ids_.push_back(added_turl->prepopulate_id()); |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 139 int SpecialLocaleHandler::GetDesignatedSearchEngine() { | 140 int SpecialLocaleHandler::GetDesignatedSearchEngine() { |
| 140 return TemplateURLPrepopulateData::sogou.id; | 141 return TemplateURLPrepopulateData::sogou.id; |
| 141 } | 142 } |
| 142 | 143 |
| 143 SpecialLocaleHandler::~SpecialLocaleHandler() {} | 144 SpecialLocaleHandler::~SpecialLocaleHandler() {} |
| 144 | 145 |
| 145 // static | 146 // static |
| 146 bool RegisterSpecialLocaleHandler(JNIEnv* env) { | 147 bool RegisterSpecialLocaleHandler(JNIEnv* env) { |
| 147 return RegisterNativesImpl(env); | 148 return RegisterNativesImpl(env); |
| 148 } | 149 } |
| OLD | NEW |