diff options
author | cpu@chromium.org <cpu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-11-04 03:39:22 +0000 |
---|---|---|
committer | cpu@chromium.org <cpu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-11-04 03:39:22 +0000 |
commit | 4512f3acc3dab73e7fdcb8371d13f7bf46d8484b (patch) | |
tree | b422b0d7be3ae72a1b53ce5822054a440bcc668f /chrome/app/client_util.h | |
parent | 3002a3d7dd1cf42d481c8fd626d872e93677a789 (diff) | |
download | chromium_src-4512f3acc3dab73e7fdcb8371d13f7bf46d8484b.zip chromium_src-4512f3acc3dab73e7fdcb8371d13f7bf46d8484b.tar.gz chromium_src-4512f3acc3dab73e7fdcb8371d13f7bf46d8484b.tar.bz2 |
Rewrite of chrome.exe startup code
A lot of cruft and repeated code has deposited over the years on chrome's initialization code.
This CL makes it all much more clear and straightforward. There is no fundamental change of
behavior except the order of certain things is different but it should not alter the observed
operation.
- chrome's and chromium load is fundamentally the same but most of the code was repeated
- chrome's way to load the dll was incorrect: using a relative path with LOAD_WITH_ALTERED_SEARCH_PATH
- Use of SearchPath() was dangerous and not needed
- removed google_update_client.cc and .h
- removed bunch of #ifdefs
TEST=all convered by UI tests already except [1]
BUG=none
[1] The only thing I don't see convered by test is the restart dialog ('woa! chrome crashed').
Review URL: http://codereview.chromium.org/345036
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@30934 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/app/client_util.h')
-rw-r--r-- | chrome/app/client_util.h | 68 |
1 files changed, 38 insertions, 30 deletions
diff --git a/chrome/app/client_util.h b/chrome/app/client_util.h index b3ab7e7..c4d74d2 100644 --- a/chrome/app/client_util.h +++ b/chrome/app/client_util.h @@ -9,37 +9,45 @@ #define CHROME_APP_CLIENT_UTIL_H_ #include <windows.h> - #include <string> -#include "sandbox/src/sandbox_factory.h" - -namespace client_util { -typedef int (*DLL_MAIN)(HINSTANCE instance, sandbox::SandboxInterfaceInfo*, - TCHAR*); - -extern const wchar_t kProductVersionKey[]; - -// Returns true if file specified by file_path exists -bool FileExists(const std::wstring& file_path); - -// Returns Chromium version after reading it from reg_key registry key. Uses -// exe_path to detemine registry root key (HKLM/HKCU). Note it is the -// responsibility of caller to free *version when function is successful. -bool GetChromiumVersion(const wchar_t* const exe_path, - const wchar_t* const reg_key_path, - wchar_t** version); - -// Get path to DLL specified by dll_name. If dll_path is specified and it -// exists we assume DLL is in that directory and return that. Else we search -// for that DLL by calling Windows API. -std::wstring GetDLLPath(const std::wstring& dll_name, - const std::wstring& dll_path); - -// Returns the path to the exe (without the file name) that called this -// function. -std::wstring GetExecutablePath(); - -} // namespace client_util +namespace sandbox { + union SandboxInterfaceInfo; +} + +// Implements the common aspects of loading chrome.dll for both chrome and +// chromium scenarios, which are in charge of implementing two abstract +// methods: GetRegistryPath() and OnBeforeLaunch(). +class MainDllLoader { + public: + MainDllLoader(); + virtual ~MainDllLoader(); + + // Loads and calls the entry point of chrome.dll. |instance| is the exe + // instance retrieved from wWinMain and the |sbox_info| is the broker or + // target services interface pointer. + // The return value is what the main entry point of chrome.dll returns + // upon termination. + int Launch(HINSTANCE instance, sandbox::SandboxInterfaceInfo* sbox_info); + + // Derived classes must return the relative registry path that holds the + // most current version of chrome.dll. + virtual std::wstring GetRegistryPath() = 0; + + // Called after chrome.dll has beem loaded but before the entry point + // is invoked. Derived classes can implement custom actions here. + virtual void OnBeforeLaunch(const std::wstring& version) {} + + protected: + HMODULE Load(std::wstring* version, std::wstring* file); + + private: + // Chrome.dll handle. + HMODULE dll_; +}; + +// Factory for the MainDllLoader. Caller owns the pointer and should call +// delete to free it. +MainDllLoader* MakeMainDllLoader(); #endif // CHROME_APP_CLIENT_UTIL_H_ |