| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/search_engines/template_url_service_test_util.h" | 5 #include "chrome/browser/search_engines/template_url_service_test_util.h" |
| 6 | 6 |
| 7 #include "base/message_loop/message_loop_proxy.h" | |
| 8 #include "base/run_loop.h" | 7 #include "base/run_loop.h" |
| 8 #include "base/thread_task_runner_handle.h" |
| 9 #include "chrome/browser/history/history_service_factory.h" | 9 #include "chrome/browser/history/history_service_factory.h" |
| 10 #include "chrome/browser/search_engines/chrome_template_url_service_client.h" | 10 #include "chrome/browser/search_engines/chrome_template_url_service_client.h" |
| 11 #include "chrome/test/base/testing_pref_service_syncable.h" | 11 #include "chrome/test/base/testing_pref_service_syncable.h" |
| 12 #include "chrome/test/base/testing_profile.h" | 12 #include "chrome/test/base/testing_profile.h" |
| 13 #include "components/search_engines/default_search_pref_test_util.h" | 13 #include "components/search_engines/default_search_pref_test_util.h" |
| 14 #include "components/search_engines/keyword_table.h" | 14 #include "components/search_engines/keyword_table.h" |
| 15 #include "components/search_engines/keyword_web_data_service.h" | 15 #include "components/search_engines/keyword_web_data_service.h" |
| 16 #include "components/search_engines/template_url_service.h" | 16 #include "components/search_engines/template_url_service.h" |
| 17 #include "components/search_engines/testing_search_terms_data.h" | 17 #include "components/search_engines/testing_search_terms_data.h" |
| 18 #include "components/webdata/common/web_database_service.h" | 18 #include "components/webdata/common/web_database_service.h" |
| (...skipping 24 matching lines...) Expand all Loading... |
| 43 | 43 |
| 44 TemplateURLServiceTestUtil::TemplateURLServiceTestUtil() | 44 TemplateURLServiceTestUtil::TemplateURLServiceTestUtil() |
| 45 : changed_count_(0), | 45 : changed_count_(0), |
| 46 search_terms_data_(NULL) { | 46 search_terms_data_(NULL) { |
| 47 // Make unique temp directory. | 47 // Make unique temp directory. |
| 48 EXPECT_TRUE(temp_dir_.CreateUniqueTempDir()); | 48 EXPECT_TRUE(temp_dir_.CreateUniqueTempDir()); |
| 49 profile_.reset(new TestingProfile(temp_dir_.path())); | 49 profile_.reset(new TestingProfile(temp_dir_.path())); |
| 50 | 50 |
| 51 scoped_refptr<WebDatabaseService> web_database_service = | 51 scoped_refptr<WebDatabaseService> web_database_service = |
| 52 new WebDatabaseService(temp_dir_.path().AppendASCII("webdata"), | 52 new WebDatabaseService(temp_dir_.path().AppendASCII("webdata"), |
| 53 base::MessageLoopProxy::current(), | 53 base::ThreadTaskRunnerHandle::Get(), |
| 54 base::MessageLoopProxy::current()); | 54 base::ThreadTaskRunnerHandle::Get()); |
| 55 web_database_service->AddTable( | 55 web_database_service->AddTable( |
| 56 scoped_ptr<WebDatabaseTable>(new KeywordTable())); | 56 scoped_ptr<WebDatabaseTable>(new KeywordTable())); |
| 57 web_database_service->LoadDatabase(); | 57 web_database_service->LoadDatabase(); |
| 58 | 58 |
| 59 web_data_service_ = new KeywordWebDataService( | 59 web_data_service_ = new KeywordWebDataService( |
| 60 web_database_service.get(), base::MessageLoopProxy::current(), | 60 web_database_service.get(), base::ThreadTaskRunnerHandle::Get(), |
| 61 KeywordWebDataService::ProfileErrorCallback()); | 61 KeywordWebDataService::ProfileErrorCallback()); |
| 62 web_data_service_->Init(); | 62 web_data_service_->Init(); |
| 63 | 63 |
| 64 ResetModel(false); | 64 ResetModel(false); |
| 65 } | 65 } |
| 66 | 66 |
| 67 TemplateURLServiceTestUtil::~TemplateURLServiceTestUtil() { | 67 TemplateURLServiceTestUtil::~TemplateURLServiceTestUtil() { |
| 68 ClearModel(); | 68 ClearModel(); |
| 69 profile_.reset(); | 69 profile_.reset(); |
| 70 | 70 |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 150 DefaultSearchPrefTestUtil::SetManagedPref( | 150 DefaultSearchPrefTestUtil::SetManagedPref( |
| 151 profile()->GetTestingPrefService(), | 151 profile()->GetTestingPrefService(), |
| 152 enabled, name, keyword, search_url, suggest_url, icon_url, encodings, | 152 enabled, name, keyword, search_url, suggest_url, icon_url, encodings, |
| 153 alternate_url, search_terms_replacement_key); | 153 alternate_url, search_terms_replacement_key); |
| 154 } | 154 } |
| 155 | 155 |
| 156 void TemplateURLServiceTestUtil::RemoveManagedDefaultSearchPreferences() { | 156 void TemplateURLServiceTestUtil::RemoveManagedDefaultSearchPreferences() { |
| 157 DefaultSearchPrefTestUtil::RemoveManagedPref( | 157 DefaultSearchPrefTestUtil::RemoveManagedPref( |
| 158 profile()->GetTestingPrefService()); | 158 profile()->GetTestingPrefService()); |
| 159 } | 159 } |
| OLD | NEW |