diff options
author | tony@chromium.org <tony@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-05-24 19:26:57 +0000 |
---|---|---|
committer | tony@chromium.org <tony@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-05-24 19:26:57 +0000 |
commit | b4d08ea03dc3b02209b24e8d0b18ca42e70f5368 (patch) | |
tree | da9bd0f1a7ff798aa11d63886d8bdb6a2b664942 /chrome | |
parent | 89d4dc272b08346d1a08f2a633cfea0469ba5e30 (diff) | |
download | chromium_src-b4d08ea03dc3b02209b24e8d0b18ca42e70f5368.zip chromium_src-b4d08ea03dc3b02209b24e8d0b18ca42e70f5368.tar.gz chromium_src-b4d08ea03dc3b02209b24e8d0b18ca42e70f5368.tar.bz2 |
Remove installer_util_strings.rc from chrome.dll.
These strings are also in the locale pak files, so this is a duplicate
of >250k of data. Add the ability to provide a different string
provider for BrowserDistribution.
BUG=128056
TEST=chrome --first-run still works
Review URL: https://chromiumcodereview.appspot.com/10386217
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@138859 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r-- | chrome/app/chrome_dll.rc | 2 | ||||
-rw-r--r-- | chrome/browser/DEPS | 1 | ||||
-rw-r--r-- | chrome/browser/chrome_browser_main.cc | 4 | ||||
-rw-r--r-- | chrome/browser/chrome_browser_main_win.cc | 33 | ||||
-rw-r--r-- | chrome/browser/chrome_browser_main_win.h | 4 | ||||
-rw-r--r-- | chrome/chrome_browser.gypi | 1 | ||||
-rw-r--r-- | chrome/chrome_dll.gypi | 1 | ||||
-rw-r--r-- | chrome/chrome_exe.gypi | 1 | ||||
-rw-r--r-- | chrome/chrome_tests.gypi | 7 | ||||
-rw-r--r-- | chrome/installer/util/l10n_string_util.cc | 21 | ||||
-rw-r--r-- | chrome/installer/util/l10n_string_util.h | 18 | ||||
-rwxr-xr-x | chrome/installer/util/prebuild/create_string_rc.py | 14 |
12 files changed, 85 insertions, 22 deletions
diff --git a/chrome/app/chrome_dll.rc b/chrome/app/chrome_dll.rc index 7238647..879579a 100644 --- a/chrome/app/chrome_dll.rc +++ b/chrome/app/chrome_dll.rc @@ -246,8 +246,6 @@ END #endif // English (U.S.) resources ///////////////////////////////////////////////////////////////////////////// -#include "installer_util_strings/installer_util_strings.rc" - #ifndef APSTUDIO_INVOKED ///////////////////////////////////////////////////////////////////////////// // diff --git a/chrome/browser/DEPS b/chrome/browser/DEPS index eee85c0..80a96fd 100644 --- a/chrome/browser/DEPS +++ b/chrome/browser/DEPS @@ -12,6 +12,7 @@ include_rules = [ "+content/public/browser", "+google_update", "+grit", # For generated headers + "+installer_util_strings", # For generated headers "+policy", # For generated headers and source "+ppapi/c", # For various types. "+ppapi/proxy", diff --git a/chrome/browser/chrome_browser_main.cc b/chrome/browser/chrome_browser_main.cc index 5c8a311..386932c 100644 --- a/chrome/browser/chrome_browser_main.cc +++ b/chrome/browser/chrome_browser_main.cc @@ -1593,6 +1593,10 @@ int ChromeBrowserMainParts::PreMainMessageLoopRunImpl() { ChromeBrowserMainPartsWin::CheckMachineLevelInstall()) { return chrome::RESULT_CODE_MACHINE_LEVEL_INSTALL_EXISTS; } + + // installer_util references strings that are normally compiled into + // setup.exe. In Chrome, these strings are in the locale files. + ChromeBrowserMainPartsWin::SetupInstallerUtilStrings(); #endif // Create the TranslateManager singleton. diff --git a/chrome/browser/chrome_browser_main_win.cc b/chrome/browser/chrome_browser_main_win.cc index 4cade20..2ba99c6 100644 --- a/chrome/browser/chrome_browser_main_win.cc +++ b/chrome/browser/chrome_browser_main_win.cc @@ -35,17 +35,20 @@ #include "chrome/installer/util/browser_distribution.h" #include "chrome/installer/util/helper.h" #include "chrome/installer/util/install_util.h" +#include "chrome/installer/util/l10n_string_util.h" #include "chrome/installer/util/shell_util.h" #include "content/public/common/main_function_params.h" #include "grit/app_locale_settings.h" #include "grit/chromium_strings.h" #include "grit/generated_resources.h" +#include "installer_util_strings/installer_util_strings.h" #include "ui/base/l10n/l10n_util.h" #include "ui/base/l10n/l10n_util_win.h" #include "ui/base/ui_base_switches.h" #include "ui/base/win/message_box_win.h" #include "ui/gfx/platform_font_win.h" + namespace { typedef HRESULT (STDAPICALLTYPE* RegisterApplicationRestartProc)( @@ -75,6 +78,11 @@ int GetMinimumFontSize() { return min_font_size; } +class TranslationDelegate : public installer::TranslationDelegate { + public: + virtual string16 GetLocalizedString(int installer_string_id) OVERRIDE; +}; + } // namespace void RecordBreakpadStatusUMA(MetricsService* metrics) { @@ -312,3 +320,28 @@ bool ChromeBrowserMainPartsWin::CheckMachineLevelInstall() { } return false; } + +string16 TranslationDelegate::GetLocalizedString(int installer_string_id) { + int resource_id = 0; + switch (installer_string_id) { + // HANDLE_STRING is used by the DO_INSTALLER_STRING_MAPPING macro which is in + // the generated header installer_util_strings.h. +#define HANDLE_STRING(base_id, chrome_id) \ + case base_id: \ + resource_id = chrome_id; \ + break; + DO_INSTALLER_STRING_MAPPING +#undef HANDLE_STRING + default: + NOTREACHED(); + } + if (resource_id) + return l10n_util::GetStringUTF16(resource_id); + return string16(); +} + +// static +void ChromeBrowserMainPartsWin::SetupInstallerUtilStrings() { + CR_DEFINE_STATIC_LOCAL(TranslationDelegate, delegate, ()); + installer::SetTranslationDelegate(&delegate); +} diff --git a/chrome/browser/chrome_browser_main_win.h b/chrome/browser/chrome_browser_main_win.h index 5022474..b2aa3df 100644 --- a/chrome/browser/chrome_browser_main_win.h +++ b/chrome/browser/chrome_browser_main_win.h @@ -61,6 +61,10 @@ class ChromeBrowserMainPartsWin : public ChromeBrowserMainParts { // user level Chrome. static bool CheckMachineLevelInstall(); + // Sets the TranslationDelegate which provides localized strings to + // installer_util. + static void SetupInstallerUtilStrings(); + private: scoped_ptr<chrome::MediaDeviceNotificationsWindowWin> media_device_notifications_window_; diff --git a/chrome/chrome_browser.gypi b/chrome/chrome_browser.gypi index c63a9f2..91547a7 100644 --- a/chrome/chrome_browser.gypi +++ b/chrome/chrome_browser.gypi @@ -4780,6 +4780,7 @@ '<(DEPTH)/third_party/wtl/include', ], 'dependencies': [ + 'installer_util_strings', '../google_update/google_update.gyp:google_update', '../third_party/iaccessible2/iaccessible2.gyp:iaccessible2', '../third_party/isimpledom/isimpledom.gyp:isimpledom', diff --git a/chrome/chrome_dll.gypi b/chrome/chrome_dll.gypi index e124362..c644662 100644 --- a/chrome/chrome_dll.gypi +++ b/chrome/chrome_dll.gypi @@ -60,7 +60,6 @@ # up actual Chromium functionality into this .dll. 'chrome_resources.gyp:chrome_resources', 'chrome_version_resources', - 'installer_util_strings', '../content/content.gyp:content_worker', '../crypto/crypto.gyp:crypto', '../printing/printing.gyp:printing', diff --git a/chrome/chrome_exe.gypi b/chrome/chrome_exe.gypi index f64af02..0722056 100644 --- a/chrome/chrome_exe.gypi +++ b/chrome/chrome_exe.gypi @@ -451,7 +451,6 @@ 'chrome_dll', 'chrome_version_resources', 'installer_util', - 'installer_util_strings', 'image_pre_reader', '../base/base.gyp:base', '../breakpad/breakpad.gyp:breakpad_handler', diff --git a/chrome/chrome_tests.gypi b/chrome/chrome_tests.gypi index f86c553..c1aee45 100644 --- a/chrome/chrome_tests.gypi +++ b/chrome/chrome_tests.gypi @@ -588,7 +588,6 @@ ], 'dependencies': [ 'chrome.gyp:chrome_version_resources', - 'chrome.gyp:installer_util_strings', '../sandbox/sandbox.gyp:sandbox', '../third_party/iaccessible2/iaccessible2.gyp:iaccessible2', '../third_party/isimpledom/isimpledom.gyp:isimpledom', @@ -2237,7 +2236,6 @@ ['OS=="win"', { 'dependencies': [ 'chrome_version_resources', - 'installer_util_strings', '../third_party/iaccessible2/iaccessible2.gyp:iaccessible2', '../third_party/isimpledom/isimpledom.gyp:isimpledom', ], @@ -3145,7 +3143,6 @@ ], 'dependencies': [ 'chrome_version_resources', - 'installer_util_strings', 'security_tests', # run time dependency '../third_party/iaccessible2/iaccessible2.gyp:iaccessible2', '../sandbox/sandbox.gyp:sandbox', @@ -3439,7 +3436,6 @@ ], 'dependencies': [ 'chrome_version_resources', - 'installer_util_strings', '../sandbox/sandbox.gyp:sandbox', ], 'conditions': [ @@ -3552,7 +3548,6 @@ ['OS=="win"', { 'dependencies': [ 'chrome_version_resources', - 'installer_util_strings', '../sandbox/sandbox.gyp:sandbox', ], 'sources': [ @@ -3942,7 +3937,6 @@ ], 'dependencies': [ 'chrome_version_resources', - 'installer_util_strings', '../sandbox/sandbox.gyp:sandbox', ], 'conditions': [ @@ -4067,7 +4061,6 @@ ], 'dependencies': [ 'chrome_version_resources', - 'installer_util_strings', '../sandbox/sandbox.gyp:sandbox', ], 'conditions': [ diff --git a/chrome/installer/util/l10n_string_util.cc b/chrome/installer/util/l10n_string_util.cc index 4c7426b..ce2011f 100644 --- a/chrome/installer/util/l10n_string_util.cc +++ b/chrome/installer/util/l10n_string_util.cc @@ -1,14 +1,15 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 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 file defines specific implementation of BrowserDistribution class for -// Google Chrome. +// This file defines utility functions for fetching localized resources. -#include <algorithm> +#include "chrome/installer/util/l10n_string_util.h" #include <atlbase.h> +#include <algorithm> + #include "base/logging.h" #include "base/memory/scoped_ptr.h" #include "base/string_util.h" @@ -23,11 +24,23 @@ const installer::LanguageSelector& GetLanguageSelector() { return instance; } +installer::TranslationDelegate* g_translation_delegate = NULL; + } // namespace namespace installer { +TranslationDelegate::~TranslationDelegate() { +} + +void SetTranslationDelegate(TranslationDelegate* delegate) { + g_translation_delegate = delegate; +} + std::wstring GetLocalizedString(int base_message_id) { + if (g_translation_delegate) + return g_translation_delegate->GetLocalizedString(base_message_id); + std::wstring localized_string; int message_id = base_message_id + GetLanguageSelector().offset(); diff --git a/chrome/installer/util/l10n_string_util.h b/chrome/installer/util/l10n_string_util.h index 27ee239..9008b1f 100644 --- a/chrome/installer/util/l10n_string_util.h +++ b/chrome/installer/util/l10n_string_util.h @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 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. // @@ -16,11 +16,25 @@ #include <string> +#include "base/string16.h" + namespace installer { +class TranslationDelegate { + public: + virtual ~TranslationDelegate(); + virtual string16 GetLocalizedString(int installer_string_id) = 0; +}; + +// If we're in Chrome, the installer strings aren't in the binary, but are in +// the localized pak files. A TranslationDelegate must be provided so we can +// load these strings. +void SetTranslationDelegate(TranslationDelegate* delegate); + // Given a string base id, return the localized version of the string based on // the system language. This is used for shortcuts placed on the user's -// desktop. +// desktop. The string is retrieved from the TranslationDelegate if one has +// been set. Otherwise, the string is read from the binary's string table. std::wstring GetLocalizedString(int base_message_id); // Given the system language, return a url that points to the localized eula. diff --git a/chrome/installer/util/prebuild/create_string_rc.py b/chrome/installer/util/prebuild/create_string_rc.py index 9e4ddb7..dd1043b 100755 --- a/chrome/installer/util/prebuild/create_string_rc.py +++ b/chrome/installer/util/prebuild/create_string_rc.py @@ -1,5 +1,5 @@ #!/usr/bin/env python -# Copyright (c) 2011 The Chromium Authors. All rights reserved. +# Copyright (c) 2012 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. @@ -184,7 +184,8 @@ def WriteHeaderFile(translated_strings, out_filename): """Writes a .h file with resource ids. This file can be included by the executable to refer to identifiers.""" lines = [] - do_languages_lines = ['#define DO_LANGUAGES'] + do_languages_lines = ['\n#define DO_LANGUAGES'] + installer_string_mapping_lines = ['\n#define DO_INSTALLER_STRING_MAPPING'] # Write the values for how the languages ids are offset. seen_languages = set() @@ -213,11 +214,14 @@ def WriteHeaderFile(translated_strings, out_filename): lines.append('#define %s_BASE %s_%s' % (string_id, string_id, translated_strings[0].language)) + installer_string_mapping_lines.append(' HANDLE_STRING(%s_BASE, %s)' + % (string_id, string_id)) - outfile = open(out_filename + '.h', 'wb') + outfile = open(out_filename, 'wb') outfile.write('\n'.join(lines)) - outfile.write('\n#ifndef RC_INVOKED\n') + outfile.write('\n#ifndef RC_INVOKED') outfile.write(' \\\n'.join(do_languages_lines)) + outfile.write(' \\\n'.join(installer_string_mapping_lines)) # .rc files must end in a new line outfile.write('\n#endif // ndef RC_INVOKED\n') outfile.close() @@ -234,7 +238,7 @@ def main(argv): translated_strings = CollectTranslatedStrings(branding) kFilebase = os.path.join(argv[1], 'installer_util_strings') WriteRCFile(translated_strings, kFilebase) - WriteHeaderFile(translated_strings, kFilebase) + WriteHeaderFile(translated_strings, kFilebase + '.h') return 0 |