diff --git a/chrome/browser/chromeos/BUILD.gn b/chrome/browser/chromeos/BUILD.gn index 21826465462d4f..17539abeb48e19 100644 --- a/chrome/browser/chromeos/BUILD.gn +++ b/chrome/browser/chromeos/BUILD.gn @@ -111,6 +111,7 @@ source_set("chromeos") { "//chromeos/services/multidevice_setup/public/cpp:oobe_completion_tracker", "//chromeos/services/multidevice_setup/public/cpp:prefs", "//chromeos/services/secure_channel/public/cpp/client", + "//chromeos/tpm", "//components/arc", "//components/arc/common:struct_traits", "//components/arc/media_session", diff --git a/chrome/browser/ui/webui/chromeos/login/eula_screen_handler.h b/chrome/browser/ui/webui/chromeos/login/eula_screen_handler.h index e7dc2517322916..8e17b6978da9f0 100644 --- a/chrome/browser/ui/webui/chromeos/login/eula_screen_handler.h +++ b/chrome/browser/ui/webui/chromeos/login/eula_screen_handler.h @@ -10,7 +10,6 @@ #include "base/memory/ref_counted.h" #include "chrome/browser/chromeos/login/screens/eula_view.h" #include "chrome/browser/ui/webui/chromeos/login/base_screen_handler.h" -#include "chromeos/tpm/tpm_password_fetcher.h" #include "components/login/secure_module_util_chromeos.h" #include "content/public/browser/web_ui.h" @@ -25,9 +24,7 @@ class HelpAppLauncher; // WebUI implementation of EulaScreenView. It is used to interact // with the eula part of the JS page. -class EulaScreenHandler : public EulaView, - public BaseScreenHandler, - public TpmPasswordFetcherDelegate { +class EulaScreenHandler : public EulaView, public BaseScreenHandler { public: explicit EulaScreenHandler(CoreOobeView* core_oobe_view); ~EulaScreenHandler() override; diff --git a/chromeos/BUILD.gn b/chromeos/BUILD.gn index 20a2f232413042..c3512156080d4d 100644 --- a/chromeos/BUILD.gn +++ b/chromeos/BUILD.gn @@ -43,7 +43,6 @@ component("chromeos") { "//base/third_party/dynamic_annotations", "//chromeos/cryptohome", "//chromeos/dbus:authpolicy_proto", - "//chromeos/dbus:cryptohome_proto", "//chromeos/dbus:vm_applications_apps_proto", "//chromeos/login/auth", "//chromeos/login/login_state", @@ -148,12 +147,6 @@ component("chromeos") { "timezone/timezone_request.h", "timezone/timezone_resolver.cc", "timezone/timezone_resolver.h", - "tpm/tpm_password_fetcher.cc", - "tpm/tpm_password_fetcher.h", - "tpm/tpm_token_info_getter.cc", - "tpm/tpm_token_info_getter.h", - "tpm/tpm_token_loader.cc", - "tpm/tpm_token_loader.h", ] if (current_cpu == "arm" || current_cpu == "x86") { defines = [ "BINDER_IPC_32BIT" ] @@ -303,6 +296,7 @@ test("chromeos_unittests") { "//chromeos/network:unit_tests", "//chromeos/services:unit_tests", "//chromeos/settings:unit_tests", + "//chromeos/tpm:unit_tests", "//components/account_id", "//components/onc", "//components/policy:generated", @@ -350,7 +344,6 @@ test("chromeos_unittests") { "test/run_all_unittests.cc", "timezone/timezone_unittest.cc", "tools/variable_expander_unittest.cc", - "tpm/tpm_token_info_getter_unittest.cc", ] data = [ diff --git a/chromeos/tpm/BUILD.gn b/chromeos/tpm/BUILD.gn new file mode 100644 index 00000000000000..272e25076cd827 --- /dev/null +++ b/chromeos/tpm/BUILD.gn @@ -0,0 +1,44 @@ +# Copyright 2019 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. + +import("//testing/test.gni") + +assert(is_chromeos, "Non-Chrome-OS builds must not depend on //chromeos") + +component("tpm") { + defines = [ "IS_CHROMEOS_TPM_IMPL" ] + deps = [ + "//base", + "//chromeos/cryptohome", + "//chromeos/dbus", + "//chromeos/dbus:cryptohome_proto", + "//chromeos/login/login_state", + "//components/account_id", + "//crypto", + ] + sources = [ + "tpm_password_fetcher.cc", + "tpm_password_fetcher.h", + "tpm_token_info_getter.cc", + "tpm_token_info_getter.h", + "tpm_token_loader.cc", + "tpm_token_loader.h", + ] +} + +source_set("unit_tests") { + testonly = true + deps = [ + ":tpm", + "//base/test:test_support", + "//chromeos:chromeos_constants", + "//chromeos/cryptohome", + "//chromeos/dbus", + "//chromeos/dbus:cryptohome_proto", + "//testing/gtest", + ] + sources = [ + "tpm_token_info_getter_unittest.cc", + ] +} diff --git a/chromeos/tpm/DEPS b/chromeos/tpm/DEPS new file mode 100644 index 00000000000000..c2bdbe147f1673 --- /dev/null +++ b/chromeos/tpm/DEPS @@ -0,0 +1,11 @@ +noparent = True + +include_rules = [ + "+base", + "+crypto", + "+chromeos/cryptohome", + "+chromeos/login/login_state", + "+chromeos/dbus", + "+components/account_id", + "+testing", +] diff --git a/chromeos/tpm/tpm_password_fetcher.h b/chromeos/tpm/tpm_password_fetcher.h index b69d41b8bfe4a8..33db5d6da32f9a 100644 --- a/chromeos/tpm/tpm_password_fetcher.h +++ b/chromeos/tpm/tpm_password_fetcher.h @@ -7,23 +7,23 @@ #include +#include "base/component_export.h" #include "base/macros.h" #include "base/memory/weak_ptr.h" #include "base/optional.h" -#include "chromeos/chromeos_export.h" namespace chromeos { // Interface which TpmPasswordFetcher uses to notify that password has been // fetched. -class CHROMEOS_EXPORT TpmPasswordFetcherDelegate { +class COMPONENT_EXPORT(CHROMEOS_TPM) TpmPasswordFetcherDelegate { public: virtual ~TpmPasswordFetcherDelegate() {} virtual void OnPasswordFetched(const std::string& tpm_password) = 0; }; // Class for fetching TPM password from the Cryptohome. -class CHROMEOS_EXPORT TpmPasswordFetcher { +class COMPONENT_EXPORT(CHROMEOS_TPM) TpmPasswordFetcher { public: // Creates fetcher with the given delegate to be notified every time fetching // is done. diff --git a/chromeos/tpm/tpm_token_info_getter.h b/chromeos/tpm/tpm_token_info_getter.h index b9b63f83bc9ab5..a7163de7a6e4f4 100644 --- a/chromeos/tpm/tpm_token_info_getter.h +++ b/chromeos/tpm/tpm_token_info_getter.h @@ -9,12 +9,12 @@ #include #include "base/callback.h" +#include "base/component_export.h" #include "base/macros.h" #include "base/memory/ref_counted.h" #include "base/memory/weak_ptr.h" #include "base/optional.h" #include "base/time/time.h" -#include "chromeos/chromeos_export.h" #include "chromeos/dbus/cryptohome_client.h" #include "components/account_id/account_id.h" @@ -26,7 +26,7 @@ namespace chromeos { // Class for getting a user or the system TPM token info from cryptohome during // TPM token loading. -class CHROMEOS_EXPORT TPMTokenInfoGetter { +class COMPONENT_EXPORT(CHROMEOS_TPM) TPMTokenInfoGetter { public: using TpmTokenInfoCallback = base::OnceCallback token_info)>; diff --git a/chromeos/tpm/tpm_token_loader.h b/chromeos/tpm/tpm_token_loader.h index 146010ab33a18b..9bde6965cbe455 100644 --- a/chromeos/tpm/tpm_token_loader.h +++ b/chromeos/tpm/tpm_token_loader.h @@ -10,13 +10,13 @@ #include #include "base/callback_forward.h" +#include "base/component_export.h" #include "base/macros.h" #include "base/memory/ref_counted.h" #include "base/memory/weak_ptr.h" #include "base/observer_list.h" #include "base/optional.h" #include "base/threading/thread_checker.h" -#include "chromeos/chromeos_export.h" #include "chromeos/dbus/cryptohome_client.h" #include "chromeos/login/login_state/login_state.h" #include "chromeos/tpm/tpm_token_info_getter.h" @@ -34,7 +34,8 @@ namespace chromeos { // session, the observers are notified using |OnTPMTokenReady|. // Note: This currently initializes the token with the hard coded default id 0. // See CryptohomeClient::OnPkcs11GetTpmTokenInfo. -class CHROMEOS_EXPORT TPMTokenLoader : public LoginState::Observer { +class COMPONENT_EXPORT(CHROMEOS_TPM) TPMTokenLoader + : public LoginState::Observer { public: enum TPMTokenStatus { TPM_TOKEN_STATUS_UNDETERMINED,