OLD | NEW |
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 utility functions that can report details about the |
6 // host operating environment. | 6 // host operating environment. |
7 | 7 |
8 #ifndef CHROME_APP_CLIENT_UTIL_H_ | 8 #ifndef CHROME_APP_CLIENT_UTIL_H_ |
9 #define CHROME_APP_CLIENT_UTIL_H_ | 9 #define CHROME_APP_CLIENT_UTIL_H_ |
10 | 10 |
11 #include <windows.h> | 11 #include <windows.h> |
12 | 12 |
13 #include "base/strings/string16.h" | 13 #include "base/strings/string16.h" |
14 | 14 |
15 namespace sandbox { | 15 namespace sandbox { |
16 struct SandboxInterfaceInfo; | 16 struct SandboxInterfaceInfo; |
17 } | 17 } |
18 | 18 |
19 // Gets the path of the current exe with a trailing backslash. | 19 // Gets the path of the current exe with a trailing backslash. |
20 string16 GetExecutablePath(); | 20 base::string16 GetExecutablePath(); |
21 | 21 |
22 // Returns the version in the current module's version resource or the empty | 22 // Returns the version in the current module's version resource or the empty |
23 // string if none found. | 23 // string if none found. |
24 string16 GetCurrentModuleVersion(); | 24 base::string16 GetCurrentModuleVersion(); |
25 | 25 |
26 // Implements the common aspects of loading chrome.dll for both chrome and | 26 // Implements the common aspects of loading chrome.dll for both chrome and |
27 // chromium scenarios, which are in charge of implementing two abstract | 27 // chromium scenarios, which are in charge of implementing two abstract |
28 // methods: GetRegistryPath() and OnBeforeLaunch(). | 28 // methods: GetRegistryPath() and OnBeforeLaunch(). |
29 class MainDllLoader { | 29 class MainDllLoader { |
30 public: | 30 public: |
31 MainDllLoader(); | 31 MainDllLoader(); |
32 virtual ~MainDllLoader(); | 32 virtual ~MainDllLoader(); |
33 | 33 |
34 // Loads and calls the entry point of chrome.dll. |instance| is the exe | 34 // Loads and calls the entry point of chrome.dll. |instance| is the exe |
35 // instance retrieved from wWinMain and the |sbox_info| is the broker or | 35 // instance retrieved from wWinMain and the |sbox_info| is the broker or |
36 // target services interface pointer. | 36 // target services interface pointer. |
37 // The return value is what the main entry point of chrome.dll returns | 37 // The return value is what the main entry point of chrome.dll returns |
38 // upon termination. | 38 // upon termination. |
39 int Launch(HINSTANCE instance, sandbox::SandboxInterfaceInfo* sbox_info); | 39 int Launch(HINSTANCE instance, sandbox::SandboxInterfaceInfo* sbox_info); |
40 | 40 |
41 // Launches a new instance of the browser if the current instance in | 41 // Launches a new instance of the browser if the current instance in |
42 // persistent mode an upgrade is detected. | 42 // persistent mode an upgrade is detected. |
43 void RelaunchChromeBrowserWithNewCommandLineIfNeeded(); | 43 void RelaunchChromeBrowserWithNewCommandLineIfNeeded(); |
44 | 44 |
45 // Called after chrome.dll has been loaded but before the entry point | 45 // Called after chrome.dll has been loaded but before the entry point |
46 // is invoked. Derived classes can implement custom actions here. | 46 // is invoked. Derived classes can implement custom actions here. |
47 // |dll_path| refers to the path of the Chrome dll being loaded. | 47 // |dll_path| refers to the path of the Chrome dll being loaded. |
48 virtual void OnBeforeLaunch(const string16& dll_path) {} | 48 virtual void OnBeforeLaunch(const base::string16& dll_path) {} |
49 | 49 |
50 // Called after the chrome.dll entry point returns and before terminating | 50 // Called after the chrome.dll entry point returns and before terminating |
51 // this process. The return value will be used as the process return code. | 51 // this process. The return value will be used as the process return code. |
52 // |dll_path| refers to the path of the Chrome dll being loaded. | 52 // |dll_path| refers to the path of the Chrome dll being loaded. |
53 virtual int OnBeforeExit(int return_code, const string16& dll_path) { | 53 virtual int OnBeforeExit(int return_code, const base::string16& dll_path) { |
54 return return_code; | 54 return return_code; |
55 } | 55 } |
56 | 56 |
57 protected: | 57 protected: |
58 // Derived classes must return the relative registry path that holds the | 58 // Derived classes must return the relative registry path that holds the |
59 // most current version of chrome.dll. | 59 // most current version of chrome.dll. |
60 virtual string16 GetRegistryPath() = 0; | 60 virtual base::string16 GetRegistryPath() = 0; |
61 | 61 |
62 HMODULE Load(string16* out_version, string16* out_file); | 62 HMODULE Load(base::string16* out_version, base::string16* out_file); |
63 | 63 |
64 private: | 64 private: |
65 // Chrome.dll handle. | 65 // Chrome.dll handle. |
66 HMODULE dll_; | 66 HMODULE dll_; |
67 }; | 67 }; |
68 | 68 |
69 // Factory for the MainDllLoader. Caller owns the pointer and should call | 69 // Factory for the MainDllLoader. Caller owns the pointer and should call |
70 // delete to free it. | 70 // delete to free it. |
71 MainDllLoader* MakeMainDllLoader(); | 71 MainDllLoader* MakeMainDllLoader(); |
72 | 72 |
73 #endif // CHROME_APP_CLIENT_UTIL_H_ | 73 #endif // CHROME_APP_CLIENT_UTIL_H_ |
OLD | NEW |