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 <windows.h> | 5 #include <windows.h> |
6 #include <shlwapi.h> | 6 #include <shlwapi.h> |
7 | 7 |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/debug/trace_event.h" | 9 #include "base/debug/trace_event.h" |
10 #include "base/environment.h" | 10 #include "base/environment.h" |
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
212 | 212 |
213 MainDllLoader::MainDllLoader() : dll_(NULL) { | 213 MainDllLoader::MainDllLoader() : dll_(NULL) { |
214 } | 214 } |
215 | 215 |
216 MainDllLoader::~MainDllLoader() { | 216 MainDllLoader::~MainDllLoader() { |
217 } | 217 } |
218 | 218 |
219 // Loading chrome is an interesting affair. First we try loading from the | 219 // Loading chrome is an interesting affair. First we try loading from the |
220 // current directory to support run-what-you-compile and other development | 220 // current directory to support run-what-you-compile and other development |
221 // scenarios. | 221 // scenarios. |
222 // If that fails then we look at the --chrome-version command line flag to | 222 // If that fails then we look at the version resource in the current |
223 // determine if we should stick with an older dll version even if a new one is | |
224 // available to support upgrade-in-place scenarios. | |
225 // If that fails then finally we look at the version resource in the current | |
226 // module. This is the expected path for chrome.exe browser instances in an | 223 // module. This is the expected path for chrome.exe browser instances in an |
227 // installed build. | 224 // installed build. |
228 HMODULE MainDllLoader::Load(base::string16* out_version, | 225 HMODULE MainDllLoader::Load(base::string16* out_version, |
229 base::string16* out_file) { | 226 base::string16* out_file) { |
230 const CommandLine& cmd_line = *CommandLine::ForCurrentProcess(); | 227 const CommandLine& cmd_line = *CommandLine::ForCurrentProcess(); |
231 const base::string16 dir(GetExecutablePath()); | 228 const base::string16 dir(GetExecutablePath()); |
232 *out_file = dir; | 229 *out_file = dir; |
233 HMODULE dll = LoadChromeWithDirectory(out_file); | 230 HMODULE dll = LoadChromeWithDirectory(out_file); |
234 if (!dll) { | 231 if (!dll) { |
235 // Loading from same directory (for developers) failed. | 232 // Loading from same directory (for developers) failed. Look at the version |
236 base::string16 version_string; | 233 // resource in the current module and try loading that. |
237 if (cmd_line.HasSwitch(switches::kChromeVersion)) { | 234 base::string16 version_string(GetCurrentModuleVersion()); |
238 // This is used to support Chrome Frame, see http://crbug.com/88589. | |
239 version_string = cmd_line.GetSwitchValueNative(switches::kChromeVersion); | |
240 | |
241 if (!Version(WideToASCII(version_string)).IsValid()) { | |
242 // If a bogus command line flag was given, then abort. | |
243 LOG(ERROR) << "Invalid command line version: " << version_string; | |
244 return NULL; | |
245 } | |
246 } | |
247 | |
248 // If no version on the command line, then look at the version resource in | |
249 // the current module and try loading that. | |
250 if (version_string.empty()) | |
251 version_string = GetCurrentModuleVersion(); | |
252 | |
253 if (version_string.empty()) { | 235 if (version_string.empty()) { |
254 LOG(ERROR) << "No valid Chrome version found"; | 236 LOG(ERROR) << "No valid Chrome version found"; |
255 return NULL; | 237 return NULL; |
256 } | 238 } |
257 | 239 |
258 *out_file = dir; | 240 *out_file = dir; |
259 *out_version = version_string; | 241 *out_version = version_string; |
260 out_file->append(*out_version).append(1, L'\\'); | 242 out_file->append(*out_version).append(1, L'\\'); |
261 dll = LoadChromeWithDirectory(out_file); | 243 dll = LoadChromeWithDirectory(out_file); |
262 if (!dll) { | 244 if (!dll) { |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
351 } | 333 } |
352 }; | 334 }; |
353 | 335 |
354 MainDllLoader* MakeMainDllLoader() { | 336 MainDllLoader* MakeMainDllLoader() { |
355 #if defined(GOOGLE_CHROME_BUILD) | 337 #if defined(GOOGLE_CHROME_BUILD) |
356 return new ChromeDllLoader(); | 338 return new ChromeDllLoader(); |
357 #else | 339 #else |
358 return new ChromiumDllLoader(); | 340 return new ChromiumDllLoader(); |
359 #endif | 341 #endif |
360 } | 342 } |
OLD | NEW |