From 2ddb2d3e14eef3de7dbd0cef553d669b9ac2361c Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Mon, 9 May 2016 14:22:11 +0200 Subject: BASELINE: Update Chromium to 51.0.2704.41 Also adds in all smaller components by reversing logic for exclusion. Change-Id: Ibf90b506e7da088ea2f65dcf23f2b0992c504422 Reviewed-by: Joerg Bornemann --- chromium/components/webdata_services/BUILD.gn | 39 ++++++ chromium/components/webdata_services/DEPS | 11 ++ chromium/components/webdata_services/OWNERS | 4 + .../webdata_services/web_data_service_test_util.cc | 39 ++++++ .../webdata_services/web_data_service_test_util.h | 48 +++++++ .../webdata_services/web_data_service_wrapper.cc | 149 +++++++++++++++++++++ .../webdata_services/web_data_service_wrapper.h | 95 +++++++++++++ 7 files changed, 385 insertions(+) create mode 100644 chromium/components/webdata_services/BUILD.gn create mode 100644 chromium/components/webdata_services/DEPS create mode 100644 chromium/components/webdata_services/OWNERS create mode 100644 chromium/components/webdata_services/web_data_service_test_util.cc create mode 100644 chromium/components/webdata_services/web_data_service_test_util.h create mode 100644 chromium/components/webdata_services/web_data_service_wrapper.cc create mode 100644 chromium/components/webdata_services/web_data_service_wrapper.h (limited to 'chromium/components/webdata_services') diff --git a/chromium/components/webdata_services/BUILD.gn b/chromium/components/webdata_services/BUILD.gn new file mode 100644 index 00000000000..8626a4c089e --- /dev/null +++ b/chromium/components/webdata_services/BUILD.gn @@ -0,0 +1,39 @@ +# Copyright 2014 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. + +static_library("webdata_services") { + output_name = "webdata_services" + + sources = [ + "web_data_service_wrapper.cc", + "web_data_service_wrapper.h", + ] + + deps = [ + "//base", + "//components/autofill/core/browser", + "//components/keyed_service/core", + "//components/password_manager/core/browser", + "//components/search_engines", + "//components/signin/core/browser", + "//components/webdata/common", + "//sql", + "//sync", + ] +} + +source_set("test_support") { + testonly = true + sources = [ + "web_data_service_test_util.cc", + "web_data_service_test_util.h", + ] + + deps = [ + ":webdata_services", + "//base", + "//components/autofill/core/browser", + "//components/signin/core/browser", + ] +} diff --git a/chromium/components/webdata_services/DEPS b/chromium/components/webdata_services/DEPS new file mode 100644 index 00000000000..fd192716922 --- /dev/null +++ b/chromium/components/webdata_services/DEPS @@ -0,0 +1,11 @@ +include_rules = [ + "+components/autofill/core/browser/webdata", + "+components/keyed_service/core", + "+components/password_manager/core/browser/webdata", + "+components/search_engines/keyword_table.h", + "+components/search_engines/keyword_web_data_service.h", + "+components/signin/core/browser/webdata", + "+components/webdata/common", + "+sql", + "+sync", +] diff --git a/chromium/components/webdata_services/OWNERS b/chromium/components/webdata_services/OWNERS new file mode 100644 index 00000000000..dbe16c9b519 --- /dev/null +++ b/chromium/components/webdata_services/OWNERS @@ -0,0 +1,4 @@ +pkasting@chromium.org + +# For sqlite stuff: +shess@chromium.org diff --git a/chromium/components/webdata_services/web_data_service_test_util.cc b/chromium/components/webdata_services/web_data_service_test_util.cc new file mode 100644 index 00000000000..e013f323fca --- /dev/null +++ b/chromium/components/webdata_services/web_data_service_test_util.cc @@ -0,0 +1,39 @@ +// Copyright 2013 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/webdata_services/web_data_service_test_util.h" + +#include "components/autofill/core/browser/webdata/autofill_webdata_service.h" + +using autofill::AutofillWebDataService; + +MockWebDataServiceWrapperBase::MockWebDataServiceWrapperBase() { +} + +MockWebDataServiceWrapperBase::~MockWebDataServiceWrapperBase() { +} + +void MockWebDataServiceWrapperBase::Shutdown() { +} + +// TODO(caitkp): This won't scale well. As we get more WebData subclasses, we +// will probably need a better way to create these mocks rather than passing +// all the webdatas in. +MockWebDataServiceWrapper::MockWebDataServiceWrapper( + scoped_refptr fake_autofill, + scoped_refptr fake_token) + : fake_autofill_web_data_(fake_autofill), fake_token_web_data_(fake_token) { +} + +MockWebDataServiceWrapper::~MockWebDataServiceWrapper() { +} + +scoped_refptr +MockWebDataServiceWrapper::GetAutofillWebData() { + return fake_autofill_web_data_; +} + +scoped_refptr MockWebDataServiceWrapper::GetTokenWebData() { + return fake_token_web_data_; +} diff --git a/chromium/components/webdata_services/web_data_service_test_util.h b/chromium/components/webdata_services/web_data_service_test_util.h new file mode 100644 index 00000000000..95f801289c3 --- /dev/null +++ b/chromium/components/webdata_services/web_data_service_test_util.h @@ -0,0 +1,48 @@ +// Copyright (c) 2011 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_WEBDATA_SERVICES_WEB_DATA_SERVICE_TEST_UTIL_H__ +#define COMPONENTS_WEBDATA_SERVICES_WEB_DATA_SERVICE_TEST_UTIL_H__ + +#include "base/macros.h" +#include "base/message_loop/message_loop.h" +#include "components/signin/core/browser/webdata/token_web_data.h" +#include "components/webdata_services/web_data_service_wrapper.h" + +// Base class for mocks of WebDataService, that does nothing in +// Shutdown(). +class MockWebDataServiceWrapperBase : public WebDataServiceWrapper { + public: + MockWebDataServiceWrapperBase(); + ~MockWebDataServiceWrapperBase() override; + + void Shutdown() override; + + private: + DISALLOW_COPY_AND_ASSIGN(MockWebDataServiceWrapperBase); +}; + +// Pass your fake WebDataService in the constructor and this will +// serve it up via GetWebData(). +class MockWebDataServiceWrapper : public MockWebDataServiceWrapperBase { + public: + MockWebDataServiceWrapper( + scoped_refptr fake_autofill, + scoped_refptr fake_token); + + ~MockWebDataServiceWrapper() override; + + scoped_refptr GetAutofillWebData() override; + + scoped_refptr GetTokenWebData() override; + + protected: + scoped_refptr fake_autofill_web_data_; + scoped_refptr fake_token_web_data_; + + private: + DISALLOW_COPY_AND_ASSIGN(MockWebDataServiceWrapper); +}; + +#endif // COMPONENTS_WEBDATA_SERVICES_WEB_DATA_SERVICE_TEST_UTIL_H__ diff --git a/chromium/components/webdata_services/web_data_service_wrapper.cc b/chromium/components/webdata_services/web_data_service_wrapper.cc new file mode 100644 index 00000000000..398660f3f39 --- /dev/null +++ b/chromium/components/webdata_services/web_data_service_wrapper.cc @@ -0,0 +1,149 @@ +// Copyright 2014 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/webdata_services/web_data_service_wrapper.h" + +#include "base/bind.h" +#include "base/callback.h" +#include "base/files/file_path.h" +#include "base/single_thread_task_runner.h" +#include "build/build_config.h" +#include "components/autofill/core/browser/webdata/autocomplete_syncable_service.h" +#include "components/autofill/core/browser/webdata/autofill_profile_syncable_service.h" +#include "components/autofill/core/browser/webdata/autofill_table.h" +#include "components/autofill/core/browser/webdata/autofill_wallet_metadata_syncable_service.h" +#include "components/autofill/core/browser/webdata/autofill_wallet_syncable_service.h" +#include "components/autofill/core/browser/webdata/autofill_webdata_service.h" +#include "components/password_manager/core/browser/webdata/logins_table.h" +#include "components/search_engines/keyword_table.h" +#include "components/search_engines/keyword_web_data_service.h" +#include "components/signin/core/browser/webdata/token_service_table.h" +#include "components/signin/core/browser/webdata/token_web_data.h" +#include "components/webdata/common/web_database_service.h" +#include "components/webdata/common/webdata_constants.h" + +#if defined(OS_WIN) +#include "components/password_manager/core/browser/webdata/password_web_data_service_win.h" +#endif + +namespace { + +void InitSyncableServicesOnDBThread( + scoped_refptr db_thread, + const syncer::SyncableService::StartSyncFlare& sync_flare, + const scoped_refptr& autofill_web_data, + const base::FilePath& context_path, + const std::string& app_locale, + autofill::AutofillWebDataBackend* autofill_backend) { + DCHECK(db_thread->BelongsToCurrentThread()); + + // Currently only Autocomplete and Autofill profiles use the new Sync API, but + // all the database data should migrate to this API over time. + autofill::AutocompleteSyncableService::CreateForWebDataServiceAndBackend( + autofill_web_data.get(), autofill_backend); + autofill::AutocompleteSyncableService::FromWebDataService( + autofill_web_data.get())->InjectStartSyncFlare(sync_flare); + + autofill::AutofillProfileSyncableService::CreateForWebDataServiceAndBackend( + autofill_web_data.get(), autofill_backend, app_locale); + autofill::AutofillWalletSyncableService::CreateForWebDataServiceAndBackend( + autofill_web_data.get(), autofill_backend, app_locale); + autofill::AutofillWalletMetadataSyncableService:: + CreateForWebDataServiceAndBackend(autofill_web_data.get(), + autofill_backend, app_locale); + + autofill::AutofillProfileSyncableService::FromWebDataService( + autofill_web_data.get())->InjectStartSyncFlare(sync_flare); + autofill::AutofillWalletSyncableService::FromWebDataService( + autofill_web_data.get())->InjectStartSyncFlare(sync_flare); +} + +} // namespace + +WebDataServiceWrapper::WebDataServiceWrapper() { +} + +WebDataServiceWrapper::WebDataServiceWrapper( + const base::FilePath& context_path, + const std::string& application_locale, + const scoped_refptr& ui_thread, + const scoped_refptr& db_thread, + const syncer::SyncableService::StartSyncFlare& flare, + const ShowErrorCallback& show_error_callback) { + base::FilePath path = context_path.Append(kWebDataFilename); + web_database_ = new WebDatabaseService(path, ui_thread, db_thread); + + // All tables objects that participate in managing the database must + // be added here. + web_database_->AddTable(make_scoped_ptr(new autofill::AutofillTable)); + web_database_->AddTable(make_scoped_ptr(new KeywordTable)); + // TODO(mdm): We only really need the LoginsTable on Windows for IE7 password + // access, but for now, we still create it on all platforms since it deletes + // the old logins table. We can remove this after a while, e.g. in M22 or so. + web_database_->AddTable(make_scoped_ptr(new LoginsTable)); + web_database_->AddTable(make_scoped_ptr(new TokenServiceTable)); + web_database_->LoadDatabase(); + + autofill_web_data_ = new autofill::AutofillWebDataService( + web_database_, ui_thread, db_thread, + base::Bind(show_error_callback, ERROR_LOADING_AUTOFILL)); + autofill_web_data_->Init(); + + keyword_web_data_ = new KeywordWebDataService( + web_database_, ui_thread, + base::Bind(show_error_callback, ERROR_LOADING_KEYWORD)); + keyword_web_data_->Init(); + + token_web_data_ = new TokenWebData( + web_database_, ui_thread, db_thread, + base::Bind(show_error_callback, ERROR_LOADING_TOKEN)); + token_web_data_->Init(); + +#if defined(OS_WIN) + password_web_data_ = new PasswordWebDataService( + web_database_, ui_thread, + base::Bind(show_error_callback, ERROR_LOADING_PASSWORD)); + password_web_data_->Init(); +#endif + + autofill_web_data_->GetAutofillBackend( + base::Bind(&InitSyncableServicesOnDBThread, db_thread, flare, + autofill_web_data_, context_path, application_locale)); +} + +WebDataServiceWrapper::~WebDataServiceWrapper() { +} + +void WebDataServiceWrapper::Shutdown() { + autofill_web_data_->ShutdownOnUIThread(); + keyword_web_data_->ShutdownOnUIThread(); + token_web_data_->ShutdownOnUIThread(); + +#if defined(OS_WIN) + password_web_data_->ShutdownOnUIThread(); +#endif + + web_database_->ShutdownDatabase(); +} + +scoped_refptr +WebDataServiceWrapper::GetAutofillWebData() { + return autofill_web_data_.get(); +} + +scoped_refptr +WebDataServiceWrapper::GetKeywordWebData() { + return keyword_web_data_.get(); +} + +scoped_refptr WebDataServiceWrapper::GetTokenWebData() { + return token_web_data_.get(); +} + +#if defined(OS_WIN) +scoped_refptr +WebDataServiceWrapper::GetPasswordWebData() { + return password_web_data_.get(); +} +#endif diff --git a/chromium/components/webdata_services/web_data_service_wrapper.h b/chromium/components/webdata_services/web_data_service_wrapper.h new file mode 100644 index 00000000000..ecc8c33d3a3 --- /dev/null +++ b/chromium/components/webdata_services/web_data_service_wrapper.h @@ -0,0 +1,95 @@ +// Copyright 2014 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_WEBDATA_SERVICES_WEB_DATA_SERVICE_WRAPPER_H_ +#define COMPONENTS_WEBDATA_SERVICES_WEB_DATA_SERVICE_WRAPPER_H_ + +#include + +#include "base/callback_forward.h" +#include "base/macros.h" +#include "base/memory/ref_counted.h" +#include "build/build_config.h" +#include "components/keyed_service/core/keyed_service.h" +#include "sql/init_status.h" +#include "sync/api/syncable_service.h" + +class KeywordWebDataService; +class TokenWebData; +class WebDatabaseService; + +#if defined(OS_WIN) +class PasswordWebDataService; +#endif + +namespace autofill { +class AutofillWebDataBackend; +class AutofillWebDataService; +} // namespace autofill + +namespace base { +class FilePath; +class SingleThreadTaskRunner; +} // namespace base + +// WebDataServiceWrapper is a KeyedService that owns multiple WebDataServices +// so that they can be associated with a context. +class WebDataServiceWrapper : public KeyedService { + public: + // ErrorType indicates which service encountered an error loading its data. + enum ErrorType { + ERROR_LOADING_AUTOFILL, + ERROR_LOADING_KEYWORD, + ERROR_LOADING_TOKEN, + ERROR_LOADING_PASSWORD, + }; + + // Shows an error message if a loading error occurs. + using ShowErrorCallback = void (*)(ErrorType, sql::InitStatus); + + // Constructor for WebDataServiceWrapper that initializes the different + // WebDataServices and starts the synchronization services using |flare|. + // Since |flare| will be copied and called multiple times, it cannot bind + // values using base::Owned nor base::Passed; it should only bind simple or + // refcounted types. + WebDataServiceWrapper( + const base::FilePath& context_path, + const std::string& application_locale, + const scoped_refptr& ui_thread, + const scoped_refptr& db_thread, + const syncer::SyncableService::StartSyncFlare& flare, + const ShowErrorCallback& show_error_callback); + ~WebDataServiceWrapper() override; + + // KeyedService: + void Shutdown() override; + + // Create the various types of service instances. These methods are virtual + // for testing purpose. + virtual scoped_refptr GetAutofillWebData(); + virtual scoped_refptr GetKeywordWebData(); + virtual scoped_refptr GetTokenWebData(); +#if defined(OS_WIN) + virtual scoped_refptr GetPasswordWebData(); +#endif + + protected: + // For testing. + WebDataServiceWrapper(); + + private: + scoped_refptr web_database_; + + scoped_refptr autofill_web_data_; + scoped_refptr keyword_web_data_; + scoped_refptr token_web_data_; + +#if defined(OS_WIN) + scoped_refptr password_web_data_; +#endif + + DISALLOW_COPY_AND_ASSIGN(WebDataServiceWrapper); +}; + +#endif // COMPONENTS_WEBDATA_SERVICES_WEB_DATA_SERVICE_WRAPPER_H_ -- cgit v1.2.1