Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(203)

Side by Side Diff: chrome/app/client_util.h

Issue 1402353011: Expose a function to get the path to a DLL. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // This file defines utility functions that can report details about the 5 // This file defines a utility function to get the full path of a module.
6 // host operating environment.
7 6
8 #ifndef CHROME_APP_CLIENT_UTIL_H_ 7 #ifndef CHROME_APP_CLIENT_UTIL_H_
9 #define CHROME_APP_CLIENT_UTIL_H_ 8 #define CHROME_APP_CLIENT_UTIL_H_
10 9
11 #include <windows.h> 10 #include "base/files/file_path.h"
12
13 #include <string>
14 #include "base/strings/string16.h" 11 #include "base/strings/string16.h"
15 12
16 namespace sandbox { 13 // Returns the full path to a module named |module_name|, or an empty path if
17 struct SandboxInterfaceInfo; 14 // the module is not found. On output, |version| is populated with the version
18 } 15 // of the module.
19 16 base::FilePath GetModulePath(const base::char16* module_name,
20 // Returns the version in the current module's version resource or the empty 17 base::string16* version);
21 // string if none found.
22 base::string16 GetCurrentModuleVersion();
23
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();
31
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);
37
38 // Launches a new instance of the browser if the current instance in
39 // persistent mode an upgrade is detected.
40 void RelaunchChromeBrowserWithNewCommandLineIfNeeded();
41
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;
50
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;
55
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);
61
62 private:
63 HMODULE dll_;
64 std::string process_type_;
65 const bool metro_mode_;
66 };
67
68 // Factory for the MainDllLoader. Caller owns the pointer and should call
69 // delete to free it.
70 MainDllLoader* MakeMainDllLoader();
71 18
72 #endif // CHROME_APP_CLIENT_UTIL_H_ 19 #endif // CHROME_APP_CLIENT_UTIL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698