Updating XTBs based on .GRDs from branch master
[chromium-blink-merge.git] / chrome / app / client_util.h
blobde09a667af9d669ef14096856c4d96b9f2d2d548
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 // Returns the version in the current module's version resource or the empty
21 // string if none found.
22 base::string16 GetCurrentModuleVersion();
24 // Implements the common aspects of loading the main dll for both chrome and
25 // chromium scenarios, which are in charge of implementing two abstract
26 // methods: GetRegistryPath() and OnBeforeLaunch().
27 class MainDllLoader {
28 public:
29 MainDllLoader();
30 virtual ~MainDllLoader();
32 // Loads and calls the entry point of chrome.dll. |instance| is the exe
33 // instance retrieved from wWinMain.
34 // The return value is what the main entry point of chrome.dll returns
35 // upon termination.
36 int Launch(HINSTANCE instance);
38 // Launches a new instance of the browser if the current instance in
39 // persistent mode an upgrade is detected.
40 void RelaunchChromeBrowserWithNewCommandLineIfNeeded();
42 protected:
43 // Called after chrome.dll has been loaded but before the entry point
44 // is invoked. Derived classes can implement custom actions here.
45 // |process_type| is the argument to the --type command line argument, e.g.
46 // "renderer", "watcher", etc.
47 // |dll_path| refers to the path of the Chrome dll being loaded.
48 virtual void OnBeforeLaunch(const std::string& process_type,
49 const base::FilePath& 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::FilePath& dll_path) = 0;
56 private:
57 // Loads chrome.dll, populating |version| with the version of the DLL loaded
58 // and |module| with the path of the loaded DLL. Returns a reference to the
59 // module, or null on failure.
60 HMODULE Load(base::string16* version, base::FilePath* module);
62 private:
63 HMODULE dll_;
64 std::string process_type_;
65 const bool metro_mode_;
68 // Factory for the MainDllLoader. Caller owns the pointer and should call
69 // delete to free it.
70 MainDllLoader* MakeMainDllLoader();
72 #endif // CHROME_APP_CLIENT_UTIL_H_