Commit 90ec3ea8 authored by Erik Chen's avatar Erik Chen Committed by Commit Bot

Add 'lacros' enum to list of extension platforms.

This CL allows extensions to be marked as available on the 'lacros'
platform. This is primarily a small change to the generator python files
to accept a new enum type.

This CL marks enterprise.platformKeys as available on 'lacros' in order
to have real code using this logic path.

Change-Id: Icb593cb9fdd149154b7bd5d7206fad560ce82277
Bug: 1111879
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2333570
Auto-Submit: Erik Chen <erikchen@chromium.org>
Reviewed-by: default avatarDevlin <rdevlin.cronin@chromium.org>
Commit-Queue: Erik Chen <erikchen@chromium.org>
Cr-Commit-Position: refs/heads/master@{#794821}
parent b7aa9697
...@@ -312,8 +312,8 @@ The only accepted value is the bool `true`. ...@@ -312,8 +312,8 @@ The only accepted value is the bool `true`.
The `platforms` property specifies the properties the feature should be The `platforms` property specifies the properties the feature should be
available on. available on.
The accepted values are lists of strings from `chromeos`, `mac`, `linux`, and The accepted values are lists of strings from `chromeos`, `mac`, 'lacros',
`win`. `linux`, and `win`.
### session\_types ### session\_types
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
// certificates will be managed by the platform and can be used for TLS // certificates will be managed by the platform and can be used for TLS
// authentication, network access or by other extension through // authentication, network access or by other extension through
// $(ref:platformKeys chrome.platformKeys). // $(ref:platformKeys chrome.platformKeys).
[platforms = ("chromeos")] [platforms = ("chromeos", "lacros")]
namespace enterprise.platformKeys { namespace enterprise.platformKeys {
[nocompile, noinline_doc] dictionary Token { [nocompile, noinline_doc] dictionary Token {
// Uniquely identifies this <code>Token</code>. // Uniquely identifies this <code>Token</code>.
......
...@@ -334,6 +334,7 @@ if (enable_extensions) { ...@@ -334,6 +334,7 @@ if (enable_extensions) {
deps = [ deps = [
"//base", "//base",
"//build:branding_buildflags", "//build:branding_buildflags",
"//build:lacros_buildflags",
"//components/crx_file", "//components/crx_file",
"//components/nacl/common:buildflags", "//components/nacl/common:buildflags",
"//components/url_formatter", "//components/url_formatter",
......
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
#include "base/strings/string_util.h" #include "base/strings/string_util.h"
#include "base/strings/stringprintf.h" #include "base/strings/stringprintf.h"
#include "build/build_config.h" #include "build/build_config.h"
#include "build/lacros_buildflags.h"
#include "extensions/common/extension.h" #include "extensions/common/extension.h"
#include "extensions/common/manifest.h" #include "extensions/common/manifest.h"
...@@ -18,7 +19,12 @@ namespace extensions { ...@@ -18,7 +19,12 @@ namespace extensions {
// static // static
Feature::Platform Feature::GetCurrentPlatform() { Feature::Platform Feature::GetCurrentPlatform() {
#if defined(OS_CHROMEOS) // TODO(https://crbug.com/1052397): For readability, this should become
// defined(OS_CHROMEOS) && BUILDFLAG(IS_LACROS). The second conditional should
// be defined(OS_CHROMEOS) && BUILDFLAG(IS_ASH).
#if BUILDFLAG(IS_LACROS)
return LACROS_PLATFORM;
#elif defined(OS_CHROMEOS) && !BUILDFLAG(IS_LACROS)
return CHROMEOS_PLATFORM; return CHROMEOS_PLATFORM;
#elif defined(OS_LINUX) #elif defined(OS_LINUX)
return LINUX_PLATFORM; return LINUX_PLATFORM;
......
...@@ -46,6 +46,7 @@ class Feature { ...@@ -46,6 +46,7 @@ class Feature {
enum Platform { enum Platform {
UNSPECIFIED_PLATFORM, UNSPECIFIED_PLATFORM,
CHROMEOS_PLATFORM, CHROMEOS_PLATFORM,
LACROS_PLATFORM,
LINUX_PLATFORM, LINUX_PLATFORM,
MACOSX_PLATFORM, MACOSX_PLATFORM,
WIN_PLATFORM WIN_PLATFORM
......
...@@ -143,7 +143,13 @@ class CppBundleGenerator(object): ...@@ -143,7 +143,13 @@ class CppBundleGenerator(object):
ifdefs = [] ifdefs = []
for platform in model_object.platforms: for platform in model_object.platforms:
if platform == Platforms.CHROMEOS: if platform == Platforms.CHROMEOS:
ifdefs.append('defined(OS_CHROMEOS)') # TODO(https://crbug.com/1052397): For readability, this should become
# defined(OS_CHROMEOS) && BUILDFLAG(IS_ASH).
ifdefs.append('(defined(OS_CHROMEOS) && !BUILDFLAG(IS_LACROS))')
elif platform == Platforms.LACROS:
# TODO(https://crbug.com/1052397): For readability, this should become
# defined(OS_CHROMEOS) && BUILDFLAG(IS_LACROS).
ifdefs.append('BUILDFLAG(IS_LACROS)')
elif platform == Platforms.LINUX: elif platform == Platforms.LINUX:
ifdefs.append('(defined(OS_LINUX) && !defined(OS_CHROMEOS))') ifdefs.append('(defined(OS_LINUX) && !defined(OS_CHROMEOS))')
elif platform == Platforms.MAC: elif platform == Platforms.MAC:
...@@ -252,6 +258,9 @@ class _APICCGenerator(object): ...@@ -252,6 +258,9 @@ class _APICCGenerator(object):
os.path.join(self._bundle._impl_dir, os.path.join(self._bundle._impl_dir,
'generated_api_registration.h'))) 'generated_api_registration.h')))
c.Append() c.Append()
c.Append('#include "build/build_config.h"')
c.Append('#include "build/lacros_buildflags.h"')
c.Append()
for namespace in self._bundle._model.namespaces.values(): for namespace in self._bundle._model.namespaces.values():
namespace_name = namespace.unix_name.replace("experimental_", "") namespace_name = namespace.unix_name.replace("experimental_", "")
implementation_header = namespace.compiler_options.get( implementation_header = namespace.compiler_options.get(
......
...@@ -36,15 +36,15 @@ class CppBundleGeneratorTest(unittest.TestCase): ...@@ -36,15 +36,15 @@ class CppBundleGeneratorTest(unittest.TestCase):
'test/function_platform_all.json') 'test/function_platform_all.json')
self.assertEquals( self.assertEquals(
'defined(OS_WIN) || (defined(OS_LINUX) && !defined(OS_CHROMEOS)) || ' 'defined(OS_WIN) || (defined(OS_LINUX) && !defined(OS_CHROMEOS)) || '
'defined(OS_CHROMEOS)', '(defined(OS_CHROMEOS) && !BUILDFLAG(IS_LACROS))',
_getPlatformIfdefs(cpp_bundle_generator, model)) _getPlatformIfdefs(cpp_bundle_generator, model))
def testIfDefsForChromeOS(self): def testIfDefsForChromeOS(self):
cpp_bundle_generator, model = _createCppBundleGenerator( cpp_bundle_generator, model = _createCppBundleGenerator(
'test/function_platform_chromeos.json') 'test/function_platform_chromeos.json')
self.assertEquals( self.assertEquals('(defined(OS_CHROMEOS) && !BUILDFLAG(IS_LACROS))',
'defined(OS_CHROMEOS)', _getPlatformIfdefs(cpp_bundle_generator, model))
_getPlatformIfdefs(cpp_bundle_generator, model))
if __name__ == '__main__': if __name__ == '__main__':
unittest.main() unittest.main()
...@@ -240,6 +240,7 @@ FEATURE_GRAMMAR = ({ ...@@ -240,6 +240,7 @@ FEATURE_GRAMMAR = ({
list: { list: {
'enum_map': { 'enum_map': {
'chromeos': 'Feature::CHROMEOS_PLATFORM', 'chromeos': 'Feature::CHROMEOS_PLATFORM',
'lacros': 'Feature::LACROS_PLATFORM',
'linux': 'Feature::LINUX_PLATFORM', 'linux': 'Feature::LINUX_PLATFORM',
'mac': 'Feature::MACOSX_PLATFORM', 'mac': 'Feature::MACOSX_PLATFORM',
'win': 'Feature::WIN_PLATFORM', 'win': 'Feature::WIN_PLATFORM',
......
...@@ -605,6 +605,7 @@ class Platforms(object): ...@@ -605,6 +605,7 @@ class Platforms(object):
""" """
CHROMEOS = _PlatformInfo("chromeos") CHROMEOS = _PlatformInfo("chromeos")
CHROMEOS_TOUCH = _PlatformInfo("chromeos_touch") CHROMEOS_TOUCH = _PlatformInfo("chromeos_touch")
LACROS = _PlatformInfo("lacros")
LINUX = _PlatformInfo("linux") LINUX = _PlatformInfo("linux")
MAC = _PlatformInfo("mac") MAC = _PlatformInfo("mac")
WIN = _PlatformInfo("win") WIN = _PlatformInfo("win")
......
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