Skip to content

Commit

Permalink
Make //chromeos/tpm a component
Browse files Browse the repository at this point in the history
//chromeos/tpm has DBus dependencies which means it needs to be
a separate component in order to remove DBus dependencies form
//chromeos.

For extracting explicit DEPS file:
TBR=sky@chromium.org

Bug: 863439
Change-Id: I40838f9d62a6aef329375ed782a1c22a6e7708d8
Reviewed-on: https://chromium-review.googlesource.com/c/1399305
Reviewed-by: Toni Baržić <tbarzic@chromium.org>
Commit-Queue: Steven Bennetts <stevenjb@chromium.org>
Cr-Commit-Position: refs/heads/master@{#620853}
  • Loading branch information
stevenjb authored and Commit Bot committed Jan 8, 2019
1 parent 39fa39d commit 94c4806
Show file tree
Hide file tree
Showing 8 changed files with 66 additions and 19 deletions.
1 change: 1 addition & 0 deletions chrome/browser/chromeos/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
5 changes: 1 addition & 4 deletions chrome/browser/ui/webui/chromeos/login/eula_screen_handler.h
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand All @@ -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;
Expand Down
9 changes: 1 addition & 8 deletions chromeos/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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" ]
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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 = [
Expand Down
44 changes: 44 additions & 0 deletions chromeos/tpm/BUILD.gn
Original file line number Diff line number Diff line change
@@ -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",
]
}
11 changes: 11 additions & 0 deletions chromeos/tpm/DEPS
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
noparent = True

include_rules = [
"+base",
"+crypto",
"+chromeos/cryptohome",
"+chromeos/login/login_state",
"+chromeos/dbus",
"+components/account_id",
"+testing",
]
6 changes: 3 additions & 3 deletions chromeos/tpm/tpm_password_fetcher.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,23 @@

#include <string>

#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.
Expand Down
4 changes: 2 additions & 2 deletions chromeos/tpm/tpm_token_info_getter.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@
#include <string>

#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"

Expand All @@ -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<void(
base::Optional<CryptohomeClient::TpmTokenInfo> token_info)>;
Expand Down
5 changes: 3 additions & 2 deletions chromeos/tpm/tpm_token_loader.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@
#include <vector>

#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"
Expand All @@ -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,
Expand Down

0 comments on commit 94c4806

Please sign in to comment.