summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--build/buildflag.h47
-rw-r--r--build/buildflag_header.gni138
-rw-r--r--build/buildflag_header.gypi118
-rw-r--r--build/common.gypi12
-rw-r--r--build/config/BUILD.gn3
-rw-r--r--build/config/features.gni2
-rw-r--r--build/gypi_to_gn.py6
-rwxr-xr-xbuild/write_buildflag_header.py95
-rw-r--r--chrome/browser/BUILD.gn2
-rw-r--r--chrome/browser/extensions/component_loader.cc5
-rw-r--r--chrome/browser/profiles/profile.cc3
-rw-r--r--chrome/browser/resources/BUILD.gn13
-rw-r--r--chrome/browser/ui/BUILD.gn1
-rw-r--r--chrome/browser/ui/webui/options/content_settings_handler.cc3
-rw-r--r--chrome/browser/ui/webui/options/options_ui.cc5
-rw-r--r--chrome/chrome.gyp1
-rw-r--r--chrome/chrome_android.gypi1
-rw-r--r--chrome/chrome_browser.gypi1
-rw-r--r--chrome/chrome_browser_extensions.gypi1
-rw-r--r--chrome/chrome_child.gypi1
-rw-r--r--chrome/chrome_common.gypi14
-rw-r--r--chrome/chrome_debugger.gypi1
-rw-r--r--chrome/chrome_exe.gypi5
-rw-r--r--chrome/chrome_features.gypi31
-rw-r--r--chrome/chrome_plugin.gypi1
-rw-r--r--chrome/chrome_renderer.gypi1
-rw-r--r--chrome/chrome_resources.gyp6
-rw-r--r--chrome/chrome_tests.gypi3
-rw-r--r--chrome/chrome_tests_unit.gypi2
-rw-r--r--chrome/chrome_utility.gypi1
-rw-r--r--chrome/common/BUILD.gn9
-rw-r--r--chrome/common/features.gni12
-rw-r--r--chrome/common/pref_names.cc3
-rw-r--r--chrome/common/pref_names.h3
-rw-r--r--chrome/common_constants.gyp1
-rwxr-xr-xtools/grit/grit/util.py7
-rw-r--r--tools/grit/grit_rule.gni7
37 files changed, 527 insertions, 38 deletions
diff --git a/build/buildflag.h b/build/buildflag.h
new file mode 100644
index 0000000..283f5bc
--- /dev/null
+++ b/build/buildflag.h
@@ -0,0 +1,47 @@
+// Copyright 2015 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.
+
+#ifndef BUILD_BUILDFLAG_H_
+#define BUILD_BUILDFLAG_H_
+
+// These macros un-mangle the names of the build flags in a way that looks
+// natural, and gives errors if the flag is not defined. Normally in the
+// preprocessor it's easy to make mistakes that interpret "you haven't done
+// the setup to know what the flag is" as "flag is off". Normally you would
+// include the generated header rather than include this file directly.
+//
+// This is for use with generated headers. See build/build_header.gni.
+
+// This dance of two macros does a concatenation of two preprocessor args using
+// ## doubly indirectly because using ## directly prevents macros in that
+// parameter from being expanded.
+#define BUILDFLAG_CAT_INDIRECT(a, b) a ## b
+#define BUILDFLAG_CAT(a, b) BUILDFLAG_CAT_INDIRECT(a, b)
+
+// Accessor for build flags.
+//
+// To test for a value, if the build file specifies:
+//
+// ENABLE_FOO=true
+//
+// Then you would check at build-time in source code with:
+//
+// #include "foo_flags.h" // The header the build file specified.
+//
+// #if BUILDFLAG(ENABLE_FOO)
+// ...
+// #endif
+//
+// There will no #define called ENABLE_FOO so if you accidentally test for
+// whether that is defined, it will always be negative. You can also use
+// the value in expressions:
+//
+// const char kSpamServerName[] = BUILDFLAG(SPAM_SERVER_NAME);
+//
+// Because the flag is accessed as a preprocessor macro with (), an error
+// will be thrown if the proper header defining the internal flag value has
+// not been included.
+#define BUILDFLAG(flag) (BUILDFLAG_CAT(BUILDFLAG_INTERNAL_, flag)())
+
+#endif // BUILD_BUILDFLAG_H_
diff --git a/build/buildflag_header.gni b/build/buildflag_header.gni
new file mode 100644
index 0000000..9054d07
--- /dev/null
+++ b/build/buildflag_header.gni
@@ -0,0 +1,138 @@
+# Copyright 2015 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.
+
+# Generates a header with preprocessor defines specified by the build file.
+# The GYP version of this (with instructions) is build/buildflag_header.gypi.
+#
+# The flags are converted to function-style defines with mangled names and
+# code uses an accessor macro to access the values. This is to try to
+# minimize bugs where code checks whether something is defined or not, and
+# the proper header isn't included, meaning the answer will always be silently
+# false or might vary across the code base.
+#
+# In the GN template, specify build flags in the template as a list
+# of strings that encode key/value pairs like this:
+#
+# flags = [ "ENABLE_FOO=1", "ENABLE_BAR=$enable_bar" ]
+#
+# The GN values "true" and "false" will be mapped to 0 and 1 for boolean
+# #if flags to be expressed naturally. This means you can't directly make a
+# define that generates C++ value of true or false for use in code. If you
+# REALLY need this, you can also use the string "(true)" and "(false)" to
+# prevent the rewriting.
+
+# To check the value of the flag in C code:
+#
+# #include "path/to/here/header_file.h"
+#
+# #if BUILDFLAG(ENABLE_FOO)
+# ...
+# #endif
+#
+# const char kSpamServerUrl[] = BUILDFLAG(SPAM_SERVER_URL);
+#
+# There will no #define called ENABLE_FOO so if you accidentally test for that
+# in an ifdef it will always be negative.
+#
+#
+# Template parameters
+#
+# flags [required, list of strings]
+# Flag values as described above.
+#
+# header [required, string]
+# File name for generated header. By default, this will go in the
+# generated file directory for this target, and you would include it
+# with:
+# #include "<path_to_this_BUILD_file>/<header>"
+#
+# header_dir [optional, string]
+# Override the default location of the generated header. The string will
+# be treated as a subdirectory of the root_gen_dir. For example:
+# header_dir = "foo/bar"
+# Then you can include the header as:
+# #include "foo/bar/baz.h"
+#
+# deps, public_deps, testonly, visibility
+# Normal meaning.
+#
+#
+# Grit defines
+#
+# If one .grd file uses a flag, just add to the grit target:
+#
+# defines = [
+# "enable_doom_melon=$enable_doom_melon",
+# ]
+#
+# If multiple .grd files use it, you'll want to put the defines in a .gni file
+# so it can be shared. Generally this .gni file should include all grit defines
+# for a given module (for some definition of "module"). Then do:
+#
+# defines = ui_grit_defines
+#
+# If you forget to do this, the flag will be implicitly false in the .grd file
+# and those resources won't be compiled. You'll know because the resource
+# #define won't be generated and any code that uses it won't compile. If you
+# see a missing IDS_* string, this is probably the reason.
+#
+#
+# Example
+#
+# buildflag_header("foo_features") {
+# header = "foo_features.h"
+#
+# flags = [
+# # This uses the GN build flag enable_doom_melon as the definition.
+# "ENABLE_DOOM_MELON=$enable_doom_melon",
+#
+# # This force-enables the flag.
+# "ENABLE_SPACE_LASER=true",
+#
+# # This will expand to the quoted C string when used in source code.
+# "SPAM_SERVER_URL=\"http://www.example.com/\"",
+# ]
+# }
+template("buildflag_header") {
+ action(target_name) {
+ script = "//build/write_buildflag_header.py"
+
+ if (defined(invoker.header_dir)) {
+ header_file = "${invoker.header_dir}/${invoker.header}"
+ } else {
+ # Compute the path from the root to this file.
+ header_file = rebase_path(".", "//") + "/${invoker.header}"
+ }
+
+ outputs = [
+ "$root_gen_dir/$header_file",
+ ]
+
+ # Always write --flags to the file so it's not empty. Empty will confuse GN
+ # into thinking the response file isn't used.
+ response_file_contents = [ "--flags" ]
+ if (defined(invoker.flags)) {
+ response_file_contents += invoker.flags
+ }
+
+ args = [
+ "--output",
+ header_file, # Not rebased, Python script puts it inside gen-dir.
+ "--rulename",
+ get_label_info(":$target_name", "label_no_toolchain"),
+ "--gen-dir",
+ rebase_path(root_gen_dir, root_out_dir),
+ "--definitions",
+ "{{response_file_name}}",
+ ]
+
+ forward_variables_from(invoker,
+ [
+ "deps",
+ "public_deps",
+ "testonly",
+ "visibility",
+ ])
+ }
+}
diff --git a/build/buildflag_header.gypi b/build/buildflag_header.gypi
new file mode 100644
index 0000000..730ef429
--- /dev/null
+++ b/build/buildflag_header.gypi
@@ -0,0 +1,118 @@
+# Copyright 2015 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.
+
+# Generates a header with preprocessor defines specified by the build file.
+#
+# The canonical documentation is in build/buildflag_header.gni. You should
+# write the GN build, get it working, and then transform it into GYP.
+#
+# In every target that uses your generated header you must include a dependency
+# on the GYP target that generates the header (this is implicit in GN).
+# Otherwise, clean builds may not necessarily create the header before the
+# source code is compiled.
+#
+# Assuming your GN code looks like this:
+#
+# buildflag_header("foo_features") {
+# header = "foo_features.h"
+# flags = [
+# "ENABLE_DOOM_MELON=$enable_doom_melon",
+# "ENABLE_SPACE_LASER=true",
+# "SPAM_SERVER_URL=\"http://www.example.com/\"",
+# ]
+# }
+#
+# Write a GYP target like this:
+#
+# {
+# # GN version: //foo:foo_features
+# 'target_name': 'foo_foo_features',
+# 'includes': [ '../build/buildflag_header.gypi' ],
+# 'variables': {
+# 'buildflag_header_path': 'foo/foo_features.h',
+# 'buildflag_header_flags': [
+# 'ENABLE_DOOM_MELON=<(enable_doom_melon)',
+# 'ENABLE_SPACE_LASER=true',
+# 'SPAM_SERVER_URL="http://www.example.com/"',
+# ],
+# },
+# }
+#
+# Variables
+#
+# target_name
+# Base this on the GN label, replacing / and : with _ to make it globally
+# unique.
+#
+# buildflag_header_path
+# This must be the full path to the header from the source root. In GN
+# you only say "features.h" and it uses the BUILD file's path implicitly.
+# Use the path to BUILD.gn followed by your header name to produce the
+# same output file.
+#
+# buildflag_flags (optional)
+# List of the same format as GN's "flags". To expand variables, use
+# "<(foo)" where GN would have used "$foo".
+#
+# includes
+# List the relative path to build/buildflag_header.gypi from the .gyp
+# file including this code, Note: If your code is in a .gypi file in a
+# different directory, this must be relative to the .gyp including your
+# file.
+#
+#
+# Grit defines
+#
+# Follow the same advice as in the buildflag_header.gni, except on the grit
+# action use the variable name 'grit_additional_defines' and explicitly add a
+# '-D' in front:
+#
+# 'grit_grd_file': 'foo.grd',
+# 'grit_additional_defines': [
+# '-D', 'enable_doom_melon=<(enable_doom_melon)',
+# ],
+#
+# Put shared lists of defines in a .gypi.
+
+{
+ 'type': 'none',
+ 'hard_dependency': 1,
+
+ 'actions': [
+ {
+ 'action_name': 'buildflag_header',
+ 'variables': {
+ # Default these values to empty if they're not defined.
+ 'variables': {
+ 'buildflag_flags%': [],
+ },
+
+ # Writes the flags to a response file with a name based on the name of
+ # this target.
+ 'response_file_name': '<|(<(_target_name)_buildflag_header.rsp --flags <@(buildflag_flags))',
+
+ 'build_header_script': '<(DEPTH)/build/write_buildflag_header.py',
+ },
+
+ 'message': 'Generating build header.',
+
+ 'inputs': [
+ '<(build_header_script)',
+ '<(response_file_name)',
+ ],
+
+ 'outputs': [
+ '<(SHARED_INTERMEDIATE_DIR)/<(buildflag_header_path)',
+ ],
+
+ 'action': [
+ 'python', '<(build_header_script)',
+ '--output', '<(buildflag_header_path)',
+ '--rulename', '<(_target_name)',
+ '--gen-dir', '<(SHARED_INTERMEDIATE_DIR)',
+ '--definitions', '<(response_file_name)',
+ ],
+ }
+ ],
+}
diff --git a/build/common.gypi b/build/common.gypi
index 9c226a2..c5d5c85d 100644
--- a/build/common.gypi
+++ b/build/common.gypi
@@ -547,9 +547,6 @@
# Enable Chrome browser extensions
'enable_extensions%': 1,
- # Enable Google Now.
- 'enable_google_now%': 1,
-
# Enable basic printing support and UI.
'enable_basic_printing%': 1,
@@ -819,7 +816,6 @@
['OS=="android"', {
'enable_extensions%': 0,
- 'enable_google_now%': 0,
'cld2_table_size%': 0,
'enable_themes%': 0,
'remoting%': 0,
@@ -867,7 +863,6 @@
'configuration_policy%': 0,
'disable_ftp_support%': 1,
'enable_extensions%': 0,
- 'enable_google_now%': 0,
'cld2_table_size%': 0,
'enable_basic_printing%': 0,
'enable_print_preview%': 0,
@@ -1221,7 +1216,6 @@
'enable_print_preview%': '<(enable_print_preview)',
'enable_spellcheck%': '<(enable_spellcheck)',
'use_browser_spellchecker%': '<(use_browser_spellchecker)',
- 'enable_google_now%': '<(enable_google_now)',
'cld_version%': '<(cld_version)',
'cld2_table_size%': '<(cld2_table_size)',
'enable_captive_portal_detection%': '<(enable_captive_portal_detection)',
@@ -2180,9 +2174,6 @@
['enable_settings_app==1', {
'grit_defines': ['-D', 'enable_settings_app'],
}],
- ['enable_google_now==1', {
- 'grit_defines': ['-D', 'enable_google_now'],
- }],
['use_concatenated_impulse_responses==1', {
'grit_defines': ['-D', 'use_concatenated_impulse_responses'],
}],
@@ -2995,9 +2986,6 @@
['enable_background==1', {
'defines': ['ENABLE_BACKGROUND=1'],
}],
- ['enable_google_now==1', {
- 'defines': ['ENABLE_GOOGLE_NOW=1'],
- }],
['enable_basic_printing==1 or enable_print_preview==1', {
# Convenience define for ENABLE_BASIC_PRINTING || ENABLE_PRINT_PREVIEW.
'defines': ['ENABLE_PRINTING=1'],
diff --git a/build/config/BUILD.gn b/build/config/BUILD.gn
index 9cc3756..5f85713 100644
--- a/build/config/BUILD.gn
+++ b/build/config/BUILD.gn
@@ -218,9 +218,6 @@ config("feature_flags") {
if (enable_image_loader_extension) {
defines += [ "IMAGE_LOADER_EXTENSION=1" ]
}
- if (enable_google_now) {
- defines += [ "ENABLE_GOOGLE_NOW=1" ]
- }
if (enable_one_click_signin) {
defines += [ "ENABLE_ONE_CLICK_SIGNIN" ]
}
diff --git a/build/config/features.gni b/build/config/features.gni
index 514a667..1d5f305 100644
--- a/build/config/features.gni
+++ b/build/config/features.gni
@@ -83,8 +83,6 @@ declare_args() {
enable_autofill_dialog = !is_ios
- enable_google_now = !is_ios && !is_android
-
enable_one_click_signin = is_win || is_mac || (is_linux && !is_chromeos)
enable_remoting = !is_ios && !is_chromecast && !is_headless
diff --git a/build/gypi_to_gn.py b/build/gypi_to_gn.py
index a107f94..6de1a63 100644
--- a/build/gypi_to_gn.py
+++ b/build/gypi_to_gn.py
@@ -96,10 +96,12 @@ def LoadPythonDictionary(path):
if 'target_conditions' in file_data:
del file_data['target_conditions']
- # Strip targets in the toplevel, since some files define these and we can't
- # slurp them in.
+ # Strip targets and includes in the toplevel, since some files define these
+ # and we can't slurp them in.
if 'targets' in file_data:
del file_data['targets']
+ if 'includes' in file_data:
+ del file_data['includes']
return file_data
diff --git a/build/write_buildflag_header.py b/build/write_buildflag_header.py
new file mode 100755
index 0000000..d46cfc8
--- /dev/null
+++ b/build/write_buildflag_header.py
@@ -0,0 +1,95 @@
+#!/usr/bin/env python
+# Copyright 2015 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.
+
+# This writes headers for build flags. See buildflag_header.gni for usage of
+# this system as a whole.
+#
+# The parameters are passed in a response file so we don't have to worry
+# about command line lengths. The name of the response file is passed on the
+# command line.
+#
+# The format of the response file is:
+# [--flags <list of one or more flag values>]
+
+import optparse
+import os
+import shlex
+import sys
+
+
+class Options:
+ def __init__(self, output, rulename, header_guard, flags):
+ self.output = output
+ self.rulename = rulename
+ self.header_guard = header_guard
+ self.flags = flags
+
+
+def GetOptions():
+ parser = optparse.OptionParser()
+ parser.add_option('--output', help="Output header name inside --gen-dir.")
+ parser.add_option('--rulename',
+ help="Helpful name of build rule for including in the " +
+ "comment at the top of the file.")
+ parser.add_option('--gen-dir',
+ help="Path to root of generated file directory tree.")
+ parser.add_option('--definitions',
+ help="Name of the response file containing the flags.")
+ cmdline_options, cmdline_flags = parser.parse_args()
+
+ # Compute header guard by replacing some chars with _ and upper-casing.
+ header_guard = cmdline_options.output.upper()
+ header_guard = \
+ header_guard.replace('/', '_').replace('\\', '_').replace('.', '_')
+ header_guard += '_'
+
+ # The actual output file is inside the gen dir.
+ output = os.path.join(cmdline_options.gen_dir, cmdline_options.output)
+
+ # Definition file in GYP is newline separated, in GN they are shell formatted.
+ # shlex can parse both of these.
+ with open(cmdline_options.definitions, 'r') as def_file:
+ defs = shlex.split(def_file.read())
+ flags_index = defs.index('--flags')
+
+ # Everything after --flags are flags. true/false are remapped to 1/0,
+ # everything else is passed through.
+ flags = []
+ for flag in defs[flags_index + 1 :]:
+ equals_index = flag.index('=')
+ key = flag[:equals_index]
+ value = flag[equals_index + 1:]
+
+ # Canonicalize and validate the value.
+ if value == 'true':
+ value = '1'
+ elif value == 'false':
+ value = '0'
+ flags.append((key, str(value)))
+
+ return Options(output=output,
+ rulename=cmdline_options.rulename,
+ header_guard=header_guard,
+ flags=flags)
+
+
+def WriteHeader(options):
+ with open(options.output, 'w') as output_file:
+ output_file.write("// Generated by build/write_buildflag_header.py\n")
+ if options.rulename:
+ output_file.write('// From "' + options.rulename + '"\n')
+
+ output_file.write('\n#ifndef %s\n' % options.header_guard)
+ output_file.write('#define %s\n\n' % options.header_guard)
+ output_file.write('#include "build/buildflag.h"\n\n')
+
+ for pair in options.flags:
+ output_file.write('#define BUILDFLAG_INTERNAL_%s() (%s)\n' % pair)
+
+ output_file.write('\n#endif // %s\n' % options.header_guard)
+
+
+options = GetOptions()
+WriteHeader(options)
diff --git a/chrome/browser/BUILD.gn b/chrome/browser/BUILD.gn
index 8f19496..d09b1f2 100644
--- a/chrome/browser/BUILD.gn
+++ b/chrome/browser/BUILD.gn
@@ -6,6 +6,7 @@ import("//build/config/chrome_build.gni")
import("//build/config/crypto.gni")
import("//build/config/features.gni")
import("//build/config/ui.gni")
+import("//chrome/common/features.gni")
import("//media/media_options.gni")
import("//third_party/protobuf/proto_library.gni")
@@ -957,6 +958,7 @@ if (is_win) {
# (generate_browser_resources action)
grit("resources") {
source = "browser_resources.grd"
+ defines = chrome_grit_defines
output_dir = "$root_gen_dir/chrome"
outputs = [
"grit/browser_resources.h",
diff --git a/chrome/browser/extensions/component_loader.cc b/chrome/browser/extensions/component_loader.cc
index 1e4a738..56a5178 100644
--- a/chrome/browser/extensions/component_loader.cc
+++ b/chrome/browser/extensions/component_loader.cc
@@ -27,6 +27,7 @@
#include "chrome/common/chrome_paths.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/extensions/extension_constants.h"
+#include "chrome/common/features.h"
#include "chrome/grit/chromium_strings.h"
#include "chrome/grit/generated_resources.h"
#include "components/crx_file/id_util.h"
@@ -382,7 +383,7 @@ void ComponentLoader::AddNetworkSpeechSynthesisExtension() {
}
void ComponentLoader::AddGoogleNowExtension() {
-#if defined(ENABLE_GOOGLE_NOW)
+#if BUILDFLAG(ENABLE_GOOGLE_NOW)
const char kEnablePrefix[] = "Enable";
const char kFieldTrialName[] = "GoogleNow";
std::string enable_prefix(kEnablePrefix);
@@ -418,7 +419,7 @@ void ComponentLoader::AddGoogleNowExtension() {
} else {
DeleteData(google_now_manifest_id, root_directory);
}
-#endif // defined(ENABLE_GOOGLE_NOW)
+#endif // BUILDFLAG(ENABLE_GOOGLE_NOW)
}
#if defined(OS_CHROMEOS)
diff --git a/chrome/browser/profiles/profile.cc b/chrome/browser/profiles/profile.cc
index 04d5e9f..8566442 100644
--- a/chrome/browser/profiles/profile.cc
+++ b/chrome/browser/profiles/profile.cc
@@ -12,6 +12,7 @@
#include "chrome/browser/first_run/first_run.h"
#include "chrome/browser/profiles/profile_manager.h"
#include "chrome/browser/sync/profile_sync_service_factory.h"
+#include "chrome/common/features.h"
#include "chrome/common/pref_names.h"
#include "components/browser_sync/browser/profile_sync_service.h"
#include "components/data_reduction_proxy/core/browser/data_reduction_proxy_prefs.h"
@@ -98,7 +99,7 @@ void Profile::RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry) {
registry->RegisterDictionaryPref(prefs::kSafeBrowsingIncidentsSent);
registry->RegisterBooleanPref(
prefs::kSafeBrowsingExtendedReportingOptInAllowed, true);
-#if defined(ENABLE_GOOGLE_NOW)
+#if BUILDFLAG(ENABLE_GOOGLE_NOW)
registry->RegisterBooleanPref(prefs::kGoogleGeolocationAccessEnabled, false);
#endif
// This pref is intentionally outside the above #if. That flag corresponds
diff --git a/chrome/browser/resources/BUILD.gn b/chrome/browser/resources/BUILD.gn
index a5949a2..14de709 100644
--- a/chrome/browser/resources/BUILD.gn
+++ b/chrome/browser/resources/BUILD.gn
@@ -2,10 +2,12 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
+import("//chrome/common/features.gni")
import("//tools/grit/grit_rule.gni")
grit("memory_internals_resources") {
source = "memory_internals_resources.grd"
+ defines = chrome_grit_defines
outputs = [
"grit/memory_internals_resources.h",
"memory_internals_resources.pak",
@@ -15,6 +17,7 @@ grit("memory_internals_resources") {
grit("net_internals_resources") {
source = "net_internals_resources.grd"
+ defines = chrome_grit_defines
outputs = [
"grit/net_internals_resources.h",
"net_internals_resources.pak",
@@ -24,6 +27,7 @@ grit("net_internals_resources") {
grit("invalidations_resources") {
source = "invalidations_resources.grd"
+ defines = chrome_grit_defines
outputs = [
"grit/invalidations_resources.h",
"invalidations_resources.pak",
@@ -33,6 +37,7 @@ grit("invalidations_resources") {
grit("password_manager_internals_resources") {
source = "password_manager_internals_resources.grd"
+ defines = chrome_grit_defines
outputs = [
"grit/password_manager_internals_resources.h",
"password_manager_internals_resources.pak",
@@ -42,6 +47,7 @@ grit("password_manager_internals_resources") {
grit("signin_internals_resources") {
source = "signin_internals_resources.grd"
+ defines = chrome_grit_defines
outputs = [
"grit/signin_internals_resources.h",
"signin_internals_resources.pak",
@@ -51,6 +57,7 @@ grit("signin_internals_resources") {
grit("translate_internals_resources") {
source = "translate_internals_resources.grd"
+ defines = chrome_grit_defines
outputs = [
"grit/translate_internals_resources.h",
"translate_internals_resources.pak",
@@ -71,6 +78,7 @@ copy("extension_resource_demo") {
if (!is_ios) {
grit("component_extension_resources") {
source = "component_extension_resources.grd"
+ defines = chrome_grit_defines
outputs = [
"grit/component_extension_resources.h",
"grit/component_extension_resources_map.cc",
@@ -82,6 +90,7 @@ if (!is_ios) {
grit("settings_resources") {
source = "settings/settings_resources.grd"
+ defines = chrome_grit_defines
outputs = [
"grit/settings_resources.h",
"grit/settings_resources_map.cc",
@@ -93,6 +102,7 @@ if (!is_ios) {
grit("options_resources") {
source = "options_resources.grd"
+ defines = chrome_grit_defines
outputs = [
"grit/options_resources.h",
"options_resources.pak",
@@ -102,6 +112,7 @@ if (!is_ios) {
grit("options_test_resources") {
source = "options_test_resources.grd"
+ defines = chrome_grit_defines
outputs = [
"grit/options_test_resources.h",
"options_test_resources.pak",
@@ -111,6 +122,7 @@ if (!is_ios) {
grit("quota_internals_resources") {
source = "quota_internals_resources.grd"
+ defines = chrome_grit_defines
outputs = [
"grit/quota_internals_resources.h",
"quota_internals_resources.pak",
@@ -120,6 +132,7 @@ if (!is_ios) {
grit("sync_file_system_internals_resources") {
source = "sync_file_system_internals_resources.grd"
+ defines = chrome_grit_defines
outputs = [
"grit/sync_file_system_internals_resources.h",
"sync_file_system_internals_resources.pak",
diff --git a/chrome/browser/ui/BUILD.gn b/chrome/browser/ui/BUILD.gn
index be6d20f..e8124cc 100644
--- a/chrome/browser/ui/BUILD.gn
+++ b/chrome/browser/ui/BUILD.gn
@@ -5,6 +5,7 @@
import("//build/config/crypto.gni")
import("//build/config/features.gni")
import("//build/config/ui.gni")
+import("//chrome/common/features.gni")
gypi_values = exec_script("//build/gypi_to_gn.py",
[ rebase_path("../../chrome_browser_ui.gypi") ],
diff --git a/chrome/browser/ui/webui/options/content_settings_handler.cc b/chrome/browser/ui/webui/options/content_settings_handler.cc
index 10ce23a..787a884 100644
--- a/chrome/browser/ui/webui/options/content_settings_handler.cc
+++ b/chrome/browser/ui/webui/options/content_settings_handler.cc
@@ -29,6 +29,7 @@
#include "chrome/browser/ui/browser_list.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/extensions/manifest_handlers/app_launch_info.h"
+#include "chrome/common/features.h"
#include "chrome/common/pref_names.h"
#include "chrome/common/url_constants.h"
#include "chrome/grit/generated_resources.h"
@@ -451,7 +452,7 @@ void ContentSettingsHandler::GetLocalizedValues(
{"cookiesShowCookies", IDS_COOKIES_SHOW_COOKIES_BUTTON},
{"flashStorageSettings", IDS_FLASH_STORAGE_SETTINGS},
{"flashStorageUrl", IDS_FLASH_STORAGE_URL},
-#if defined(ENABLE_GOOGLE_NOW)
+#if BUILDFLAG(ENABLE_GOOGLE_NOW)
{"googleGeolocationAccessEnable",
IDS_GEOLOCATION_GOOGLE_ACCESS_ENABLE_CHKBOX},
#endif
diff --git a/chrome/browser/ui/webui/options/options_ui.cc b/chrome/browser/ui/webui/options/options_ui.cc
index e69c199..56e784c 100644
--- a/chrome/browser/ui/webui/options/options_ui.cc
+++ b/chrome/browser/ui/webui/options/options_ui.cc
@@ -47,6 +47,7 @@
#include "chrome/browser/ui/webui/options/startup_pages_handler.h"
#include "chrome/browser/ui/webui/options/sync_setup_handler.h"
#include "chrome/browser/ui/webui/theme_source.h"
+#include "chrome/common/features.h"
#include "chrome/common/url_constants.h"
#include "chrome/grit/generated_resources.h"
#include "chrome/grit/locale_settings.h"
@@ -100,7 +101,7 @@
#include "chrome/browser/ui/webui/options/certificate_manager_handler.h"
#endif
-#if defined(ENABLE_GOOGLE_NOW)
+#if BUILDFLAG(ENABLE_GOOGLE_NOW)
#include "chrome/browser/ui/webui/options/geolocation_options_handler.h"
#endif
@@ -279,7 +280,7 @@ OptionsUI::OptionsUI(content::WebUI* web_ui)
AddOptionsPageUIHandler(localized_strings, new CreateProfileHandler());
AddOptionsPageUIHandler(localized_strings, new EasyUnlockHandler());
AddOptionsPageUIHandler(localized_strings, new FontSettingsHandler());
-#if defined(ENABLE_GOOGLE_NOW)
+#if BUILDFLAG(ENABLE_GOOGLE_NOW)
AddOptionsPageUIHandler(localized_strings, new GeolocationOptionsHandler());
#endif
AddOptionsPageUIHandler(localized_strings, new options::HelpOverlayHandler());
diff --git a/chrome/chrome.gyp b/chrome/chrome.gyp
index cfd46cc..9495002 100644
--- a/chrome/chrome.gyp
+++ b/chrome/chrome.gyp
@@ -104,6 +104,7 @@
'chrome_browser_ui.gypi',
'chrome_common.gypi',
'chrome_installer_util.gypi',
+ 'chrome_features.gypi',
],
'conditions': [
['OS!="ios"', {
diff --git a/chrome/chrome_android.gypi b/chrome/chrome_android.gypi
index 9c8b394..e84068c 100644
--- a/chrome/chrome_android.gypi
+++ b/chrome/chrome_android.gypi
@@ -14,6 +14,7 @@
'chrome.gyp:browser',
'chrome.gyp:browser_ui',
'chrome.gyp:child',
+ 'chrome.gyp:chrome_common_features',
'chrome.gyp:plugin',
'chrome.gyp:renderer',
'chrome.gyp:utility',
diff --git a/chrome/chrome_browser.gypi b/chrome/chrome_browser.gypi
index cba3bcc..6653fee 100644
--- a/chrome/chrome_browser.gypi
+++ b/chrome/chrome_browser.gypi
@@ -3066,6 +3066,7 @@
# NOTE: New dependencies should generally be added in the OS!="ios"
# dependencies block below, rather than here.
'browser_ui',
+ 'chrome_common_features',
'chrome_resources.gyp:chrome_extra_resources',
'chrome_resources.gyp:chrome_resources',
'chrome_resources.gyp:chrome_strings',
diff --git a/chrome/chrome_browser_extensions.gypi b/chrome/chrome_browser_extensions.gypi
index 8c0ca4f..7b23685 100644
--- a/chrome/chrome_browser_extensions.gypi
+++ b/chrome/chrome_browser_extensions.gypi
@@ -956,6 +956,7 @@
# browser, then we can clean up these dependencies.
'dependencies': [
'browser/extensions/api/api_registration.gyp:chrome_api_registration',
+ 'chrome_common_features',
'chrome_resources.gyp:chrome_extra_resources',
'chrome_resources.gyp:chrome_resources',
'chrome_resources.gyp:chrome_strings',
diff --git a/chrome/chrome_child.gypi b/chrome/chrome_child.gypi
index 6464a39..95298fa 100644
--- a/chrome/chrome_child.gypi
+++ b/chrome/chrome_child.gypi
@@ -9,6 +9,7 @@
'type': 'static_library',
'variables': { 'enable_wexit_time_destructors': 1, },
'dependencies': [
+ 'chrome_common_features',
'../base/base.gyp:base',
'../content/content.gyp:content_child',
],
diff --git a/chrome/chrome_common.gypi b/chrome/chrome_common.gypi
index 1438853..babce65 100644
--- a/chrome/chrome_common.gypi
+++ b/chrome/chrome_common.gypi
@@ -297,6 +297,7 @@
# GN: //chrome/common:common
'target_name': 'common',
'type': 'static_library',
+ 'hard_dependency': 1, # Because of transitive dep on version_header.
'variables': {
'chrome_common_target': 1,
'enable_wexit_time_destructors': 1,
@@ -314,6 +315,7 @@
# TODO(gregoryd): chrome_resources and chrome_strings could be
# shared with the 64-bit target, but it does not work due to a gyp
# issue.
+ 'chrome_common_features',
'installer_util',
'safe_browsing_proto',
'<(DEPTH)/base/base.gyp:base',
@@ -564,6 +566,7 @@
'common/net/x509_certificate_model_openssl.cc',
],
'dependencies': [
+ 'chrome_common_features',
'<(DEPTH)/base/base.gyp:base',
'<(DEPTH)/chrome/chrome_resources.gyp:chrome_resources',
'<(DEPTH)/chrome/chrome_resources.gyp:chrome_strings',
@@ -653,5 +656,16 @@
'../third_party/mojo/mojo_public.gyp:mojo_cpp_bindings',
],
},
+ {
+ # GN version: //chrome/common:features
+ 'target_name': 'chrome_common_features',
+ 'includes': [ '../build/buildflag_header.gypi' ],
+ 'variables': {
+ 'buildflag_header_path': 'chrome/common/features.h',
+ 'buildflag_flags': [
+ 'ENABLE_GOOGLE_NOW=<(enable_google_now)',
+ ],
+ },
+ },
],
}
diff --git a/chrome/chrome_debugger.gypi b/chrome/chrome_debugger.gypi
index 31991c6..dae7b73 100644
--- a/chrome/chrome_debugger.gypi
+++ b/chrome/chrome_debugger.gypi
@@ -13,6 +13,7 @@
'../base/base.gyp:base',
'../content/content.gyp:content_browser',
'../net/net.gyp:net',
+ 'chrome_common_features',
'browser/devtools/webrtc_device_provider_resources.gyp:webrtc_device_provider_resources',
'browser/devtools/devtools_protocol_constants.gyp:devtools_protocol_constants',
],
diff --git a/chrome/chrome_exe.gypi b/chrome/chrome_exe.gypi
index f593901..286db96 100644
--- a/chrome/chrome_exe.gypi
+++ b/chrome/chrome_exe.gypi
@@ -46,7 +46,10 @@
# GN version: //chrome:chrome_initial
'target_name': 'chrome_initial',
'type': 'executable',
- 'dependencies' : [ '../chrome/common_constants.gyp:version_header', ],
+ 'dependencies' : [
+ '../chrome/common_constants.gyp:version_header',
+ 'chrome_common_features',
+ ],
# Name the exe chrome.exe, not chrome_initial.exe.
'product_name': 'chrome',
'mac_bundle': 1,
diff --git a/chrome/chrome_features.gypi b/chrome/chrome_features.gypi
new file mode 100644
index 0000000..a4d8756
--- /dev/null
+++ b/chrome/chrome_features.gypi
@@ -0,0 +1,31 @@
+# Copyright 2015 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.
+
+# This is the GYP equivalent of //chrome/common/features.gni.
+# Please keep in sync!
+
+{
+ 'variables': {
+ 'variables': {
+ # Conditional variables.
+ 'conditions': [
+ ['OS=="android" or OS=="ios"', {
+ 'enable_google_now%': 0,
+ }, {
+ 'enable_google_now%': 1,
+ }]
+ ],
+ },
+
+ # Anything in the conditions needs to be copied to the outer scope to be
+ # accessible.
+ 'enable_google_now%': '<(enable_google_now)',
+
+ # Grit defines based on the feature flags. These must be manually added to
+ # grit targets.
+ 'chrome_grit_defines': [
+ '-D', 'enable_google_now=<(enable_google_now)',
+ ]
+ },
+}
diff --git a/chrome/chrome_plugin.gypi b/chrome/chrome_plugin.gypi
index 718666c..418725b 100644
--- a/chrome/chrome_plugin.gypi
+++ b/chrome/chrome_plugin.gypi
@@ -9,6 +9,7 @@
'type': 'static_library',
'variables': { 'enable_wexit_time_destructors': 1, },
'dependencies': [
+ 'chrome_common_features',
'../base/base.gyp:base',
'../content/content.gyp:content_plugin',
'../gin/gin.gyp:gin',
diff --git a/chrome/chrome_renderer.gypi b/chrome/chrome_renderer.gypi
index b12ac52..b8b978b 100644
--- a/chrome/chrome_renderer.gypi
+++ b/chrome/chrome_renderer.gypi
@@ -237,6 +237,7 @@
'type': 'static_library',
'variables': { 'enable_wexit_time_destructors': 1, },
'dependencies': [
+ 'chrome_common_features',
'common',
'common_mojo_bindings',
'chrome_resources.gyp:chrome_resources',
diff --git a/chrome/chrome_resources.gyp b/chrome/chrome_resources.gyp
index 6edb819..85116d4 100644
--- a/chrome/chrome_resources.gyp
+++ b/chrome/chrome_resources.gyp
@@ -2,8 +2,14 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
{
+ 'includes': [
+ 'chrome_features.gypi',
+ ],
'variables': {
+ # Apply Chrome-specific grit settings to all grit actions in this file.
'grit_out_dir': '<(SHARED_INTERMEDIATE_DIR)/chrome',
+ 'grit_additional_defines': [ '<@(chrome_grit_defines)' ],
+
'additional_modules_list_file': '<(SHARED_INTERMEDIATE_DIR)/chrome/browser/internal/additional_modules_list.txt',
},
'targets': [
diff --git a/chrome/chrome_tests.gypi b/chrome/chrome_tests.gypi
index f3a92fd9..5b6e6a9 100644
--- a/chrome/chrome_tests.gypi
+++ b/chrome/chrome_tests.gypi
@@ -1617,6 +1617,7 @@
'type': 'executable',
'dependencies': [
'browser',
+ 'chrome_common_features',
'chrome_resources.gyp:chrome_resources',
'chrome_resources.gyp:chrome_strings',
'chrome_resources.gyp:packed_extra_resources',
@@ -2111,6 +2112,7 @@
'type': 'executable',
'dependencies': [
'browser',
+ 'chrome_common_features',
'chrome_resources.gyp:browser_tests_pak',
'chrome_resources.gyp:chrome_resources',
'chrome_resources.gyp:chrome_strings',
@@ -2655,6 +2657,7 @@
'type': 'executable',
'dependencies': [
'browser',
+ 'chrome_common_features',
'chrome_resources.gyp:chrome_resources',
'chrome_resources.gyp:chrome_strings',
'chrome_resources.gyp:packed_extra_resources',
diff --git a/chrome/chrome_tests_unit.gypi b/chrome/chrome_tests_unit.gypi
index 1dc2c8c..f43ce67 100644
--- a/chrome/chrome_tests_unit.gypi
+++ b/chrome/chrome_tests_unit.gypi
@@ -1658,6 +1658,7 @@
# NOTE: New dependencies should generally be added in the OS!="ios"
# dependencies block below, rather than here.
'browser',
+ 'chrome_common_features',
'chrome_resources.gyp:chrome_resources',
'chrome_resources.gyp:chrome_strings',
'chrome_resources.gyp:theme_resources',
@@ -2212,6 +2213,7 @@
'../ui/base/ui_base.gyp:ui_base_test_support',
'../ui/gfx/gfx.gyp:gfx_test_support',
'../ui/resources/ui_resources.gyp:ui_resources',
+ 'chrome_common_features',
'chrome_resources.gyp:chrome_resources',
'chrome_resources.gyp:chrome_strings',
],
diff --git a/chrome/chrome_utility.gypi b/chrome/chrome_utility.gypi
index d70f335..638ba4e 100644
--- a/chrome/chrome_utility.gypi
+++ b/chrome/chrome_utility.gypi
@@ -126,6 +126,7 @@
'../third_party/libxml/libxml.gyp:libxml',
'<(DEPTH)/chrome/chrome_resources.gyp:chrome_resources',
'<(DEPTH)/chrome/chrome_resources.gyp:chrome_strings',
+ 'chrome_common_features',
'common',
],
'include_dirs': [
diff --git a/chrome/common/BUILD.gn b/chrome/common/BUILD.gn
index bc89196..9b20bda 100644
--- a/chrome/common/BUILD.gn
+++ b/chrome/common/BUILD.gn
@@ -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/buildflag_header.gni")
+import("//chrome/common/features.gni")
import("//chrome/version.gni")
import("//mojo/public/tools/bindings/mojom.gni")
import("//tools/grit/grit_rule.gni")
@@ -36,6 +38,11 @@ if (enable_extensions) {
}
}
+buildflag_header("features") {
+ header = "features.h"
+ flags = [ "ENABLE_GOOGLE_NOW=$enable_google_now" ]
+}
+
# GYP version: chrome/chrome_common.gypi:common
static_library("common") {
sources = rebase_path(gypi_values.chrome_common_sources, ".", "//chrome")
@@ -47,6 +54,7 @@ static_library("common") {
]
public_deps = [
+ ":features",
"//base:base",
"//base:base_static",
"//base:i18n",
@@ -315,6 +323,7 @@ static_library("constants") {
"//content/public/common:result_codes",
]
deps = [
+ ":features",
":version_header",
"//base",
"//base/third_party/dynamic_annotations",
diff --git a/chrome/common/features.gni b/chrome/common/features.gni
new file mode 100644
index 0000000..2e92745c
--- /dev/null
+++ b/chrome/common/features.gni
@@ -0,0 +1,12 @@
+# Copyright 2015 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.
+
+# This is the GN version of //chrome/chrome_features.gypi.
+# Please keep in sync!
+
+declare_args() {
+ enable_google_now = !is_ios && !is_android
+}
+
+chrome_grit_defines = [ "enable_google_now=$enable_google_now" ]
diff --git a/chrome/common/pref_names.cc b/chrome/common/pref_names.cc
index f3bfd8e..d546cb0 100644
--- a/chrome/common/pref_names.cc
+++ b/chrome/common/pref_names.cc
@@ -5,6 +5,7 @@
#include "chrome/common/pref_names.h"
#include "base/basictypes.h"
+#include "chrome/common/features.h"
#include "chrome/common/pref_font_webkit_names.h"
namespace prefs {
@@ -1557,7 +1558,7 @@ const char kGeolocationAccessToken[] = "geolocation.access_token";
const char kGeolocationEnabled[] = "geolocation.enabled";
#endif
-#if defined(ENABLE_GOOGLE_NOW)
+#if BUILDFLAG(ENABLE_GOOGLE_NOW)
// Boolean that is true when Google services can use the user's location.
const char kGoogleGeolocationAccessEnabled[] =
"googlegeolocationaccess.enabled";
diff --git a/chrome/common/pref_names.h b/chrome/common/pref_names.h
index f82326b..79e1d12a 100644
--- a/chrome/common/pref_names.h
+++ b/chrome/common/pref_names.h
@@ -10,6 +10,7 @@
#include <stddef.h>
#include "build/build_config.h"
+#include "chrome/common/features.h"
namespace prefs {
@@ -557,7 +558,7 @@ extern const char kGeolocationAccessToken[];
extern const char kGeolocationEnabled[];
#endif
-#if defined(ENABLE_GOOGLE_NOW)
+#if BUILDFLAG(ENABLE_GOOGLE_NOW)
extern const char kGoogleGeolocationAccessEnabled[];
#endif
extern const char kGoogleNowLauncherEnabled[];
diff --git a/chrome/common_constants.gyp b/chrome/common_constants.gyp
index 134878e..c69a075 100644
--- a/chrome/common_constants.gyp
+++ b/chrome/common_constants.gyp
@@ -72,6 +72,7 @@
# GN version: //chrome/common:constants
'target_name': 'common_constants',
'type': 'static_library',
+ 'hard_dependency': 1, # Because of transitive dep on version_header.
'sources': [
'<@(common_constants_sources)'
],
diff --git a/tools/grit/grit/util.py b/tools/grit/grit/util.py
index b958bc2..93dce26 100755
--- a/tools/grit/grit/util.py
+++ b/tools/grit/grit/util.py
@@ -483,7 +483,8 @@ def ParseDefine(define):
'''Parses a define argument and returns the name and value.
The format is either "NAME=VAL" or "NAME", using True as the default value.
- Values of "1" and "0" are transformed to True and False respectively.
+ Values of "1"/"true" and "0"/"false" are transformed to True and False
+ respectively.
Args:
define: a string of the form "NAME=VAL" or "NAME".
@@ -497,8 +498,8 @@ def ParseDefine(define):
val = True
if len(parts) > 1:
val = parts[1]
- if val == "1": val = True
- elif val == "0": val = False
+ if val == "1" or val == "true": val = True
+ elif val == "0" or val == "false": val = False
return (name, val)
diff --git a/tools/grit/grit_rule.gni b/tools/grit/grit_rule.gni
index 083e3d9..f60d8fa 100644
--- a/tools/grit/grit_rule.gni
+++ b/tools/grit/grit_rule.gni
@@ -244,13 +244,6 @@ if (enable_settings_app) {
"enable_settings_app",
]
}
-if (enable_google_now) {
- grit_defines += [
- "-D",
- "enable_google_now",
- ]
-}
-
if (enable_webrtc) {
grit_defines += [
"-D",