diff options
author | robertshield@chromium.org <robertshield@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-09-01 19:09:41 +0000 |
---|---|---|
committer | robertshield@chromium.org <robertshield@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-09-01 19:09:41 +0000 |
commit | 06e6f87a7d99758524cefbd9d234b0635c420dbc (patch) | |
tree | d72cc2e2e116a2f8f77252a5c9510953a7540800 | |
parent | 58531df60b957442c986f947e6e1566fd9cf6084 (diff) | |
download | chromium_src-06e6f87a7d99758524cefbd9d234b0635c420dbc.zip chromium_src-06e6f87a7d99758524cefbd9d234b0635c420dbc.tar.gz chromium_src-06e6f87a7d99758524cefbd9d234b0635c420dbc.tar.bz2 |
Parameterize the Google Update appid at build time instead of hard coding it in the source.
Review URL: http://codereview.chromium.org/178011
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@25072 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | app/app.gyp | 47 | ||||
-rw-r--r-- | build/common.gypi | 5 | ||||
-rw-r--r-- | chrome/app/chrome_exe_main.cc | 6 | ||||
-rw-r--r-- | chrome/chrome.gyp | 1 | ||||
-rw-r--r-- | chrome/installer/installer.gyp | 1 | ||||
-rwxr-xr-x | chrome/installer/mini_installer.gyp | 2 | ||||
-rw-r--r-- | chrome/installer/mini_installer/mini_installer.cc | 18 | ||||
-rw-r--r-- | chrome/installer/mini_installer/mini_installer.h | 7 | ||||
-rw-r--r-- | chrome/installer/util/google_update_constants.cc | 3 | ||||
-rw-r--r-- | chrome/tools/build/appid.py | 52 |
10 files changed, 130 insertions, 12 deletions
diff --git a/app/app.gyp b/app/app.gyp index 4422d03..3d027d6 100644 --- a/app/app.gyp +++ b/app/app.gyp @@ -297,6 +297,51 @@ 'dependencies': ['../build/win/system.gyp:cygwin'], }], ], - }, + }, + { + 'target_name': 'app_id', + 'type': 'none', + 'msvs_guid': '83100055-172B-49EA-B422-B1A92B627D37', + 'conditions': [ + ['OS=="win"', + { + 'actions': [ + { + 'action_name': 'appid', + 'variables': { + 'appid_py': '../chrome/tools/build/appid.py', + }, + 'conditions': [ + [ 'branding=="Chrome"', { + 'variables': { + 'appid_value': '<(google_update_appid)', + }, + }, { # else + 'variables': { + 'appid_value': '', + }, + }], + ], + 'inputs': [ + '<(appid_py)', + ], + 'outputs': [ + '<(SHARED_INTERMEDIATE_DIR)/chrome/appid.h', + 'tools/build/_always_run_appid_py.marker', + ], + 'action': [ + 'python', + '<(appid_py)', + '-a', '<(appid_value)', + '-o', '<(SHARED_INTERMEDIATE_DIR)/chrome/appid.h', + ], + 'process_outputs_as_sources': 1, + 'message': 'Generating appid information in <(SHARED_INTERMEDIATE_DIR)/chrome/appid.h' + }, + ], + }, + ], + ], + }, ], } diff --git a/build/common.gypi b/build/common.gypi index 4b95643..cd48bb9 100644 --- a/build/common.gypi +++ b/build/common.gypi @@ -69,6 +69,9 @@ # {'variables': {'library': 'shared_library'}} # to compile as shared by default 'library%': 'static_library', + + # The Google Update appid. + 'google_update_appid%': '{8A69D345-D564-463c-AFF1-A69D9E530F96}', # TODO(bradnelson): eliminate this when possible. # To allow local gyp files to prevent release.vsprops from being included. @@ -763,4 +766,4 @@ # and therefore SYMROOT, needs to be set at the project level. 'SYMROOT': '<(DEPTH)/xcodebuild', }, -} +}
\ No newline at end of file diff --git a/chrome/app/chrome_exe_main.cc b/chrome/app/chrome_exe_main.cc index 07a757c..a0899e6 100644 --- a/chrome/app/chrome_exe_main.cc +++ b/chrome/app/chrome_exe_main.cc @@ -19,6 +19,9 @@ #include "sandbox/src/sandbox_factory.h" #include "sandbox/src/dep.h" +// Generataed header containing the Google Update appid. +#include "appid.h" + int APIENTRY wWinMain(HINSTANCE instance, HINSTANCE prev_instance, wchar_t* command_line, int) { base::EnableTerminationOnHeapCorruption(); @@ -50,9 +53,8 @@ int APIENTRY wWinMain(HINSTANCE instance, HINSTANCE prev_instance, #if defined(GOOGLE_CHROME_BUILD) google_update::GoogleUpdateClient client; - // TODO(erikkay): Get guid from build macros rather than hardcoding. // TODO(erikkay): verify client.Init() return value for official builds - client.Init(L"{8A69D345-D564-463c-AFF1-A69D9E530F96}", dll_name); + client.Init(google_update::kChromeGuid, dll_name); dll_full_path = client.GetDLLFullPath(); versionned_path = client.GetDLLPath(); #else diff --git a/chrome/chrome.gyp b/chrome/chrome.gyp index d174b01..b2becc4 100644 --- a/chrome/chrome.gyp +++ b/chrome/chrome.gyp @@ -3345,6 +3345,7 @@ }], ['OS=="win"', { 'dependencies': [ + '../app/app.gyp:app_id', 'installer/installer.gyp:installer_util', 'installer/installer.gyp:installer_util_strings', '../breakpad/breakpad.gyp:breakpad_handler', diff --git a/chrome/installer/installer.gyp b/chrome/installer/installer.gyp index c501a59..2f684fa 100644 --- a/chrome/installer/installer.gyp +++ b/chrome/installer/installer.gyp @@ -16,6 +16,7 @@ 'type': '<(library)', 'msvs_guid': 'EFBB1436-A63F-4CD8-9E99-B89226E782EC', 'dependencies': [ + '../../app/app.gyp:app_id', 'installer_util_strings', '../chrome.gyp:common', '../chrome.gyp:chrome_resources', diff --git a/chrome/installer/mini_installer.gyp b/chrome/installer/mini_installer.gyp index 950f6da..229c994 100755 --- a/chrome/installer/mini_installer.gyp +++ b/chrome/installer/mini_installer.gyp @@ -18,6 +18,7 @@ 'type': 'executable', 'msvs_guid': '24A5AC7C-280B-4899-9153-6BA570A081E7', 'dependencies': [ + '../../app/app.gyp:app_id', '../chrome.gyp:chrome', '../chrome.gyp:chrome_dll', '../chrome.gyp:default_extensions', @@ -28,6 +29,7 @@ '../..', '<(PRODUCT_DIR)', '<(INTERMEDIATE_DIR)', + '<(SHARED_INTERMEDIATE_DIR)/chrome', ], 'sources': [ 'mini_installer/chrome.release', diff --git a/chrome/installer/mini_installer/mini_installer.cc b/chrome/installer/mini_installer/mini_installer.cc index 6567086..ff913f2 100644 --- a/chrome/installer/mini_installer/mini_installer.cc +++ b/chrome/installer/mini_installer/mini_installer.cc @@ -35,6 +35,9 @@ #include "chrome/installer/mini_installer/mini_installer.h" #include "chrome/installer/mini_installer/pe_resource.h" +// Generated header that includes the Google Update id. +#include "appid.h" + // Required linker symbol. See remarks above. extern "C" unsigned int __sse2_available = 0; @@ -148,7 +151,14 @@ bool ReadValueFromRegistry(HKEY root_key, const wchar_t *sub_key, // flag is cleared by setup.exe at the end of install. void SetFullInstallerFlag(HKEY root_key) { HKEY key; - if (::RegOpenKeyEx(root_key, kApRegistryKey, NULL, + wchar_t ap_registry_key[128]; + if (!SafeStrCopy(ap_registry_key, _countof(ap_registry_key), + kApRegistryKeyBase) || + !SafeStrCat(ap_registry_key, _countof(ap_registry_key), + google_update::kChromeGuid)) { + return; + } + if (::RegOpenKeyEx(root_key, ap_registry_key, NULL, KEY_READ | KEY_SET_VALUE, &key) != ERROR_SUCCESS) return; @@ -238,7 +248,7 @@ BOOL CALLBACK OnResourceFound(HMODULE module, const wchar_t* type, PEResource resource(name, type, module); if ((!resource.IsValid()) || - (resource.Size() < 1 ) || + (resource.Size() < 1) || (resource.Size() > kMaxResourceSize)) { return FALSE; } @@ -251,7 +261,7 @@ BOOL CALLBACK OnResourceFound(HMODULE module, const wchar_t* type, if (StrStartsWith(name, kChromePrefix)) { if (!SafeStrCopy(ctx->chrome_resource_path, - ctx->chrome_resource_path_size, full_path)) + ctx->chrome_resource_path_size, full_path)) return FALSE; } else if (StrStartsWith(name, kSetupPrefix)) { if (!SafeStrCopy(ctx->setup_resource_path, @@ -401,7 +411,7 @@ void AppendCommandLineFlags(wchar_t* buffer, int size) { // Current executable name not in the command line so just append // the whole command line. cmd_to_append = cmd_line; - } else if (args_num > 1 ) { + } else if (args_num > 1) { wchar_t* tmp = StrStr(cmd_line, exe_name); tmp = StrStr(tmp, L" "); cmd_to_append = tmp; diff --git a/chrome/installer/mini_installer/mini_installer.h b/chrome/installer/mini_installer/mini_installer.h index fde3656..9cce8d2 100644 --- a/chrome/installer/mini_installer/mini_installer.h +++ b/chrome/installer/mini_installer/mini_installer.h @@ -42,13 +42,14 @@ const wchar_t kUninstallRegistryValueName[] = L"UninstallString"; // Paths for the above registry keys #if defined(GOOGLE_CHROME_BUILD) -const wchar_t kApRegistryKey[] = L"Software\\Google\\Update\\ClientState\\" - L"{8A69D345-D564-463c-AFF1-A69D9E530F96}"; +// The concatenation of this plus the Google Update GUID is the app registry +// key. +const wchar_t kApRegistryKeyBase[] = L"Software\\Google\\Update\\ClientState\\"; const wchar_t kUninstallRegistryKey[] = L"Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\Google Chrome"; const wchar_t kCleanupRegistryKey[] = L"Software\\Google"; #else -const wchar_t kApRegistryKey[] = L"Software\\Chromium"; +const wchar_t kApRegistryKeyBase[] = L"Software\\Chromium"; const wchar_t kUninstallRegistryKey[] = L"Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\Chromium"; const wchar_t kCleanupRegistryKey[] = L"Software\\Chromium"; diff --git a/chrome/installer/util/google_update_constants.cc b/chrome/installer/util/google_update_constants.cc index 170a17b..4586f07 100644 --- a/chrome/installer/util/google_update_constants.cc +++ b/chrome/installer/util/google_update_constants.cc @@ -4,9 +4,10 @@ #include "chrome/installer/util/google_update_constants.h" +#include "appid.h" + namespace google_update { -const wchar_t kChromeGuid[] = L"{8A69D345-D564-463c-AFF1-A69D9E530F96}"; const wchar_t kGearsUpgradeCode[] = L"{D92DBAED-3E3E-4530-B30D-072D16C7DDD0}"; const wchar_t kRegPathClients[] = L"Software\\Google\\Update\\Clients"; diff --git a/chrome/tools/build/appid.py b/chrome/tools/build/appid.py new file mode 100644 index 0000000..b563022 --- /dev/null +++ b/chrome/tools/build/appid.py @@ -0,0 +1,52 @@ +#!/usr/bin/env python +# Copyright (c) 2009 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. + +""" +appid.py -- Chromium appid header file generation utility. +""" + +import optparse +import sys + +GENERATED_APPID_INCLUDE_FILE_CONTENTS = """ +// This file is automatically generated by appid.py. +// It contains the Google Update Appid used for this build. Note that +// the Appid will be empty for non Google Chrome builds. +namespace google_update { +const wchar_t kChromeGuid[] = L"%s"; +} +""" + +def GenerateAppIdHeader(opts): + contents = GENERATED_APPID_INCLUDE_FILE_CONTENTS % opts.appid + + output_file = open(opts.output_file, 'w') + try: + output_file.write(contents) + finally: + output_file.close() + +def main(): + parser = optparse.OptionParser() + parser.add_option('-a', '--appid', + help='The Google Update App Id of the Chrome being built.') + parser.add_option('-o', '--output_file', + help='The path to the generated output header file') + + (opts, args) = parser.parse_args() + + if opts.appid is None or not opts.output_file: + parser.print_help() + return 1 + + # Log a trace in the build output when we run. + print "Generating appid header... ", + GenerateAppIdHeader(opts) + + print "Done." + + +if __name__ == '__main__': + sys.exit(main()) |