Skip to content

Commit

Permalink
LaCrOS: Replace defined(OS_CHROMEOS) with BUILDFLAG(IS_CHROMEOS_ASH)
Browse files Browse the repository at this point in the history
The change is mostly mechanical replacing defined(OS_CHROMEOS) with
BUILDFLAG(IS_CHROMEOS_ASH) and GN variable is_chromeos with
is_chromeos_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: I7734434e2a8fd49509c54233751c29779893099c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2546666
Reviewed-by: Alan Cutter <alancutter@chromium.org>
Commit-Queue: Yuta Hijikata <ythjkt@chromium.org>
Cr-Commit-Position: refs/heads/master@{#829705}
  • Loading branch information
Yuta Hijikata authored and Commit Bot committed Nov 20, 2020
1 parent 5056bf1 commit b77fc4b
Show file tree
Hide file tree
Showing 29 changed files with 167 additions and 129 deletions.
11 changes: 8 additions & 3 deletions chrome/browser/web_applications/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
# 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")

group("web_app_group") {
public_configs = [ "//build/config/compiler:wexit_time_destructors" ]
}
Expand Down Expand Up @@ -74,6 +76,7 @@ source_set("web_applications") {
deps = [
":web_app_group",
"//chrome/browser:browser_process",
"//build:chromeos_buildflags",
"//chrome/browser/web_applications/components",
"//chrome/browser/web_applications/preinstalled_web_apps",
"//chrome/common",
Expand All @@ -89,7 +92,7 @@ source_set("web_applications") {
"//skia",
]

if (is_chromeos) {
if (is_chromeos_ash) {
deps += [
"//ash/public/cpp",
"//chromeos/components/camera_app_ui",
Expand Down Expand Up @@ -206,6 +209,7 @@ source_set("web_applications_unit_tests") {
":web_applications_on_extensions_test_support",
":web_applications_test_support",
"//base/test:test_support",
"//build:chromeos_buildflags",
"//chrome/browser",
"//chrome/browser/web_applications/components",
"//chrome/browser/web_applications/preinstalled_web_apps",
Expand All @@ -221,7 +225,7 @@ source_set("web_applications_unit_tests") {
"//testing/gtest",
]

if (is_chromeos) {
if (is_chromeos_ash) {
deps += [
"//chrome/browser/chromeos",
"//chromeos/constants",
Expand Down Expand Up @@ -261,6 +265,7 @@ source_set("web_applications_browser_tests") {
":web_applications_on_extensions_test_support",
":web_applications_test_support",
"//build:branding_buildflags",
"//build:chromeos_buildflags",
"//chrome/app:command_ids",
"//chrome/browser/apps/app_service:test_support",
"//chrome/browser/extensions:test_support",
Expand All @@ -275,7 +280,7 @@ source_set("web_applications_browser_tests") {
"//extensions/browser:test_support",
]

if (is_chromeos) {
if (is_chromeos_ash) {
deps += [
"//chrome/browser/chromeos",
"//chrome/browser/ui",
Expand Down
14 changes: 9 additions & 5 deletions chrome/browser/web_applications/components/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
# 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")

source_set("components") {
sources = [
"app_icon_manager.cc",
Expand Down Expand Up @@ -89,11 +91,11 @@ source_set("components") {
"web_app_icon_downloader.h",
]

if (is_chromeos) {
if (is_chromeos_ash) {
sources += [ "web_app_shortcut_chromeos.cc" ]
}

if (is_linux) {
if (is_linux || is_chromeos_lacros) {
# Desktop linux, doesn't count ChromeOS.
sources += [
"web_app_file_handler_registration_linux.cc",
Expand Down Expand Up @@ -130,6 +132,7 @@ source_set("components") {
[ "//components/services/app_service/public/cpp:app_share_target" ]

deps = [
"//build:chromeos_buildflags",
"//chrome/app/resources:platform_locale_settings",
"//chrome/app/theme:chrome_unscaled_resources",
"//chrome/browser:browser_process",
Expand Down Expand Up @@ -187,7 +190,7 @@ source_set("unit_tests") {
]
}

if (is_linux) {
if (is_linux || is_chromeos_lacros) {
# Desktop linux, doesn't count ChromeOS.
sources += [
"web_app_file_handler_registration_linux_unittest.cc",
Expand All @@ -198,6 +201,7 @@ source_set("unit_tests") {
deps = [
":components",
"//base/test:test_support",
"//build:chromeos_buildflags",
"//chrome/app/theme:theme_resources",
"//chrome/browser/web_applications:web_app_test_group",
"//chrome/browser/web_applications:web_applications",
Expand All @@ -210,7 +214,7 @@ source_set("unit_tests") {
"//testing/gtest",
]

if (is_chromeos) {
if (is_chromeos_ash) {
deps += [ "//chrome/browser/chromeos" ]
}

Expand All @@ -224,7 +228,7 @@ source_set("browser_tests") {

sources = [ "web_app_url_loader_browsertest.cc" ]

if (is_linux) {
if (is_linux || is_chromeos_lacros) {
sources += [ "web_app_file_handler_registration_linux_browsertest.cc" ]
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include "base/no_destructor.h"
#include "base/strings/utf_string_conversions.h"
#include "build/build_config.h"
#include "build/chromeos_buildflags.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/web_applications/components/app_icon_manager.h"
#include "chrome/common/chrome_features.h"
Expand Down Expand Up @@ -69,7 +70,7 @@ void AppShortcutManager::SetShortcutUpdateCallbackForTesting(
}

bool AppShortcutManager::CanCreateShortcuts() const {
#if defined(OS_CHROMEOS)
#if BUILDFLAG(IS_CHROMEOS_ASH)
return false;
#else
return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include <vector>

#include "base/strings/string_util.h"
#include "build/chromeos_buildflags.h"

namespace web_app {

Expand Down Expand Up @@ -40,9 +41,9 @@ bool ExternalInstallOptions::operator==(
run_on_os_login, is_disabled,
override_previous_user_uninstall, only_for_new_users,
user_type_allowlist, gate_on_feature,
#if defined(OS_CHROMEOS)
#if BUILDFLAG(IS_CHROMEOS_ASH)
disable_if_arc_supported, disable_if_tablet_form_factor,
#endif // defined(OS_CHROMEOS)
#endif // BUILDFLAG(IS_CHROMEOS_ASH)
bypass_service_worker_check, require_manifest,
force_reinstall, wait_for_windows_closed, install_placeholder,
reinstall_placeholder, launch_query_params,
Expand All @@ -56,10 +57,10 @@ bool ExternalInstallOptions::operator==(
other.add_to_management, other.run_on_os_login, other.is_disabled,
other.override_previous_user_uninstall, other.only_for_new_users,
other.user_type_allowlist, other.gate_on_feature,
#if defined(OS_CHROMEOS)
#if BUILDFLAG(IS_CHROMEOS_ASH)
other.disable_if_arc_supported,
other.disable_if_tablet_form_factor,
#endif // defined(OS_CHROMEOS)
#endif // BUILDFLAG(IS_CHROMEOS_ASH)
other.bypass_service_worker_check, other.require_manifest,
other.force_reinstall, other.wait_for_windows_closed,
other.install_placeholder, other.reinstall_placeholder,
Expand Down Expand Up @@ -116,12 +117,12 @@ std::ostream& operator<<(std::ostream& out,
<< "\n only_for_new_users: " << install_options.only_for_new_users
<< "\n user_type_allowlist: " << install_options.user_type_allowlist
<< "\n gate_on_feature: " << install_options.gate_on_feature
#if defined(OS_CHROMEOS)
#if BUILDFLAG(IS_CHROMEOS_ASH)
<< "\n disable_if_arc_supported: "
<< install_options.disable_if_arc_supported
<< "\n disable_if_tablet_form_factor: "
<< install_options.disable_if_tablet_form_factor
#endif // defined(OS_CHROMEOS)
#endif // BUILDFLAG(IS_CHROMEOS_ASH)
<< "\n bypass_service_worker_check: "
<< install_options.bypass_service_worker_check
<< "\n require_manifest: " << install_options.require_manifest
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include "base/optional.h"
#include "base/threading/sequenced_task_runner_handle.h"
#include "build/build_config.h"
#include "build/chromeos_buildflags.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/web_applications/components/web_app_constants.h"
#include "chrome/browser/web_applications/components/web_app_id.h"
Expand Down Expand Up @@ -291,7 +292,7 @@ FileHandlerManager& OsIntegrationManager::file_handler_manager_for_testing() {
ScopedOsHooksSuppress OsIntegrationManager::ScopedSuppressOsHooksForTesting() {
// Creating OS hooks on ChromeOS doesn't write files to disk, so it's
// unnecessary to suppress and it provides better crash coverage.
#if !defined(OS_CHROMEOS)
#if !BUILDFLAG(IS_CHROMEOS_ASH)
return std::make_unique<base::AutoReset<bool>>(
&g_suppress_os_hooks_for_testing_, true);
#else
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,14 @@

#include "base/check.h"
#include "build/build_config.h"
#include "build/chromeos_buildflags.h"

namespace web_app {

// This block defines stub implementations of OS specific methods for
// FileHandling. Currently, Windows, MacOSX and Desktop Linux (but not Chrome
// OS) have their own implementations.
#if defined(OS_CHROMEOS)
#if BUILDFLAG(IS_CHROMEOS_ASH)
bool ShouldRegisterFileHandlersWithOs() {
return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include "base/i18n/case_conversion.h"
#include "base/strings/utf_string_conversions.h"
#include "build/build_config.h"
#include "build/chromeos_buildflags.h"
#include "chrome/common/chrome_features.h"
#include "chrome/grit/platform_locale_settings.h"
#include "components/url_formatter/url_formatter.h"
Expand Down Expand Up @@ -55,7 +56,7 @@ class GeneratedIconImageSource : public gfx::CanvasImageSource {

std::string font_name =
l10n_util::GetStringUTF8(IDS_SANS_SERIF_FONT_FAMILY);
#if defined(OS_CHROMEOS)
#if BUILDFLAG(IS_CHROMEOS_ASH)
if (base::FeatureList::IsEnabled(features::kAppServiceAdaptiveIcon)) {
// With adaptive icons, we generate full size square icons as they will be
// masked by the OS.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_util.h"
#include "base/threading/scoped_blocking_call.h"
#include "build/chromeos_buildflags.h"
#include "chrome/browser/shell_integration.h"
#include "chrome/browser/shell_integration_linux.h"
#include "chrome/browser/web_applications/components/web_app_id.h"
Expand Down Expand Up @@ -508,7 +509,7 @@ bool CreatePlatformShortcuts(const base::FilePath& web_app_path,
const ShortcutLocations& creation_locations,
ShortcutCreationReason /*creation_reason*/,
const ShortcutInfo& shortcut_info) {
#if !defined(OS_CHROMEOS)
#if !BUILDFLAG(IS_CHROMEOS_ASH)
base::ScopedBlockingCall scoped_blocking_call(FROM_HERE,
base::BlockingType::MAY_BLOCK);
return CreateDesktopShortcut(shortcut_info, creation_locations);
Expand All @@ -519,7 +520,7 @@ bool CreatePlatformShortcuts(const base::FilePath& web_app_path,

bool DeletePlatformShortcuts(const base::FilePath& web_app_path,
const ShortcutInfo& shortcut_info) {
#if !defined(OS_CHROMEOS)
#if !BUILDFLAG(IS_CHROMEOS_ASH)
return DeleteDesktopShortcuts(shortcut_info.profile_path,
shortcut_info.extension_id);
#endif
Expand Down Expand Up @@ -549,7 +550,7 @@ void UpdatePlatformShortcuts(const base::FilePath& web_app_path,
}

void DeleteAllShortcutsForProfile(const base::FilePath& profile_path) {
#if !defined(OS_CHROMEOS)
#if !BUILDFLAG(IS_CHROMEOS_ASH)
DeleteAllDesktopShortcuts(profile_path);
#endif
}
Expand Down
13 changes: 7 additions & 6 deletions chrome/browser/web_applications/components/web_app_utils.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,14 @@
#include "chrome/browser/web_applications/components/web_app_utils.h"

#include "base/files/file_path.h"
#include "build/chromeos_buildflags.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/common/chrome_constants.h"

#if defined(OS_CHROMEOS)
#if BUILDFLAG(IS_CHROMEOS_ASH)
#include "chrome/browser/chromeos/profiles/profile_helper.h"
#include "components/user_manager/user_manager.h"
#endif // OS_CHROMEOS
#endif // BUILDFLAG(IS_CHROMEOS_ASH)

namespace web_app {

Expand All @@ -28,7 +29,7 @@ bool AreWebAppsEnabled(const Profile* profile) {
const Profile* original_profile = profile->GetOriginalProfile();
DCHECK(!original_profile->IsOffTheRecord());

#if defined(OS_CHROMEOS)
#if BUILDFLAG(IS_CHROMEOS_ASH)
// Web Apps should not be installed to the ChromeOS system profiles.
if (chromeos::ProfileHelper::IsSigninProfile(original_profile) ||
chromeos::ProfileHelper::IsLockScreenAppProfile(original_profile)) {
Expand All @@ -40,7 +41,7 @@ bool AreWebAppsEnabled(const Profile* profile) {
user_manager->IsLoggedInAsArcKioskApp())) {
return false;
}
#endif // OS_CHROMEOS
#endif // BUILDFLAG(IS_CHROMEOS_ASH)

return true;
}
Expand Down Expand Up @@ -96,7 +97,7 @@ base::FilePath GetWebAppsTempDirectory(
}

std::string GetProfileCategoryForLogging(Profile* profile) {
#ifdef OS_CHROMEOS
#if BUILDFLAG(IS_CHROMEOS_ASH)
if (chromeos::ProfileHelper::IsSigninProfile(profile) ||
chromeos::ProfileHelper::IsLockScreenAppProfile(profile)) {
return "SigninOrLockScreen";
Expand All @@ -117,7 +118,7 @@ std::string GetProfileCategoryForLogging(Profile* profile) {
}

bool IsChromeOs() {
#if defined(OS_CHROMEOS)
#if BUILDFLAG(IS_CHROMEOS_ASH)
return true;
#else
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

#include "base/containers/adapters.h"
#include "base/files/file_path.h"
#include "build/chromeos_buildflags.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/web_applications/components/web_application_info.h"
#include "chrome/browser/web_applications/test/web_app_test.h"
Expand All @@ -17,11 +18,11 @@
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"

#if defined(OS_CHROMEOS)
#if BUILDFLAG(IS_CHROMEOS_ASH)
#include "chrome/browser/chromeos/login/users/mock_user_manager.h"
#include "chrome/browser/chromeos/profiles/profile_helper.h"
#include "components/user_manager/scoped_user_manager.h"
#endif // OS_CHROMEOS
#endif // BUILDFLAG(IS_CHROMEOS_ASH)

namespace web_app {

Expand Down Expand Up @@ -67,7 +68,7 @@ TEST_F(WebAppUtilsTest, AreWebAppsEnabled) {
EXPECT_FALSE(AreWebAppsEnabled(system_profile));
EXPECT_FALSE(AreWebAppsEnabled(system_profile->GetPrimaryOTRProfile()));

#if defined(OS_CHROMEOS)
#if BUILDFLAG(IS_CHROMEOS_ASH)
Profile* signin_profile =
profile_manager.CreateTestingProfile(chrome::kInitialProfile);
EXPECT_FALSE(AreWebAppsEnabled(signin_profile));
Expand Down Expand Up @@ -125,7 +126,7 @@ TEST_F(WebAppUtilsTest, AreWebAppsUserInstallable) {
EXPECT_FALSE(
AreWebAppsUserInstallable(system_profile->GetPrimaryOTRProfile()));

#if defined(OS_CHROMEOS)
#if BUILDFLAG(IS_CHROMEOS_ASH)
Profile* signin_profile =
profile_manager.CreateTestingProfile(chrome::kInitialProfile);
EXPECT_FALSE(AreWebAppsUserInstallable(signin_profile));
Expand Down
1 change: 1 addition & 0 deletions chrome/browser/web_applications/extensions/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ source_set("extensions") {
deps = [
"//base",
"//chrome/browser:browser_process",
"//build:chromeos_buildflags",
"//chrome/browser/web_applications",
"//chrome/browser/web_applications:web_app_group",
"//chrome/browser/web_applications/components",
Expand Down
Loading

0 comments on commit b77fc4b

Please sign in to comment.