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 #include "metro_driver_win.h" | 5 #include "metro_driver_win.h" |
6 | 6 |
7 #include <string.h> | 7 #include <string.h> |
8 | 8 |
9 #include "chrome/app/client_util.h" | 9 #include "chrome/app/client_util.h" |
10 #include "chrome/common/chrome_constants.h" | 10 #include "chrome/common/chrome_constants.h" |
(...skipping 28 matching lines...) Expand all Loading... |
39 return; | 39 return; |
40 } | 40 } |
41 // We haven't tried to load the metro driver, this probably means we are the | 41 // We haven't tried to load the metro driver, this probably means we are the |
42 // browser. Find it or not we set the environment variable because we don't | 42 // browser. Find it or not we set the environment variable because we don't |
43 // want to keep trying in the child processes. | 43 // want to keep trying in the child processes. |
44 HMODULE metro_dll = ::LoadLibraryW(chrome::kMetroDriverDll); | 44 HMODULE metro_dll = ::LoadLibraryW(chrome::kMetroDriverDll); |
45 if (!metro_dll) { | 45 if (!metro_dll) { |
46 // It is not next to the build output, so this must be an actual deployment | 46 // It is not next to the build output, so this must be an actual deployment |
47 // and in that case we need the mainloader to find the current version | 47 // and in that case we need the mainloader to find the current version |
48 // directory. | 48 // directory. |
49 string16 version(GetCurrentModuleVersion()); | 49 base::string16 version(GetCurrentModuleVersion()); |
50 if (!version.empty()) { | 50 if (!version.empty()) { |
51 std::wstring exe_path(GetExecutablePath()); | 51 std::wstring exe_path(GetExecutablePath()); |
52 exe_path.append(version).append(L"\\").append(chrome::kMetroDriverDll); | 52 exe_path.append(version).append(L"\\").append(chrome::kMetroDriverDll); |
53 metro_dll = ::LoadLibraryW(exe_path.c_str()); | 53 metro_dll = ::LoadLibraryW(exe_path.c_str()); |
54 } | 54 } |
55 } | 55 } |
56 // We set the environment variable always, so we don't keep trying in | 56 // We set the environment variable always, so we don't keep trying in |
57 // the child processes. | 57 // the child processes. |
58 ::SetEnvironmentVariableA(kMetroModeEnvVar, metro_dll ? "1" : "0"); | 58 ::SetEnvironmentVariableA(kMetroModeEnvVar, metro_dll ? "1" : "0"); |
59 if (!metro_dll) | 59 if (!metro_dll) |
60 return; | 60 return; |
61 init_metro_fn_ = ::GetProcAddress(metro_dll, "InitMetro"); | 61 init_metro_fn_ = ::GetProcAddress(metro_dll, "InitMetro"); |
62 } | 62 } |
63 | 63 |
64 int MetroDriver::RunInMetro(HINSTANCE instance, MainFn main_fn) { | 64 int MetroDriver::RunInMetro(HINSTANCE instance, MainFn main_fn) { |
65 Context* context = new Context; | 65 Context* context = new Context; |
66 context->fn = main_fn; | 66 context->fn = main_fn; |
67 context->instance = instance; | 67 context->instance = instance; |
68 | 68 |
69 return reinterpret_cast<InitMetro>(init_metro_fn_)(&MainThread, context); | 69 return reinterpret_cast<InitMetro>(init_metro_fn_)(&MainThread, context); |
70 } | 70 } |
OLD | NEW |