diff options
author | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2019-07-31 15:50:41 +0200 |
---|---|---|
committer | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2019-08-30 12:35:23 +0000 |
commit | 7b2ffa587235a47d4094787d72f38102089f402a (patch) | |
tree | 30e82af9cbab08a7fa028bb18f4f2987a3f74dfa /chromium/components/search_engines | |
parent | d94af01c90575348c4e81a418257f254b6f8d225 (diff) | |
download | qtwebengine-chromium-7b2ffa587235a47d4094787d72f38102089f402a.tar.gz |
BASELINE: Update Chromium to 76.0.3809.94
Change-Id: I321c3f5f929c105aec0f98c5091ef6108822e647
Reviewed-by: Michael BrĂ¼ning <michael.bruning@qt.io>
Diffstat (limited to 'chromium/components/search_engines')
8 files changed, 7 insertions, 315 deletions
diff --git a/chromium/components/search_engines/BUILD.gn b/chromium/components/search_engines/BUILD.gn index 0f86736014a..0fc603c1f21 100644 --- a/chromium/components/search_engines/BUILD.gn +++ b/chromium/components/search_engines/BUILD.gn @@ -17,8 +17,6 @@ static_library("search_engines") { "keyword_table.h", "keyword_web_data_service.cc", "keyword_web_data_service.h", - "search_engine_data_type_controller.cc", - "search_engine_data_type_controller.h", "search_engines_pref_names.cc", "search_engines_pref_names.h", "search_engines_switches.cc", @@ -122,7 +120,6 @@ source_set("unit_tests") { sources = [ "default_search_manager_unittest.cc", "keyword_table_unittest.cc", - "search_engine_data_type_controller_unittest.cc", "search_host_to_urls_map_unittest.cc", "template_url_data_unittest.cc", "template_url_prepopulate_data_unittest.cc", @@ -139,8 +136,7 @@ source_set("unit_tests") { "//components/google/core/browser", "//components/pref_registry:pref_registry", "//components/prefs", - "//components/sync:test_support_driver", - "//components/sync:test_support_model", + "//components/sync:test_support", "//components/sync_preferences:test_support", "//components/webdata/common", "//net:net", diff --git a/chromium/components/search_engines/prepopulated_engines.json b/chromium/components/search_engines/prepopulated_engines.json index c5a79364269..2375b8711c6 100644 --- a/chromium/components/search_engines/prepopulated_engines.json +++ b/chromium/components/search_engines/prepopulated_engines.json @@ -28,7 +28,7 @@ // Increment this if you change the data in ways that mean users with // existing data should get a new version. Otherwise, existing data may // continue to be used and updates made here will not always appear. - "kCurrentDataVersion": 113 + "kCurrentDataVersion": 114 }, // The following engines are included in country lists and are added to the @@ -113,7 +113,6 @@ "search_url": "{google:baseURL}search?q={searchTerms}&{google:RLZ}{google:originalQueryForSuggestion}{google:assistedQueryStats}{google:searchFieldtrialParameter}{google:iOSSearchLanguage}{google:searchClient}{google:sourceId}{google:contextualSearchVersion}ie={inputEncoding}", "suggest_url": "{google:baseSuggestURL}search?{google:searchFieldtrialParameter}client={google:suggestClient}&gs_ri={google:suggestRid}&xssi=t&q={searchTerms}&{google:inputType}{google:cursorPosition}{google:currentPageUrl}{google:pageClassification}{google:searchVersion}{google:sessionToken}{google:prefetchQuery}sugkey={google:suggestAPIKeyParameter}", "image_url": "{google:baseURL}searchbyimage/upload", - "new_tab_url": "{google:baseURL}_/chrome/newtab?{google:RLZ}ie={inputEncoding}", "contextual_search_url": "{google:baseURL}_/contextualsearch?{google:contextualSearchVersion}{google:contextualSearchContextData}", "image_url_post_params": "encoded_image={google:imageThumbnail},image_url={google:imageURL},sbisrc={google:imageSearchSource},original_width={google:imageOriginalWidth},original_height={google:imageOriginalHeight}", "alternate_urls": [ diff --git a/chromium/components/search_engines/search_engine_data_type_controller.cc b/chromium/components/search_engines/search_engine_data_type_controller.cc deleted file mode 100644 index d1627a535bc..00000000000 --- a/chromium/components/search_engines/search_engine_data_type_controller.cc +++ /dev/null @@ -1,64 +0,0 @@ -// Copyright 2012 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "components/search_engines/search_engine_data_type_controller.h" - -#include "base/bind.h" -#include "base/threading/thread_task_runner_handle.h" - -namespace browser_sync { - -SearchEngineDataTypeController::SearchEngineDataTypeController( - const base::Closure& dump_stack, - syncer::SyncService* sync_service, - syncer::SyncClient* sync_client, - TemplateURLService* template_url_service) - : AsyncDirectoryTypeController(syncer::SEARCH_ENGINES, - dump_stack, - sync_service, - sync_client, - syncer::GROUP_UI, - base::ThreadTaskRunnerHandle::Get()), - template_url_service_(template_url_service) {} - -TemplateURLService::Subscription* -SearchEngineDataTypeController::GetSubscriptionForTesting() { - return template_url_subscription_.get(); -} - -SearchEngineDataTypeController::~SearchEngineDataTypeController() {} - -// We want to start the TemplateURLService before we begin associating. -bool SearchEngineDataTypeController::StartModels() { - DCHECK(CalledOnValidThread()); - // If the TemplateURLService is loaded, continue with association. We force - // a load here to prevent the rest of Sync from waiting on - // TemplateURLService's lazy load. - DCHECK(template_url_service_); - template_url_service_->Load(); - if (template_url_service_->loaded()) { - return true; // Continue to Associate(). - } - - // Register a callback and continue when the TemplateURLService is loaded. - template_url_subscription_ = template_url_service_->RegisterOnLoadedCallback( - base::Bind(&SearchEngineDataTypeController::OnTemplateURLServiceLoaded, - base::AsWeakPtr(this))); - - return false; // Don't continue Start. -} - -void SearchEngineDataTypeController::StopModels() { - DCHECK(CalledOnValidThread()); - template_url_subscription_.reset(); -} - -void SearchEngineDataTypeController::OnTemplateURLServiceLoaded() { - DCHECK(CalledOnValidThread()); - DCHECK_EQ(MODEL_STARTING, state()); - template_url_subscription_.reset(); - OnModelLoaded(); -} - -} // namespace browser_sync diff --git a/chromium/components/search_engines/search_engine_data_type_controller.h b/chromium/components/search_engines/search_engine_data_type_controller.h deleted file mode 100644 index 7c5dc73393a..00000000000 --- a/chromium/components/search_engines/search_engine_data_type_controller.h +++ /dev/null @@ -1,55 +0,0 @@ -// Copyright 2012 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef COMPONENTS_SEARCH_ENGINES_SEARCH_ENGINE_DATA_TYPE_CONTROLLER_H__ -#define COMPONENTS_SEARCH_ENGINES_SEARCH_ENGINE_DATA_TYPE_CONTROLLER_H__ - -#include <memory> -#include <string> - -#include "base/macros.h" -#include "components/search_engines/template_url_service.h" -#include "components/sync/driver/async_directory_type_controller.h" - -namespace syncer { -class SyncClient; -class SyncService; -} // namespace syncer - -namespace browser_sync { - -// Controller for the SEARCH_ENGINES sync data type. This class tells sync -// how to load the model for this data type, and the superclasses manage -// controlling the rest of the state of the datatype with regards to sync. -class SearchEngineDataTypeController - : public syncer::AsyncDirectoryTypeController { - public: - // |dump_stack| is called when an unrecoverable error occurs. - SearchEngineDataTypeController(const base::Closure& dump_stack, - syncer::SyncService* sync_service, - syncer::SyncClient* sync_client, - TemplateURLService* template_url_service); - ~SearchEngineDataTypeController() override; - - TemplateURLService::Subscription* GetSubscriptionForTesting(); - - private: - // AsyncDirectoryTypeController: - bool StartModels() override; - void StopModels() override; - - void OnTemplateURLServiceLoaded(); - - // A pointer to the template URL service that this data type will use. - TemplateURLService* template_url_service_; - - // A subscription to the OnLoadedCallback so it can be cleared if necessary. - std::unique_ptr<TemplateURLService::Subscription> template_url_subscription_; - - DISALLOW_COPY_AND_ASSIGN(SearchEngineDataTypeController); -}; - -} // namespace browser_sync - -#endif // COMPONENTS_SEARCH_ENGINES_SEARCH_ENGINE_DATA_TYPE_CONTROLLER_H__ diff --git a/chromium/components/search_engines/search_engine_data_type_controller_unittest.cc b/chromium/components/search_engines/search_engine_data_type_controller_unittest.cc deleted file mode 100644 index 52f9c3e3f49..00000000000 --- a/chromium/components/search_engines/search_engine_data_type_controller_unittest.cc +++ /dev/null @@ -1,184 +0,0 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "components/search_engines/search_engine_data_type_controller.h" - -#include <memory> - -#include "base/bind.h" -#include "base/bind_helpers.h" -#include "base/callback.h" -#include "base/memory/ptr_util.h" -#include "base/run_loop.h" -#include "base/single_thread_task_runner.h" -#include "base/test/scoped_task_environment.h" -#include "base/threading/thread_task_runner_handle.h" -#include "components/search_engines/template_url_service.h" -#include "components/sync/driver/configure_context.h" -#include "components/sync/driver/data_type_controller_mock.h" -#include "components/sync/driver/fake_generic_change_processor.h" -#include "components/sync/driver/fake_sync_service.h" -#include "components/sync/driver/sync_client_mock.h" -#include "components/sync/model/fake_syncable_service.h" -#include "testing/gtest/include/gtest/gtest.h" - -using testing::_; -using testing::DoAll; -using testing::InvokeWithoutArgs; -using testing::Return; -using testing::SetArgPointee; - -namespace browser_sync { -namespace { - -class SyncSearchEngineDataTypeControllerTest : public testing::Test { - public: - SyncSearchEngineDataTypeControllerTest() - : template_url_service_(nullptr, 0), - search_engine_dtc_(base::RepeatingClosure(), - &sync_service_, - &sync_client_, - &template_url_service_) { - // Disallow the TemplateURLService from loading until - // PreloadTemplateURLService() is called . - template_url_service_.set_disable_load(true); - - ON_CALL(sync_client_, GetSyncableServiceForType(syncer::SEARCH_ENGINES)) - .WillByDefault(testing::Return(syncable_service_.AsWeakPtr())); - } - - void TearDown() override { - // Must be done before we pump the loop. - syncable_service_.StopSyncing(syncer::SEARCH_ENGINES); - } - - protected: - void PreloadTemplateURLService() { - template_url_service_.set_disable_load(false); - template_url_service_.Load(); - } - - void SetStartExpectations() { - search_engine_dtc_.SetGenericChangeProcessorFactoryForTest( - std::make_unique<syncer::FakeGenericChangeProcessorFactory>( - std::make_unique<syncer::FakeGenericChangeProcessor>( - syncer::SEARCH_ENGINES))); - EXPECT_CALL(model_load_callback_, Run(_, _)); - } - - void Start() { - search_engine_dtc_.LoadModels( - syncer::ConfigureContext(), - base::Bind(&syncer::ModelLoadCallbackMock::Run, - base::Unretained(&model_load_callback_))); - search_engine_dtc_.StartAssociating(base::Bind( - &syncer::StartCallbackMock::Run, base::Unretained(&start_callback_))); - base::RunLoop().RunUntilIdle(); - } - - base::test::ScopedTaskEnvironment task_environment_; - syncer::FakeSyncService sync_service_; - TemplateURLService template_url_service_; - syncer::FakeSyncableService syncable_service_; - testing::NiceMock<syncer::SyncClientMock> sync_client_; - syncer::StartCallbackMock start_callback_; - syncer::ModelLoadCallbackMock model_load_callback_; - SearchEngineDataTypeController search_engine_dtc_; -}; - -TEST_F(SyncSearchEngineDataTypeControllerTest, StartURLServiceReady) { - SetStartExpectations(); - // We want to start ready. - PreloadTemplateURLService(); - EXPECT_CALL(start_callback_, Run(syncer::DataTypeController::OK, _, _)); - - EXPECT_EQ(syncer::DataTypeController::NOT_RUNNING, - search_engine_dtc_.state()); - EXPECT_FALSE(syncable_service_.syncing()); - Start(); - EXPECT_EQ(syncer::DataTypeController::RUNNING, search_engine_dtc_.state()); - EXPECT_TRUE(syncable_service_.syncing()); -} - -TEST_F(SyncSearchEngineDataTypeControllerTest, StartURLServiceNotReady) { - EXPECT_CALL(model_load_callback_, Run(_, _)); - EXPECT_FALSE(syncable_service_.syncing()); - search_engine_dtc_.LoadModels( - syncer::ConfigureContext(), - base::Bind(&syncer::ModelLoadCallbackMock::Run, - base::Unretained(&model_load_callback_))); - EXPECT_TRUE(search_engine_dtc_.GetSubscriptionForTesting()); - EXPECT_EQ(syncer::DataTypeController::MODEL_STARTING, - search_engine_dtc_.state()); - EXPECT_FALSE(syncable_service_.syncing()); - - // Send the notification that the TemplateURLService has started. - PreloadTemplateURLService(); - EXPECT_EQ(nullptr, search_engine_dtc_.GetSubscriptionForTesting()); - EXPECT_EQ(syncer::DataTypeController::MODEL_LOADED, - search_engine_dtc_.state()); - - // Wait until WebDB is loaded before we shut it down. - base::RunLoop().RunUntilIdle(); -} - -TEST_F(SyncSearchEngineDataTypeControllerTest, StartAssociationFailed) { - SetStartExpectations(); - PreloadTemplateURLService(); - EXPECT_CALL(start_callback_, - Run(syncer::DataTypeController::ASSOCIATION_FAILED, _, _)); - syncable_service_.set_merge_data_and_start_syncing_error( - syncer::SyncError(FROM_HERE, - syncer::SyncError::DATATYPE_ERROR, - "Error", - syncer::SEARCH_ENGINES)); - - Start(); - EXPECT_EQ(syncer::DataTypeController::FAILED, search_engine_dtc_.state()); - EXPECT_FALSE(syncable_service_.syncing()); - search_engine_dtc_.Stop(syncer::STOP_SYNC); - EXPECT_EQ(syncer::DataTypeController::NOT_RUNNING, - search_engine_dtc_.state()); - EXPECT_FALSE(syncable_service_.syncing()); -} - -TEST_F(SyncSearchEngineDataTypeControllerTest, Stop) { - SetStartExpectations(); - PreloadTemplateURLService(); - EXPECT_CALL(start_callback_, Run(syncer::DataTypeController::OK, _, _)); - - EXPECT_EQ(syncer::DataTypeController::NOT_RUNNING, - search_engine_dtc_.state()); - EXPECT_FALSE(syncable_service_.syncing()); - Start(); - EXPECT_EQ(syncer::DataTypeController::RUNNING, search_engine_dtc_.state()); - EXPECT_TRUE(syncable_service_.syncing()); - search_engine_dtc_.Stop(syncer::STOP_SYNC); - EXPECT_EQ(syncer::DataTypeController::NOT_RUNNING, - search_engine_dtc_.state()); - // AsyncDirectoryTypeController::Stop posts call to StopLocalService to model - // thread. We run message loop for this call to take effect. - base::RunLoop().RunUntilIdle(); - EXPECT_FALSE(syncable_service_.syncing()); -} - -TEST_F(SyncSearchEngineDataTypeControllerTest, StopBeforeLoaded) { - EXPECT_FALSE(syncable_service_.syncing()); - search_engine_dtc_.LoadModels( - syncer::ConfigureContext(), - base::Bind(&syncer::ModelLoadCallbackMock::Run, - base::Unretained(&model_load_callback_))); - EXPECT_TRUE(search_engine_dtc_.GetSubscriptionForTesting()); - EXPECT_EQ(syncer::DataTypeController::MODEL_STARTING, - search_engine_dtc_.state()); - EXPECT_FALSE(syncable_service_.syncing()); - search_engine_dtc_.Stop(syncer::STOP_SYNC); - EXPECT_EQ(nullptr, search_engine_dtc_.GetSubscriptionForTesting()); - EXPECT_EQ(syncer::DataTypeController::NOT_RUNNING, - search_engine_dtc_.state()); - EXPECT_FALSE(syncable_service_.syncing()); -} - -} // namespace -} // namespace browser_sync diff --git a/chromium/components/search_engines/template_url_prepopulate_data_unittest.cc b/chromium/components/search_engines/template_url_prepopulate_data_unittest.cc index 98cb1cc4966..bc5eacde399 100644 --- a/chromium/components/search_engines/template_url_prepopulate_data_unittest.cc +++ b/chromium/components/search_engines/template_url_prepopulate_data_unittest.cc @@ -243,7 +243,6 @@ TEST_F(TemplateURLPrepopulateDataTest, ClearProvidersFromPrefs) { EXPECT_EQ(ASCIIToUTF16("Google"), t_urls[default_index]->short_name()); EXPECT_FALSE(t_urls[default_index]->suggestions_url.empty()); EXPECT_FALSE(t_urls[default_index]->image_url.empty()); - EXPECT_FALSE(t_urls[default_index]->new_tab_url.empty()); EXPECT_FALSE(t_urls[default_index]->contextual_search_url.empty()); EXPECT_FALSE(t_urls[default_index]->image_url_post_params.empty()); EXPECT_EQ(SEARCH_ENGINE_GOOGLE, @@ -278,7 +277,6 @@ TEST_F(TemplateURLPrepopulateDataTest, ProvidersFromPrepopulated) { EXPECT_EQ(ASCIIToUTF16("Google"), t_urls[default_index]->short_name()); EXPECT_FALSE(t_urls[default_index]->suggestions_url.empty()); EXPECT_FALSE(t_urls[default_index]->image_url.empty()); - EXPECT_FALSE(t_urls[default_index]->new_tab_url.empty()); EXPECT_FALSE(t_urls[default_index]->contextual_search_url.empty()); EXPECT_FALSE(t_urls[default_index]->image_url_post_params.empty()); // Expect at least 2 alternate_urls. diff --git a/chromium/components/search_engines/template_url_service.h b/chromium/components/search_engines/template_url_service.h index fbd54db267c..879aaeb9657 100644 --- a/chromium/components/search_engines/template_url_service.h +++ b/chromium/components/search_engines/template_url_service.h @@ -760,7 +760,7 @@ class TemplateURLService : public WebDataServiceConsumer, OwnedTemplateURLVector template_urls_; - base::ObserverList<TemplateURLServiceObserver>::Unchecked model_observers_; + base::ObserverList<TemplateURLServiceObserver> model_observers_; // Maps from host to set of TemplateURLs whose search url host is host. std::unique_ptr<SearchHostToURLsMap> provider_map_ = diff --git a/chromium/components/search_engines/template_url_service_observer.h b/chromium/components/search_engines/template_url_service_observer.h index eb3ba6667d0..2f7b41fff62 100644 --- a/chromium/components/search_engines/template_url_service_observer.h +++ b/chromium/components/search_engines/template_url_service_observer.h @@ -5,9 +5,11 @@ #ifndef COMPONENTS_SEARCH_ENGINES_TEMPLATE_URL_SERVICE_OBSERVER_H_ #define COMPONENTS_SEARCH_ENGINES_TEMPLATE_URL_SERVICE_OBSERVER_H_ +#include "base/observer_list_types.h" + // TemplateURLServiceObserver is notified whenever the set of TemplateURLs // are modified. -class TemplateURLServiceObserver { +class TemplateURLServiceObserver : public base::CheckedObserver { public: // Notification that the template url model has changed in some way. virtual void OnTemplateURLServiceChanged() = 0; @@ -18,7 +20,7 @@ class TemplateURLServiceObserver { virtual void OnTemplateURLServiceShuttingDown() {} protected: - virtual ~TemplateURLServiceObserver() {} + ~TemplateURLServiceObserver() override {} }; #endif // COMPONENTS_SEARCH_ENGINES_TEMPLATE_URL_SERVICE_OBSERVER_H_ |