Fix a leak in wm::AnimateOnChildWindowVisibilityChanged().
[chromium-blink-merge.git] / chrome / app / client_util.h
blob5ef81ba5ae67f882751f70ccffc764dae55ac15f
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 // This file defines utility functions that can report details about the
6 // host operating environment.
8 #ifndef CHROME_APP_CLIENT_UTIL_H_
9 #define CHROME_APP_CLIENT_UTIL_H_
11 #include <windows.h>
13 #include <string>
14 #include "base/strings/string16.h"
16 namespace sandbox {
17 struct SandboxInterfaceInfo;
20 // Gets the path of the current exe with a trailing backslash.
21 base::string16 GetExecutablePath();
23 // Returns the version in the current module's version resource or the empty
24 // string if none found.
25 base::string16 GetCurrentModuleVersion();
27 // Implements the common aspects of loading the main dll for both chrome and
28 // chromium scenarios, which are in charge of implementing two abstract
29 // methods: GetRegistryPath() and OnBeforeLaunch().
30 class MainDllLoader {
31 public:
32 MainDllLoader();
33 virtual ~MainDllLoader();
35 // Loads and calls the entry point of chrome.dll. |instance| is the exe
36 // instance retrieved from wWinMain.
37 // The return value is what the main entry point of chrome.dll returns
38 // upon termination.
39 int Launch(HINSTANCE instance);
41 // Launches a new instance of the browser if the current instance in
42 // persistent mode an upgrade is detected.
43 void RelaunchChromeBrowserWithNewCommandLineIfNeeded();
45 protected:
46 // Called after chrome.dll has been loaded but before the entry point
47 // is invoked. Derived classes can implement custom actions here.
48 // |dll_path| refers to the path of the Chrome dll being loaded.
49 virtual void OnBeforeLaunch(const base::string16& dll_path) = 0;
51 // Called after the chrome.dll entry point returns and before terminating
52 // this process. The return value will be used as the process return code.
53 // |dll_path| refers to the path of the Chrome dll being loaded.
54 virtual int OnBeforeExit(int return_code, const base::string16& dll_path) = 0;
56 private:
57 HMODULE Load(base::string16* version, base::string16* out_file);
59 private:
60 HMODULE dll_;
61 std::string process_type_;
62 const bool metro_mode_;
65 // Factory for the MainDllLoader. Caller owns the pointer and should call
66 // delete to free it.
67 MainDllLoader* MakeMainDllLoader();
69 #endif // CHROME_APP_CLIENT_UTIL_H_