diff options
author | mark@chromium.org <mark@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-10-14 22:01:26 +0000 |
---|---|---|
committer | mark@chromium.org <mark@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-10-14 22:01:26 +0000 |
commit | 1405220aad5d0885a3f583e95d9a96e76455b1c7 (patch) | |
tree | 86dcdcc3d656a236a958bbf93f7851cdbd3c59c3 | |
parent | 6b82c608d606fc848c3b0849204968e9e649ef86 (diff) | |
download | chromium_src-1405220aad5d0885a3f583e95d9a96e76455b1c7.zip chromium_src-1405220aad5d0885a3f583e95d9a96e76455b1c7.tar.gz chromium_src-1405220aad5d0885a3f583e95d9a96e76455b1c7.tar.bz2 |
Eliminate char/wchar_t conversions, probably-unsafe statics, and disk access
when determining the framework and helper app paths on the Mac.
BUG=24833
TEST=app still works, tests still pass
Review URL: http://codereview.chromium.org/267102
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@29034 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/browser/utility_process_host_unittest.cc | 3 | ||||
-rwxr-xr-x | chrome/chrome.gyp | 22 | ||||
-rw-r--r-- | chrome/common/child_process_host.cc | 9 | ||||
-rw-r--r-- | chrome/common/chrome_constants.cc | 10 | ||||
-rw-r--r-- | chrome/common/chrome_constants.h | 4 | ||||
-rw-r--r-- | chrome/common/chrome_paths_mac.mm | 38 | ||||
-rwxr-xr-x | chrome/tools/build/make_version_cc.py | 35 |
7 files changed, 80 insertions, 41 deletions
diff --git a/chrome/browser/utility_process_host_unittest.cc b/chrome/browser/utility_process_host_unittest.cc index ffb99a7..96dded3 100644 --- a/chrome/browser/utility_process_host_unittest.cc +++ b/chrome/browser/utility_process_host_unittest.cc @@ -79,8 +79,7 @@ class TestUtilityProcessHost : public UtilityProcessHost { virtual FilePath GetUtilityProcessCmd() { FilePath exe_path; PathService::Get(base::DIR_EXE, &exe_path); - exe_path = exe_path.AppendASCII(WideToASCII( - chrome::kHelperProcessExecutablePath)); + exe_path = exe_path.Append(chrome::kHelperProcessExecutablePath); return exe_path; } diff --git a/chrome/chrome.gyp b/chrome/chrome.gyp index c072347..fd0c7c1 100755 --- a/chrome/chrome.gyp +++ b/chrome/chrome.gyp @@ -470,6 +470,28 @@ 'common/pref_names.cc', 'common/pref_names.h', ], + 'actions': [ + { + 'action_name': 'Make chrome_version.cc', + 'variables': { + 'make_version_cc_path': 'tools/build/make_version_cc.py', + }, + 'inputs': [ + '<(make_version_cc_path)', + 'VERSION', + ], + 'outputs': [ + '<(INTERMEDIATE_DIR)/chrome_version.cc', + ], + 'action': [ + 'python', + '<(make_version_cc_path)', + '<@(_outputs)', + '<(version_full)', + ], + 'process_outputs_as_sources': 1, + }, + ], }, { 'target_name': 'common', diff --git a/chrome/common/child_process_host.cc b/chrome/common/child_process_host.cc index 695ac18..1d48350 100644 --- a/chrome/common/child_process_host.cc +++ b/chrome/common/child_process_host.cc @@ -85,10 +85,7 @@ ChildProcessHost::~ChildProcessHost() { // static FilePath ChildProcessHost::GetChildPath() { - static FilePath child_path; - - if (!child_path.empty()) - return child_path; + FilePath child_path; child_path = CommandLine::ForCurrentProcess()->GetSwitchValuePath( switches::kBrowserSubprocessPath); @@ -102,8 +99,8 @@ FilePath ChildProcessHost::GetChildPath() { #else // On the Mac, the child executable lives at a predefined location within // the app bundle's versioned directory. - child_path = chrome::GetVersionedDirectory().Append( - FilePath::FromWStringHack(chrome::kHelperProcessExecutablePath)); + child_path = chrome::GetVersionedDirectory(). + Append(chrome::kHelperProcessExecutablePath); #endif // OS_MACOSX return child_path; diff --git a/chrome/common/chrome_constants.cc b/chrome/common/chrome_constants.cc index 5f8fc9a..4614319 100644 --- a/chrome/common/chrome_constants.cc +++ b/chrome/common/chrome_constants.cc @@ -36,19 +36,19 @@ const wchar_t kHelperProcessExecutableName[] = PRODUCT_STRING_W L" Helper"; #endif // OS_* #if defined(OS_WIN) const wchar_t kBrowserProcessExecutablePath[] = L"chrome.exe"; -const wchar_t kHelperProcessExecutablePath[] = L"chrome.exe"; +const FilePath::CharType kHelperProcessExecutablePath[] = FPL("chrome.exe"); #elif defined(OS_LINUX) const wchar_t kBrowserProcessExecutablePath[] = L"chrome"; -const wchar_t kHelperProcessExecutablePath[] = L"chrome"; +const FilePath::CharType kHelperProcessExecutablePath[] = FPL("chrome"); #elif defined(OS_MACOSX) const wchar_t kBrowserProcessExecutablePath[] = PRODUCT_STRING_W L".app/Contents/MacOS/" PRODUCT_STRING_W; -const wchar_t kHelperProcessExecutablePath[] = - PRODUCT_STRING_W L" Helper.app/Contents/MacOS/" PRODUCT_STRING_W L" Helper"; +const FilePath::CharType kHelperProcessExecutablePath[] = + FPL(PRODUCT_STRING " Helper.app/Contents/MacOS/" PRODUCT_STRING " Helper"); #endif // OS_* #if defined(OS_MACOSX) const FilePath::CharType kFrameworkName[] = - PRODUCT_STRING " Framework.framework"; + FPL(PRODUCT_STRING " Framework.framework"); #endif // OS_MACOSX #if defined(CHROME_FRAME_BUILD) const wchar_t kBrowserAppName[] = L"ChromeFrame"; diff --git a/chrome/common/chrome_constants.h b/chrome/common/chrome_constants.h index fab0a16..cb7e1e7 100644 --- a/chrome/common/chrome_constants.h +++ b/chrome/common/chrome_constants.h @@ -11,10 +11,12 @@ namespace chrome { +extern const char kChromeVersion[]; + extern const wchar_t kBrowserProcessExecutableName[]; extern const wchar_t kHelperProcessExecutableName[]; extern const wchar_t kBrowserProcessExecutablePath[]; -extern const wchar_t kHelperProcessExecutablePath[]; +extern const FilePath::CharType kHelperProcessExecutablePath[]; #if defined(OS_MACOSX) extern const FilePath::CharType kFrameworkName[]; #endif diff --git a/chrome/common/chrome_paths_mac.mm b/chrome/common/chrome_paths_mac.mm index beb22f2..b4f28a0 100644 --- a/chrome/common/chrome_paths_mac.mm +++ b/chrome/common/chrome_paths_mac.mm @@ -67,34 +67,18 @@ bool GetUserDesktop(FilePath* result) { } FilePath GetVersionedDirectory() { - static FilePath path; + // Start out with the path to the running .app. + NSBundle* app_bundle = [NSBundle mainBundle]; + FilePath path = FilePath([[app_bundle bundlePath] fileSystemRepresentation]); - if (path.empty()) { - // Start out with the path to the running .app. - NSBundle* app_bundle = [NSBundle mainBundle]; - path = FilePath([[app_bundle bundlePath] fileSystemRepresentation]); - - if (mac_util::IsBackgroundOnlyProcess()) { - // path identifies the helper .app in the browser .app's versioned - // directory. Go up one level to get to the browser .app's versioned - // directory. - path = path.DirName(); - } else { - // path identifies the browser .app. Go into its versioned directory. - // TODO(mark): Here, |version| comes from the outer .app bundle's - // Info.plist. In the event of an incomplete update, it may be possible - // for this value to be incorrect. Consider the case where the updater - // is able to update one, but not both, of the executable and the - // Info.plist. The executable may load one version of the framework, - // and the Info.plist may refer to another version. Ideally, the - // version would be available in a compile-time constant, or there would - // be a better way to detect the loaded framework version at runtime. - NSString* version = - [app_bundle objectForInfoDictionaryKey:@"CFBundleShortVersionString"]; - path = path.Append("Contents"). - Append("Versions"). - Append([version fileSystemRepresentation]); - } + if (mac_util::IsBackgroundOnlyProcess()) { + // path identifies the helper .app in the browser .app's versioned + // directory. Go up one level to get to the browser .app's versioned + // directory. + path = path.DirName(); + } else { + // path identifies the browser .app. Go into its versioned directory. + path = path.Append("Contents").Append("Versions").Append(kChromeVersion); } return path; diff --git a/chrome/tools/build/make_version_cc.py b/chrome/tools/build/make_version_cc.py new file mode 100755 index 0000000..2797595 --- /dev/null +++ b/chrome/tools/build/make_version_cc.py @@ -0,0 +1,35 @@ +#!/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. + +# Creates chrome_version.cc which contains the definition of the +# kChromeVersion constant. + +import sys + +def main(me, args): + if len(args) != 2: + print >>sys.stderr, 'usage: %s version.cc version' % me + return 1 + + (cc_file, version) = args + + contents = '''// automatically generated by %s + +namespace chrome { + +extern const char kChromeVersion[] = "%s"; + +} // namespace chrome +''' % (me, version) + + output = open(cc_file, 'w') + output.write(contents) + output.close() + + return 0 + +if __name__ == '__main__': + sys.exit(main(sys.argv[0], sys.argv[1:])) |