0

Convert RLZ to a buildflag header

Creates a new directory rlz/features for the gni file and the buildflag_header target.

Updates callers to depend on the new target and use the new flags.

Review-Url: https://codereview.chromium.org/2570573002
Cr-Commit-Position: refs/heads/master@{#438026}
This commit is contained in:
brettw
2016-12-12 19:28:37 -08:00
committed by Commit bot
parent 6582d0b551
commit 8fb852d9e6
33 changed files with 111 additions and 59 deletions

@@ -136,9 +136,6 @@ config("feature_flags") {
if (!enable_nacl) { if (!enable_nacl) {
defines += [ "DISABLE_NACL" ] defines += [ "DISABLE_NACL" ]
} }
if (enable_rlz) {
defines += [ "ENABLE_RLZ" ]
}
if (enable_wayland_server) { if (enable_wayland_server) {
defines += [ "ENABLE_WAYLAND_SERVER=1" ] defines += [ "ENABLE_WAYLAND_SERVER=1" ]
} }

@@ -79,11 +79,6 @@ declare_args() {
# Additional dependent variables ----------------------------------------------- # Additional dependent variables -----------------------------------------------
# Whether we are using the rlz library or not. Platforms like Android send
# rlz codes for searches but do not use the library.
enable_rlz_support = is_win || is_mac || is_ios || is_chromeos
enable_rlz = is_chrome_branded && enable_rlz_support
# Chrome OS: whether to also build the upcoming version of # Chrome OS: whether to also build the upcoming version of
# ChromeVox, which can then be enabled via a command-line switch. # ChromeVox, which can then be enabled via a command-line switch.
enable_chromevox_next = false enable_chromevox_next = false

@@ -15,6 +15,7 @@ import("//media/media_options.gni")
import("//net/features.gni") import("//net/features.gni")
import("//ppapi/features/features.gni") import("//ppapi/features/features.gni")
import("//printing/features/features.gni") import("//printing/features/features.gni")
import("//rlz/features/features.gni")
import("//sandbox/features.gni") import("//sandbox/features.gni")
import("//third_party/protobuf/proto_library.gni") import("//third_party/protobuf/proto_library.gni")
import("//ui/base/ui_features.gni") import("//ui/base/ui_features.gni")
@@ -1510,6 +1511,7 @@ split_static_library("browser") {
"//net:net_with_v8", "//net:net_with_v8",
"//ppapi/features", "//ppapi/features",
"//printing/features", "//printing/features",
"//rlz/features",
"//services/image_decoder/public/cpp", "//services/image_decoder/public/cpp",
"//services/service_manager/public/cpp", "//services/service_manager/public/cpp",
"//skia", "//skia",

@@ -38,6 +38,7 @@
#include "content/public/browser/render_process_host.h" #include "content/public/browser/render_process_host.h"
#include "content/public/browser/tracing_controller.h" #include "content/public/browser/tracing_controller.h"
#include "printing/features/features.h" #include "printing/features/features.h"
#include "rlz/features/features.h"
#if defined(OS_WIN) #if defined(OS_WIN)
#include "chrome/browser/first_run/upgrade_util_win.h" #include "chrome/browser/first_run/upgrade_util_win.h"
@@ -52,7 +53,7 @@
#include "chrome/browser/background/background_mode_manager.h" #include "chrome/browser/background/background_mode_manager.h"
#endif #endif
#if defined(ENABLE_RLZ) #if BUILDFLAG(ENABLE_RLZ)
#include "components/rlz/rlz_tracker.h" #include "components/rlz/rlz_tracker.h"
#endif #endif
@@ -175,7 +176,7 @@ bool ShutdownPreThreadsStop() {
prefs->CommitPendingWrite(); prefs->CommitPendingWrite();
#if defined(ENABLE_RLZ) #if BUILDFLAG(ENABLE_RLZ)
// Cleanup any statics created by RLZ. Must be done before NotificationService // Cleanup any statics created by RLZ. Must be done before NotificationService
// is destroyed. // is destroyed.
rlz::RLZTracker::CleanupRlz(); rlz::RLZTracker::CleanupRlz();

@@ -163,6 +163,7 @@
#include "net/http/http_stream_factory.h" #include "net/http/http_stream_factory.h"
#include "net/url_request/url_request.h" #include "net/url_request/url_request.h"
#include "printing/features/features.h" #include "printing/features/features.h"
#include "rlz/features/features.h"
#include "ui/base/l10n/l10n_util.h" #include "ui/base/l10n/l10n_util.h"
#include "ui/base/layout.h" #include "ui/base/layout.h"
#include "ui/base/material_design/material_design_controller.h" #include "ui/base/material_design/material_design_controller.h"
@@ -246,10 +247,10 @@
#include "printing/printed_document.h" #include "printing/printed_document.h"
#endif // BUILDFLAG(ENABLE_PRINT_PREVIEW) && !defined(OFFICIAL_BUILD) #endif // BUILDFLAG(ENABLE_PRINT_PREVIEW) && !defined(OFFICIAL_BUILD)
#if defined(ENABLE_RLZ) #if BUILDFLAG(ENABLE_RLZ)
#include "chrome/browser/rlz/chrome_rlz_tracker_delegate.h" #include "chrome/browser/rlz/chrome_rlz_tracker_delegate.h"
#include "components/rlz/rlz_tracker.h" #include "components/rlz/rlz_tracker.h"
#endif // defined(ENABLE_RLZ) #endif // BUILDFLAG(ENABLE_RLZ)
#if BUILDFLAG(ENABLE_WEBRTC) #if BUILDFLAG(ENABLE_WEBRTC)
#include "chrome/browser/media/webrtc/webrtc_log_util.h" #include "chrome/browser/media/webrtc/webrtc_log_util.h"
@@ -1708,7 +1709,7 @@ int ChromeBrowserMainParts::PreMainMessageLoopRunImpl() {
} }
#endif // defined(OS_WIN) #endif // defined(OS_WIN)
#if defined(ENABLE_RLZ) && !defined(OS_CHROMEOS) #if BUILDFLAG(ENABLE_RLZ) && !defined(OS_CHROMEOS)
// Init the RLZ library. This just binds the dll and schedules a task on the // Init the RLZ library. This just binds the dll and schedules a task on the
// file thread to be run sometime later. If this is the first run we record // file thread to be run sometime later. If this is the first run we record
// the installation event. // the installation event.
@@ -1725,7 +1726,7 @@ int ChromeBrowserMainParts::PreMainMessageLoopRunImpl() {
ChromeRLZTrackerDelegate::IsGoogleDefaultSearch(profile_), ChromeRLZTrackerDelegate::IsGoogleDefaultSearch(profile_),
ChromeRLZTrackerDelegate::IsGoogleHomepage(profile_), ChromeRLZTrackerDelegate::IsGoogleHomepage(profile_),
ChromeRLZTrackerDelegate::IsGoogleInStartpages(profile_)); ChromeRLZTrackerDelegate::IsGoogleInStartpages(profile_));
#endif // defined(ENABLE_RLZ) && !defined(OS_CHROMEOS) #endif // BUILDFLAG(ENABLE_RLZ) && !defined(OS_CHROMEOS)
// Configure modules that need access to resources. // Configure modules that need access to resources.
net::NetModule::SetResourceProvider(chrome_common_net::NetResourceProvider); net::NetModule::SetResourceProvider(chrome_common_net::NetResourceProvider);

@@ -148,12 +148,13 @@
#include "net/url_request/url_request.h" #include "net/url_request/url_request.h"
#include "net/url_request/url_request_context_getter.h" #include "net/url_request/url_request_context_getter.h"
#include "printing/backend/print_backend.h" #include "printing/backend/print_backend.h"
#include "rlz/features/features.h"
#include "ui/base/ime/chromeos/ime_keyboard.h" #include "ui/base/ime/chromeos/ime_keyboard.h"
#include "ui/base/ime/chromeos/input_method_manager.h" #include "ui/base/ime/chromeos/input_method_manager.h"
#include "ui/base/touch/touch_device.h" #include "ui/base/touch/touch_device.h"
#include "ui/events/event_utils.h" #include "ui/events/event_utils.h"
#if defined(ENABLE_RLZ) #if BUILDFLAG(ENABLE_RLZ)
#include "components/rlz/rlz_tracker.h" #include "components/rlz/rlz_tracker.h"
#endif #endif

@@ -27,8 +27,9 @@
#include "google_apis/gaia/gaia_urls.h" #include "google_apis/gaia/gaia_urls.h"
#include "net/test/embedded_test_server/embedded_test_server.h" #include "net/test/embedded_test_server/embedded_test_server.h"
#include "net/test/embedded_test_server/http_response.h" #include "net/test/embedded_test_server/http_response.h"
#include "rlz/features/features.h"
#if defined(ENABLE_RLZ) #if BUILDFLAG(ENABLE_RLZ)
#include "components/rlz/rlz_tracker.h" #include "components/rlz/rlz_tracker.h"
#endif #endif
@@ -36,7 +37,7 @@ namespace chromeos {
namespace { namespace {
#if defined(ENABLE_RLZ) #if BUILDFLAG(ENABLE_RLZ)
void GetAccessPointRlzInBackgroundThread(rlz_lib::AccessPoint point, void GetAccessPointRlzInBackgroundThread(rlz_lib::AccessPoint point,
base::string16* rlz) { base::string16* rlz) {
ASSERT_FALSE(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); ASSERT_FALSE(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
@@ -81,7 +82,7 @@ class LoginUtilsTest : public OobeBaseTest {
DISALLOW_COPY_AND_ASSIGN(LoginUtilsTest); DISALLOW_COPY_AND_ASSIGN(LoginUtilsTest);
}; };
#if defined(ENABLE_RLZ) #if BUILDFLAG(ENABLE_RLZ)
IN_PROC_BROWSER_TEST_F(LoginUtilsTest, RlzInitialized) { IN_PROC_BROWSER_TEST_F(LoginUtilsTest, RlzInitialized) {
WaitForSigninScreen(); WaitForSigninScreen();

@@ -114,11 +114,12 @@
#include "content/public/browser/storage_partition.h" #include "content/public/browser/storage_partition.h"
#include "content/public/common/content_switches.h" #include "content/public/common/content_switches.h"
#include "net/cert/sth_distributor.h" #include "net/cert/sth_distributor.h"
#include "rlz/features/features.h"
#include "ui/base/ime/chromeos/input_method_descriptor.h" #include "ui/base/ime/chromeos/input_method_descriptor.h"
#include "ui/base/ime/chromeos/input_method_manager.h" #include "ui/base/ime/chromeos/input_method_manager.h"
#include "url/gurl.h" #include "url/gurl.h"
#if defined(ENABLE_RLZ) #if BUILDFLAG(ENABLE_RLZ)
#include "chrome/browser/rlz/chrome_rlz_tracker_delegate.h" #include "chrome/browser/rlz/chrome_rlz_tracker_delegate.h"
#include "components/rlz/rlz_tracker.h" #include "components/rlz/rlz_tracker.h"
#endif #endif
@@ -242,7 +243,7 @@ void InitLocaleAndInputMethodsForNewUser(
prefs->SetBoolean(prefs::kLanguageShouldMergeInputMethods, true); prefs->SetBoolean(prefs::kLanguageShouldMergeInputMethods, true);
} }
#if defined(ENABLE_RLZ) #if BUILDFLAG(ENABLE_RLZ)
// Flag file that disables RLZ tracking, when present. // Flag file that disables RLZ tracking, when present.
const base::FilePath::CharType kRLZDisabledFlagName[] = const base::FilePath::CharType kRLZDisabledFlagName[] =
FILE_PATH_LITERAL(".rlz_disabled"); FILE_PATH_LITERAL(".rlz_disabled");
@@ -555,7 +556,7 @@ bool UserSessionManager::UserSessionsRestoreInProgress() const {
} }
void UserSessionManager::InitRlz(Profile* profile) { void UserSessionManager::InitRlz(Profile* profile) {
#if defined(ENABLE_RLZ) #if BUILDFLAG(ENABLE_RLZ)
if (!g_browser_process->local_state()->HasPrefPath(prefs::kRLZBrand)) { if (!g_browser_process->local_state()->HasPrefPath(prefs::kRLZBrand)) {
// Read brand code asynchronously from an OEM data and repost ourselves. // Read brand code asynchronously from an OEM data and repost ourselves.
google_brand::chromeos::InitBrand( google_brand::chromeos::InitBrand(
@@ -1354,7 +1355,7 @@ void UserSessionManager::RestoreAuthSessionImpl(
} }
void UserSessionManager::InitRlzImpl(Profile* profile, bool disabled) { void UserSessionManager::InitRlzImpl(Profile* profile, bool disabled) {
#if defined(ENABLE_RLZ) #if BUILDFLAG(ENABLE_RLZ)
PrefService* local_state = g_browser_process->local_state(); PrefService* local_state = g_browser_process->local_state();
if (disabled) { if (disabled) {
// Empty brand code means an organic install (no RLZ pings are sent). // Empty brand code means an organic install (no RLZ pings are sent).

@@ -7,6 +7,7 @@ import("//build/config/ui.gni")
import("//chrome/common/features.gni") import("//chrome/common/features.gni")
import("//extensions/features/features.gni") import("//extensions/features/features.gni")
import("//media/media_options.gni") import("//media/media_options.gni")
import("//rlz/features/features.gni")
assert(enable_extensions) assert(enable_extensions)
@@ -897,6 +898,7 @@ static_library("extensions") {
"//net", "//net",
"//ppapi/features", "//ppapi/features",
"//printing/features", "//printing/features",
"//rlz/features",
"//skia", "//skia",
"//sql", "//sql",
"//storage/browser", "//storage/browser",

@@ -25,8 +25,9 @@
#include "base/threading/thread_restrictions.h" #include "base/threading/thread_restrictions.h"
#include "base/win/windows_version.h" #include "base/win/windows_version.h"
#include "content/public/browser/browser_thread.h" #include "content/public/browser/browser_thread.h"
#include "rlz/features/features.h"
#if defined(ENABLE_RLZ) #if BUILDFLAG(ENABLE_RLZ)
#include "rlz/lib/machine_id.h" #include "rlz/lib/machine_id.h"
#endif #endif
@@ -183,13 +184,13 @@ void GetMacAddress(const IsValidMacAddressCallback& is_valid_mac_address,
} }
std::string GetRlzMachineId() { std::string GetRlzMachineId() {
#if defined(ENABLE_RLZ) #if BUILDFLAG(ENABLE_RLZ)
std::string machine_id; std::string machine_id;
if (!rlz_lib::GetMachineId(&machine_id)) if (!rlz_lib::GetMachineId(&machine_id))
return ""; return std::string();
return machine_id; return machine_id;
#else #else
return ""; return std::string();
#endif #endif
} }

@@ -5,9 +5,10 @@
#include "build/build_config.h" #include "build/build_config.h"
#include "chrome/browser/apps/app_browsertest_util.h" #include "chrome/browser/apps/app_browsertest_util.h"
#include "extensions/test/extension_test_message_listener.h" #include "extensions/test/extension_test_message_listener.h"
#include "rlz/features/features.h"
// Supported on all platforms, but on Windows only if RLZ is enabled. // Supported on all platforms, but on Windows only if RLZ is enabled.
#if !defined(OS_WIN) || defined(ENABLE_RLZ) #if !defined(OS_WIN) || BUILDFLAG(ENABLE_RLZ)
class MusicManagerPrivateTest : public extensions::PlatformAppBrowserTest { class MusicManagerPrivateTest : public extensions::PlatformAppBrowserTest {
}; };

@@ -34,9 +34,10 @@
#include "net/url_request/url_fetcher_delegate.h" #include "net/url_request/url_fetcher_delegate.h"
#include "net/url_request/url_request_context_getter.h" #include "net/url_request/url_request_context_getter.h"
#include "net/url_request/url_request_status.h" #include "net/url_request/url_request_status.h"
#include "rlz/features/features.h"
#include "url/gurl.h" #include "url/gurl.h"
#if defined(ENABLE_RLZ) #if BUILDFLAG(ENABLE_RLZ)
#include "rlz/lib/machine_id.h" #include "rlz/lib/machine_id.h"
#endif #endif
@@ -84,7 +85,7 @@ GURL GetBackendUrl() {
// |result|. // |result|.
bool HashWithMachineId(const std::string& salt, std::string* result) { bool HashWithMachineId(const std::string& salt, std::string* result) {
std::string machine_id; std::string machine_id;
#if defined(ENABLE_RLZ) #if BUILDFLAG(ENABLE_RLZ)
if (!rlz_lib::GetMachineId(&machine_id)) if (!rlz_lib::GetMachineId(&machine_id))
return false; return false;
#else #else

@@ -59,6 +59,7 @@
#include "content/public/browser/browser_context.h" #include "content/public/browser/browser_context.h"
#include "content/public/browser/browser_thread.h" #include "content/public/browser/browser_thread.h"
#include "extensions/features/features.h" #include "extensions/features/features.h"
#include "rlz/features/features.h"
#include "sql/error_delegate_util.h" #include "sql/error_delegate_util.h"
#include "ui/base/resource/resource_bundle.h" #include "ui/base/resource/resource_bundle.h"
@@ -72,9 +73,9 @@
#if defined(OS_WIN) #if defined(OS_WIN)
#include "base/win/win_util.h" #include "base/win/win_util.h"
#if defined(ENABLE_RLZ) #if BUILDFLAG(ENABLE_RLZ)
#include "rlz/lib/machine_id.h" #include "rlz/lib/machine_id.h"
#endif // defined(ENABLE_RLZ) #endif // BUILDFLAG(ENABLE_RLZ)
#endif // defined(OS_WIN) #endif // defined(OS_WIN)
using content::BrowserContext; using content::BrowserContext;
@@ -399,7 +400,7 @@ void HandleReadError(const base::FilePath& pref_filename,
std::unique_ptr<ProfilePrefStoreManager> CreateProfilePrefStoreManager( std::unique_ptr<ProfilePrefStoreManager> CreateProfilePrefStoreManager(
const base::FilePath& profile_path) { const base::FilePath& profile_path) {
std::string device_id; std::string device_id;
#if defined(OS_WIN) && defined(ENABLE_RLZ) #if defined(OS_WIN) && BUILDFLAG(ENABLE_RLZ)
// This is used by // This is used by
// chrome/browser/extensions/api/music_manager_private/device_id_win.cc // chrome/browser/extensions/api/music_manager_private/device_id_win.cc
// but that API is private (http://crbug.com/276485) and other platforms are // but that API is private (http://crbug.com/276485) and other platforms are

@@ -11,9 +11,6 @@
#include "chrome/browser/profiles/profile.h" #include "chrome/browser/profiles/profile.h"
#include "chrome/common/pref_names.h" #include "chrome/common/pref_names.h"
#include "components/prefs/pref_service.h" #include "components/prefs/pref_service.h"
#if defined(OS_CHROMEOS)
#include "chromeos/cryptohome/system_salt_getter.h"
#endif
#include "components/pref_registry/pref_registry_syncable.h" #include "components/pref_registry/pref_registry_syncable.h"
#include "content/public/browser/browser_context.h" #include "content/public/browser/browser_context.h"
#include "content/public/browser/browser_ppapi_host.h" #include "content/public/browser/browser_ppapi_host.h"
@@ -23,7 +20,13 @@
#include "crypto/random.h" #include "crypto/random.h"
#include "crypto/sha2.h" #include "crypto/sha2.h"
#include "ppapi/c/pp_errors.h" #include "ppapi/c/pp_errors.h"
#if defined(ENABLE_RLZ) #include "rlz/features/features.h"
#if defined(OS_CHROMEOS)
#include "chromeos/cryptohome/system_salt_getter.h"
#endif
#if BUILDFLAG(ENABLE_RLZ)
#include "rlz/lib/machine_id.h" #include "rlz/lib/machine_id.h"
#endif #endif
@@ -41,7 +44,7 @@ const uint32_t kSaltLength = 32;
void GetMachineIDAsync( void GetMachineIDAsync(
const base::Callback<void(const std::string&)>& callback) { const base::Callback<void(const std::string&)>& callback) {
#if defined(OS_WIN) && defined(ENABLE_RLZ) #if defined(OS_WIN) && BUILDFLAG(ENABLE_RLZ)
std::string result; std::string result;
rlz_lib::GetMachineId(&result); rlz_lib::GetMachineId(&result);
callback.Run(result); callback.Run(result);

@@ -23,8 +23,9 @@
#include "components/search_engines/default_search_manager.h" #include "components/search_engines/default_search_manager.h"
#include "components/search_engines/search_engines_pref_names.h" #include "components/search_engines/search_engines_pref_names.h"
#include "components/search_engines/template_url_service.h" #include "components/search_engines/template_url_service.h"
#include "rlz/features/features.h"
#if defined(ENABLE_RLZ) #if BUILDFLAG(ENABLE_RLZ)
#include "components/rlz/rlz_tracker.h" #include "components/rlz/rlz_tracker.h"
#endif #endif
@@ -43,7 +44,7 @@ TemplateURLServiceFactory* TemplateURLServiceFactory::GetInstance() {
std::unique_ptr<KeyedService> TemplateURLServiceFactory::BuildInstanceFor( std::unique_ptr<KeyedService> TemplateURLServiceFactory::BuildInstanceFor(
content::BrowserContext* context) { content::BrowserContext* context) {
base::Closure dsp_change_callback; base::Closure dsp_change_callback;
#if defined(ENABLE_RLZ) #if BUILDFLAG(ENABLE_RLZ)
dsp_change_callback = base::Bind( dsp_change_callback = base::Bind(
base::IgnoreResult(&rlz::RLZTracker::RecordProductEvent), rlz_lib::CHROME, base::IgnoreResult(&rlz::RLZTracker::RecordProductEvent), rlz_lib::CHROME,
rlz::RLZTracker::ChromeOmnibox(), rlz_lib::SET_TO_GOOGLE); rlz::RLZTracker::ChromeOmnibox(), rlz_lib::SET_TO_GOOGLE);

@@ -25,10 +25,11 @@
#include "components/search/search.h" #include "components/search/search.h"
#include "components/version_info/version_info.h" #include "components/version_info/version_info.h"
#include "content/public/browser/browser_thread.h" #include "content/public/browser/browser_thread.h"
#include "rlz/features/features.h"
#include "ui/base/device_form_factor.h" #include "ui/base/device_form_factor.h"
#include "url/gurl.h" #include "url/gurl.h"
#if defined(ENABLE_RLZ) #if BUILDFLAG(ENABLE_RLZ)
#include "components/rlz/rlz_tracker.h" #include "components/rlz/rlz_tracker.h"
#endif #endif
@@ -74,7 +75,7 @@ base::string16 UIThreadSearchTermsData::GetRlzParameterValue(
DCHECK(!BrowserThread::IsThreadInitialized(BrowserThread::UI) || DCHECK(!BrowserThread::IsThreadInitialized(BrowserThread::UI) ||
BrowserThread::CurrentlyOn(BrowserThread::UI)); BrowserThread::CurrentlyOn(BrowserThread::UI));
base::string16 rlz_string; base::string16 rlz_string;
#if defined(ENABLE_RLZ) #if BUILDFLAG(ENABLE_RLZ)
// For organic brandcodes do not use rlz at all. Empty brandcode usually // For organic brandcodes do not use rlz at all. Empty brandcode usually
// means a chromium install. This is ok. // means a chromium install. This is ok.
std::string brand; std::string brand;

@@ -12,6 +12,7 @@ import("//extensions/features/features.gni")
import("//media/media_options.gni") import("//media/media_options.gni")
import("//ppapi/features/features.gni") import("//ppapi/features/features.gni")
import("//printing/features/features.gni") import("//printing/features/features.gni")
import("//rlz/features/features.gni")
import("//ui/base/ui_features.gni") import("//ui/base/ui_features.gni")
config("ui_warnings") { config("ui_warnings") {
@@ -572,6 +573,7 @@ split_static_library("ui") {
"//net:net_with_v8", "//net:net_with_v8",
"//ppapi/features", "//ppapi/features",
"//printing/features", "//printing/features",
"//rlz/features",
"//services/service_manager/runner/common", "//services/service_manager/runner/common",
"//skia", "//skia",
"//storage/browser", "//storage/browser",

@@ -22,13 +22,14 @@
#include "extensions/common/manifest_handlers/options_page_info.h" #include "extensions/common/manifest_handlers/options_page_info.h"
#include "extensions/common/manifest_url_handlers.h" #include "extensions/common/manifest_url_handlers.h"
#include "net/base/url_util.h" #include "net/base/url_util.h"
#include "rlz/features/features.h"
#include "ui/app_list/app_list_folder_item.h" #include "ui/app_list/app_list_folder_item.h"
#include "ui/app_list/app_list_item.h" #include "ui/app_list/app_list_item.h"
#include "ui/app_list/app_list_model.h" #include "ui/app_list/app_list_model.h"
#include "ui/app_list/app_list_switches.h" #include "ui/app_list/app_list_switches.h"
#include "ui/gfx/geometry/rect.h" #include "ui/gfx/geometry/rect.h"
#if defined(ENABLE_RLZ) #if BUILDFLAG(ENABLE_RLZ)
#include "components/rlz/rlz_tracker.h" // nogncheck #include "components/rlz/rlz_tracker.h" // nogncheck
#endif #endif
@@ -203,7 +204,7 @@ void AppListControllerDelegate::GetApps(Profile* profile,
} }
void AppListControllerDelegate::OnSearchStarted() { void AppListControllerDelegate::OnSearchStarted() {
#if defined(ENABLE_RLZ) #if BUILDFLAG(ENABLE_RLZ)
rlz::RLZTracker::RecordAppListSearch(); rlz::RLZTracker::RecordAppListSearch();
#endif #endif
} }

@@ -87,6 +87,7 @@
#include "extensions/features/features.h" #include "extensions/features/features.h"
#include "net/base/escape.h" #include "net/base/escape.h"
#include "printing/features/features.h" #include "printing/features/features.h"
#include "rlz/features/features.h"
#include "ui/events/keycodes/keyboard_codes.h" #include "ui/events/keycodes/keyboard_codes.h"
#if BUILDFLAG(ENABLE_EXTENSIONS) #if BUILDFLAG(ENABLE_EXTENSIONS)
@@ -110,7 +111,7 @@
#endif // BUILDFLAG(ENABLE_PRINT_PREVIEW) #endif // BUILDFLAG(ENABLE_PRINT_PREVIEW)
#endif // BUILDFLAG(ENABLE_PRINTING) #endif // BUILDFLAG(ENABLE_PRINTING)
#if defined(ENABLE_RLZ) #if BUILDFLAG(ENABLE_RLZ)
#include "components/rlz/rlz_tracker.h" // nogncheck #include "components/rlz/rlz_tracker.h" // nogncheck
#endif #endif
@@ -473,7 +474,7 @@ void Home(Browser* browser, WindowOpenDisposition disposition) {
content::RecordAction(UserMetricsAction("Home")); content::RecordAction(UserMetricsAction("Home"));
std::string extra_headers; std::string extra_headers;
#if defined(ENABLE_RLZ) #if BUILDFLAG(ENABLE_RLZ)
// If the home page is a Google home page, add the RLZ header to the request. // If the home page is a Google home page, add the RLZ header to the request.
PrefService* pref_service = browser->profile()->GetPrefs(); PrefService* pref_service = browser->profile()->GetPrefs();
if (pref_service) { if (pref_service) {
@@ -483,7 +484,7 @@ void Home(Browser* browser, WindowOpenDisposition disposition) {
rlz::RLZTracker::ChromeHomePage()); rlz::RLZTracker::ChromeHomePage());
} }
} }
#endif // defined(ENABLE_RLZ) #endif // BUILDFLAG(ENABLE_RLZ)
GURL url = browser->profile()->GetHomePage(); GURL url = browser->profile()->GetHomePage();

@@ -103,6 +103,7 @@
#include "extensions/common/extension.h" #include "extensions/common/extension.h"
#include "extensions/common/extension_set.h" #include "extensions/common/extension_set.h"
#include "net/base/network_change_notifier.h" #include "net/base/network_change_notifier.h"
#include "rlz/features/features.h"
#include "ui/base/l10n/l10n_util.h" #include "ui/base/l10n/l10n_util.h"
#if defined(OS_MACOSX) #if defined(OS_MACOSX)
@@ -117,7 +118,7 @@
#include "chrome/browser/shell_integration_win.h" #include "chrome/browser/shell_integration_win.h"
#endif #endif
#if defined(ENABLE_RLZ) #if BUILDFLAG(ENABLE_RLZ)
#include "components/rlz/rlz_tracker.h" // nogncheck #include "components/rlz/rlz_tracker.h" // nogncheck
#endif #endif
@@ -471,12 +472,12 @@ Browser* StartupBrowserCreatorImpl::OpenTabsInBrowser(Browser* browser,
: WindowOpenDisposition::NEW_BACKGROUND_TAB; : WindowOpenDisposition::NEW_BACKGROUND_TAB;
params.tabstrip_add_types = add_types; params.tabstrip_add_types = add_types;
#if defined(ENABLE_RLZ) #if BUILDFLAG(ENABLE_RLZ)
if (process_startup && google_util::IsGoogleHomePageUrl(tabs[i].url)) { if (process_startup && google_util::IsGoogleHomePageUrl(tabs[i].url)) {
params.extra_headers = rlz::RLZTracker::GetAccessPointHttpHeader( params.extra_headers = rlz::RLZTracker::GetAccessPointHttpHeader(
rlz::RLZTracker::ChromeHomePage()); rlz::RLZTracker::ChromeHomePage());
} }
#endif // defined(ENABLE_RLZ) #endif // BUILDFLAG(ENABLE_RLZ)
chrome::Navigate(&params); chrome::Navigate(&params);

@@ -23,6 +23,7 @@
#include "components/login/localized_values_builder.h" #include "components/login/localized_values_builder.h"
#include "components/strings/grit/components_strings.h" #include "components/strings/grit/components_strings.h"
#include "content/public/browser/web_contents.h" #include "content/public/browser/web_contents.h"
#include "rlz/features/features.h"
#include "ui/base/l10n/l10n_util.h" #include "ui/base/l10n/l10n_util.h"
#include "ui/views/widget/widget.h" #include "ui/views/widget/widget.h"
#include "url/gurl.h" #include "url/gurl.h"
@@ -131,7 +132,7 @@ void EulaScreenHandler::DeclareLocalizedValues(
builder->Add("eulaTpmBusy", IDS_EULA_TPM_BUSY); builder->Add("eulaTpmBusy", IDS_EULA_TPM_BUSY);
builder->Add("eulaSystemInstallationSettingsOkButton", IDS_OK); builder->Add("eulaSystemInstallationSettingsOkButton", IDS_OK);
builder->Add("termsOfServiceLoading", IDS_TERMS_OF_SERVICE_SCREEN_LOADING); builder->Add("termsOfServiceLoading", IDS_TERMS_OF_SERVICE_SCREEN_LOADING);
#if defined(ENABLE_RLZ) #if BUILDFLAG(ENABLE_RLZ)
builder->AddF("eulaRlzDesc", builder->AddF("eulaRlzDesc",
IDS_EULA_RLZ_DESCRIPTION, IDS_EULA_RLZ_DESCRIPTION,
IDS_SHORT_PRODUCT_NAME, IDS_SHORT_PRODUCT_NAME,
@@ -161,7 +162,7 @@ void EulaScreenHandler::DeclareJSCallbacks() {
} }
void EulaScreenHandler::GetAdditionalParameters(base::DictionaryValue* dict) { void EulaScreenHandler::GetAdditionalParameters(base::DictionaryValue* dict) {
#if defined(ENABLE_RLZ) #if BUILDFLAG(ENABLE_RLZ)
dict->SetString("rlzEnabled", "enabled"); dict->SetString("rlzEnabled", "enabled");
#else #else
dict->SetString("rlzEnabled", "disabled"); dict->SetString("rlzEnabled", "disabled");

@@ -16,6 +16,7 @@ import("//extensions/features/features.gni")
import("//media/media_options.gni") import("//media/media_options.gni")
import("//ppapi/features/features.gni") import("//ppapi/features/features.gni")
import("//remoting/remoting_enable.gni") import("//remoting/remoting_enable.gni")
import("//rlz/features/features.gni")
import("//services/service_manager/public/service_manifest.gni") import("//services/service_manager/public/service_manifest.gni")
import("//testing/test.gni") import("//testing/test.gni")
import("//ui/base/ui_features.gni") import("//ui/base/ui_features.gni")
@@ -1228,6 +1229,7 @@ test("browser_tests") {
"//media:media_features", "//media:media_features",
"//ppapi/features", "//ppapi/features",
"//printing/features", "//printing/features",
"//rlz/features",
"//third_party/WebKit/public:features", "//third_party/WebKit/public:features",
] ]

@@ -11,6 +11,7 @@ include_rules = [
"+extensions", "+extensions",
"+mash/package", "+mash/package",
"+mojo", "+mojo",
"+rlz/features",
"+services", "+services",
# Tests under chrome/ shouldn't need to access the internals of content/ and # Tests under chrome/ shouldn't need to access the internals of content/ and

@@ -31,6 +31,7 @@
#include "extensions/common/constants.h" #include "extensions/common/constants.h"
#include "extensions/test/extension_test_message_listener.h" #include "extensions/test/extension_test_message_listener.h"
#include "ppapi/shared_impl/test_utils.h" #include "ppapi/shared_impl/test_utils.h"
#include "rlz/features/features.h"
#if defined(OS_MACOSX) #if defined(OS_MACOSX)
#include "base/mac/mac_util.h" #include "base/mac/mac_util.h"
@@ -1233,7 +1234,7 @@ TEST_PPAPI_OUT_OF_PROCESS(PDF)
IN_PROC_BROWSER_TEST_F(OutOfProcessPPAPITest, FlashDRM) { IN_PROC_BROWSER_TEST_F(OutOfProcessPPAPITest, FlashDRM) {
RunTest( RunTest(
#if (defined(OS_WIN) && defined(ENABLE_RLZ)) || defined(OS_CHROMEOS) #if (defined(OS_WIN) && BUILDFLAG(ENABLE_RLZ)) || defined(OS_CHROMEOS)
// Only implemented on Windows and ChromeOS currently. // Only implemented on Windows and ChromeOS currently.
LIST_TEST(FlashDRM_GetDeviceID) LIST_TEST(FlashDRM_GetDeviceID)
#endif #endif

@@ -6,6 +6,7 @@ import("//build/config/chrome_build.gni")
import("//build/config/features.gni") import("//build/config/features.gni")
import("//build/config/ui.gni") import("//build/config/ui.gni")
import("//printing/features/features.gni") import("//printing/features/features.gni")
import("//rlz/features/features.gni")
import("//testing/test.gni") import("//testing/test.gni")
import("//tools/grit/repack.gni") import("//tools/grit/repack.gni")

@@ -5,6 +5,7 @@
import("//build/buildflag_header.gni") import("//build/buildflag_header.gni")
import("//build/config/features.gni") import("//build/config/features.gni")
import("//build/config/ios/rules.gni") import("//build/config/ios/rules.gni")
import("//rlz/features/features.gni")
import("//third_party/protobuf/proto_library.gni") import("//third_party/protobuf/proto_library.gni")
declare_args() { declare_args() {
@@ -121,6 +122,7 @@ source_set("browser") {
"//ios/web", "//ios/web",
"//ios/web:user_agent", "//ios/web:user_agent",
"//net", "//net",
"//rlz/features",
"//url", "//url",
] ]
allow_circular_includes_from = [ allow_circular_includes_from = [
@@ -182,6 +184,7 @@ source_set("browser_impl") {
"//ios/web", "//ios/web",
"//ios/web/public/app", "//ios/web/public/app",
"//net", "//net",
"//rlz/features",
"//ui/base", "//ui/base",
] ]

@@ -94,6 +94,7 @@ include_rules = [
"+ios/public/provider/web", "+ios/public/provider/web",
"+ios/web/public", "+ios/web/public",
"+net", "+net",
"+rlz/features",
"+third_party/brotli", "+third_party/brotli",
"+third_party/google_toolbox_for_mac", "+third_party/google_toolbox_for_mac",
"+ui", "+ui",

@@ -52,10 +52,11 @@
#include "net/http/http_network_layer.h" #include "net/http/http_network_layer.h"
#include "net/http/http_stream_factory.h" #include "net/http/http_stream_factory.h"
#include "net/url_request/url_request.h" #include "net/url_request/url_request.h"
#include "rlz/features/features.h"
#include "ui/base/l10n/l10n_util_mac.h" #include "ui/base/l10n/l10n_util_mac.h"
#include "ui/base/resource/resource_bundle.h" #include "ui/base/resource/resource_bundle.h"
#if defined(ENABLE_RLZ) #if BUILDFLAG(ENABLE_RLZ)
#include "components/rlz/rlz_tracker.h" // nogncheck #include "components/rlz/rlz_tracker.h" // nogncheck
#include "ios/chrome/browser/rlz/rlz_tracker_delegate_impl.h" // nogncheck #include "ios/chrome/browser/rlz/rlz_tracker_delegate_impl.h" // nogncheck
#endif #endif
@@ -172,7 +173,7 @@ void IOSChromeMainParts::PreMainMessageLoopRun() {
ios::ChromeBrowserState* last_used_browser_state = ios::ChromeBrowserState* last_used_browser_state =
browser_state_manager->GetLastUsedBrowserState(); browser_state_manager->GetLastUsedBrowserState();
#if defined(ENABLE_RLZ) #if BUILDFLAG(ENABLE_RLZ)
// Init the RLZ library. This just schedules a task on the file thread to be // Init the RLZ library. This just schedules a task on the file thread to be
// run sometime later. If this is the first run we record the installation // run sometime later. If this is the first run we record the installation
// event. // event.
@@ -187,7 +188,7 @@ void IOSChromeMainParts::PreMainMessageLoopRun() {
RLZTrackerDelegateImpl::IsGoogleDefaultSearch(last_used_browser_state), RLZTrackerDelegateImpl::IsGoogleDefaultSearch(last_used_browser_state),
RLZTrackerDelegateImpl::IsGoogleHomepage(last_used_browser_state), RLZTrackerDelegateImpl::IsGoogleHomepage(last_used_browser_state),
RLZTrackerDelegateImpl::IsGoogleInStartpages(last_used_browser_state)); RLZTrackerDelegateImpl::IsGoogleInStartpages(last_used_browser_state));
#endif // defined(ENABLE_RLZ) #endif // BUILDFLAG(ENABLE_RLZ)
TranslateServiceIOS::Initialize(); TranslateServiceIOS::Initialize();
language_usage_metrics::LanguageUsageMetrics::RecordAcceptLanguages( language_usage_metrics::LanguageUsageMetrics::RecordAcceptLanguages(

@@ -3,6 +3,7 @@
# found in the LICENSE file. # found in the LICENSE file.
import("//build/config/features.gni") import("//build/config/features.gni")
import("//rlz/features/features.gni")
source_set("search_engines") { source_set("search_engines") {
sources = [ sources = [
@@ -33,6 +34,7 @@ source_set("search_engines") {
"//ios/chrome/common", "//ios/chrome/common",
"//ios/web", "//ios/web",
"//net", "//net",
"//rlz/features",
"//ui/base", "//ui/base",
"//url", "//url",
] ]

@@ -20,8 +20,9 @@
#include "ios/chrome/browser/search_engines/template_url_service_client_impl.h" #include "ios/chrome/browser/search_engines/template_url_service_client_impl.h"
#include "ios/chrome/browser/search_engines/ui_thread_search_terms_data.h" #include "ios/chrome/browser/search_engines/ui_thread_search_terms_data.h"
#include "ios/chrome/browser/web_data_service_factory.h" #include "ios/chrome/browser/web_data_service_factory.h"
#include "rlz/features/features.h"
#if defined(ENABLE_RLZ) #if BUILDFLAG(ENABLE_RLZ)
#include "components/rlz/rlz_tracker.h" // nogncheck #include "components/rlz/rlz_tracker.h" // nogncheck
#endif #endif
@@ -29,7 +30,7 @@ namespace ios {
namespace { namespace {
base::Closure GetDefaultSearchProviderChangedCallback() { base::Closure GetDefaultSearchProviderChangedCallback() {
#if defined(ENABLE_RLZ) #if BUILDFLAG(ENABLE_RLZ)
return base::Bind(base::IgnoreResult(&rlz::RLZTracker::RecordProductEvent), return base::Bind(base::IgnoreResult(&rlz::RLZTracker::RecordProductEvent),
rlz_lib::CHROME, rlz::RLZTracker::ChromeOmnibox(), rlz_lib::CHROME, rlz::RLZTracker::ChromeOmnibox(),
rlz_lib::SET_TO_GOOGLE); rlz_lib::SET_TO_GOOGLE);

@@ -18,9 +18,10 @@
#include "ios/chrome/common/channel_info.h" #include "ios/chrome/common/channel_info.h"
#include "ios/web/public/web_thread.h" #include "ios/web/public/web_thread.h"
#include "net/base/escape.h" #include "net/base/escape.h"
#include "rlz/features/features.h"
#include "url/gurl.h" #include "url/gurl.h"
#if defined(ENABLE_RLZ) #if BUILDFLAG(ENABLE_RLZ)
#include "components/rlz/rlz_tracker.h" // nogncheck #include "components/rlz/rlz_tracker.h" // nogncheck
#endif #endif
@@ -60,7 +61,7 @@ base::string16 UIThreadSearchTermsData::GetRlzParameterValue(
DCHECK(!from_app_list); DCHECK(!from_app_list);
DCHECK(thread_checker_.CalledOnValidThread()); DCHECK(thread_checker_.CalledOnValidThread());
base::string16 rlz_string; base::string16 rlz_string;
#if defined(ENABLE_RLZ) #if BUILDFLAG(ENABLE_RLZ)
// For organic brandcode do not use rlz at all. // For organic brandcode do not use rlz at all.
std::string brand; std::string brand;
if (ios::google_brand::GetBrand(&brand) && if (ios::google_brand::GetBrand(&brand) &&

11
rlz/features/BUILD.gn Normal file

@@ -0,0 +1,11 @@
# Copyright 2016 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("//build/buildflag_header.gni")
import("//rlz/features/features.gni")
buildflag_header("features") {
header = "features.h"
flags = [ "ENABLE_RLZ=$enable_rlz" ]
}

11
rlz/features/features.gni Normal file

@@ -0,0 +1,11 @@
# Copyright 2016 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("//build/config/chrome_build.gni")
# Whether we are using the rlz library or not. Platforms like Android send
# rlz codes for searches but do not use the library.
enable_rlz_support = is_win || is_mac || is_ios || is_chromeos
enable_rlz = is_chrome_branded && enable_rlz_support