Commit bf95320e authored by Yuta Hijikata's avatar Yuta Hijikata Committed by Commit Bot

LaCrOS: Replace defined(OS_CHROMEOS) with BUILDFLAG(IS_CHROMEOS_ASH)

The change is mostly mechanical replacing defined(OS_CHROMEOS) with
BUILDFLAG(IS_CHROMEOS_ASH) and GN variable is_chromeos with is_ash
with some special cases (For those cases please refer to
http://go/lacros-macros).

The patch is made in preparation to switching lacros build from
target_os=linux to target_os=chromeos. This will prevent lacros from
changing behaviour after the switch.

Bug: 1052397
Change-Id: I5ec5132b286ab2f67e971abca49c72f9117870bd
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2494401
Commit-Queue: Yuta Hijikata <ythjkt@chromium.org>
Reviewed-by: default avatarMichael Ershov <miersh@google.com>
Reviewed-by: default avatarRyan Sleevi <rsleevi@chromium.org>
Cr-Commit-Position: refs/heads/master@{#826695}
parent 64418e4e
......@@ -2,6 +2,7 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
import("//build/config/chromeos/ui_mode.gni")
import("//build/config/crypto.gni")
import("//testing/test.gni")
......@@ -115,9 +116,10 @@ component("crypto") {
"nss_util.h",
"nss_util_internal.h",
]
deps += [ "//build:chromeos_buildflags" ]
}
if (is_chromeos) {
if (is_chromeos_ash) {
sources += [ "nss_util_chromeos.cc" ]
}
......@@ -178,7 +180,7 @@ source_set("test_support") {
]
}
if (is_chromeos) {
if (is_chromeos_ash) {
sources += [
"scoped_test_nss_chromeos_user.cc",
"scoped_test_nss_chromeos_user.h",
......
......@@ -27,6 +27,7 @@
#include "base/threading/scoped_blocking_call.h"
#include "base/threading/thread_restrictions.h"
#include "build/build_config.h"
#include "build/chromeos_buildflags.h"
#include "crypto/nss_crypto_module_delegate.h"
#include "crypto/nss_util_internal.h"
......@@ -34,13 +35,13 @@ namespace crypto {
namespace {
#if defined(OS_CHROMEOS)
#if BUILDFLAG(IS_CHROMEOS_ASH)
// Fake certificate authority database used for testing.
static const base::FilePath::CharType kReadOnlyCertDB[] =
FILE_PATH_LITERAL("/etc/fake_root_ca/nssdb");
#endif // defined(OS_CHROMEOS)
#endif // BUILDFLAG(IS_CHROMEOS_ASH)
#if !defined(OS_CHROMEOS)
#if !BUILDFLAG(IS_CHROMEOS_ASH)
base::FilePath GetDefaultConfigDirectory() {
base::FilePath dir;
base::PathService::Get(base::DIR_HOME, &dir);
......@@ -56,7 +57,7 @@ base::FilePath GetDefaultConfigDirectory() {
DVLOG(2) << "DefaultConfigDirectory: " << dir.value();
return dir;
}
#endif // !defined(OS_CHROMEOS)
#endif // !BUILDFLAG(IS_CHROMEOS_ASH)
// On non-Chrome OS platforms, return the default config directory. On Chrome OS
// test images, return a read-only directory with fake root CA certs (which are
......@@ -64,14 +65,14 @@ base::FilePath GetDefaultConfigDirectory() {
// code). On Chrome OS non-test images (where the read-only directory doesn't
// exist), return an empty path.
base::FilePath GetInitialConfigDirectory() {
#if defined(OS_CHROMEOS)
#if BUILDFLAG(IS_CHROMEOS_ASH)
base::FilePath database_dir = base::FilePath(kReadOnlyCertDB);
if (!base::PathExists(database_dir))
database_dir.clear();
return database_dir;
#else
return GetDefaultConfigDirectory();
#endif // defined(OS_CHROMEOS)
#endif // BUILDFLAG(IS_CHROMEOS_ASH)
}
// This callback for NSS forwards all requests to a caller-specified
......@@ -157,7 +158,7 @@ class NSSInitSingleton {
// Use "sql:" which can be shared by multiple processes safely.
std::string nss_config_dir =
base::StringPrintf("sql:%s", database_dir.value().c_str());
#if defined(OS_CHROMEOS)
#if BUILDFLAG(IS_CHROMEOS_ASH)
status = NSS_Init(nss_config_dir.c_str());
#else
status = NSS_InitReadWrite(nss_config_dir.c_str());
......
......@@ -11,6 +11,7 @@
#include "base/callback.h"
#include "base/compiler_specific.h"
#include "base/macros.h"
#include "build/chromeos_buildflags.h"
#include "crypto/crypto_export.h"
namespace base {
......@@ -35,7 +36,7 @@ CRYPTO_EXPORT void EnsureNSSInit();
// A sample version string is "3.12.3".
bool CheckNSSVersion(const char* version);
#if defined(OS_CHROMEOS)
#if BUILDFLAG(IS_CHROMEOS_ASH)
// Indicates that NSS should use the Chaps library so that we
// can access the TPM through NSS. InitializeTPMTokenAndSystemSlot and
// InitializeTPMForChromeOSUser must still be called to load the slots.
......
......@@ -12,6 +12,7 @@
#include "base/callback.h"
#include "base/compiler_specific.h"
#include "base/macros.h"
#include "build/chromeos_buildflags.h"
#include "crypto/crypto_export.h"
#include "crypto/scoped_nss_types.h"
......@@ -42,7 +43,7 @@ class CRYPTO_EXPORT AutoSECMODListReadLock {
DISALLOW_COPY_AND_ASSIGN(AutoSECMODListReadLock);
};
#if defined(OS_CHROMEOS)
#if BUILDFLAG(IS_CHROMEOS_ASH)
// Returns a reference to the system-wide TPM slot if it is loaded. If it is not
// loaded and |callback| is non-null, the |callback| will be run once the slot
// is loaded.
......@@ -124,7 +125,7 @@ CRYPTO_EXPORT void SetPrivateSoftwareSlotForChromeOSUserForTesting(
// Returns true if chaps is the module to which |slot| is attached.
CRYPTO_EXPORT bool IsSlotProvidedByChaps(PK11SlotInfo* slot);
#endif // defined(OS_CHROMEOS)
#endif // BUILDFLAG(IS_CHROMEOS_ASH)
// Loads the given module for this NSS session.
SECMODModule* LoadNSSModule(const char* name,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment