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

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

Issue 7377010: This change will split the result codes between content and chrome. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: actually rename the files Created 9 years, 5 months 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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"
11 #include "base/file_util.h" 11 #include "base/file_util.h"
12 #include "base/logging.h" 12 #include "base/logging.h"
13 #include "base/memory/scoped_ptr.h" 13 #include "base/memory/scoped_ptr.h"
14 #include "base/win/registry.h" 14 #include "base/win/registry.h"
15 #include "base/string_util.h" 15 #include "base/string_util.h"
16 #include "base/utf_string_conversions.h" 16 #include "base/utf_string_conversions.h"
17 #include "base/version.h" 17 #include "base/version.h"
18 #include "chrome/app/breakpad_win.h" 18 #include "chrome/app/breakpad_win.h"
19 #include "chrome/app/client_util.h" 19 #include "chrome/app/client_util.h"
20 #include "chrome/common/chrome_constants.h" 20 #include "chrome/common/chrome_constants.h"
21 #include "chrome/common/chrome_result_codes.h"
21 #include "chrome/common/chrome_switches.h" 22 #include "chrome/common/chrome_switches.h"
22 #include "chrome/installer/util/browser_distribution.h" 23 #include "chrome/installer/util/browser_distribution.h"
23 #include "chrome/installer/util/channel_info.h" 24 #include "chrome/installer/util/channel_info.h"
24 #include "chrome/installer/util/install_util.h" 25 #include "chrome/installer/util/install_util.h"
25 #include "chrome/installer/util/google_update_constants.h" 26 #include "chrome/installer/util/google_update_constants.h"
26 #include "chrome/installer/util/google_update_settings.h" 27 #include "chrome/installer/util/google_update_settings.h"
27 #include "chrome/installer/util/util_constants.h" 28 #include "chrome/installer/util/util_constants.h"
28 #include "content/common/result_codes.h"
29 29
30 namespace { 30 namespace {
31 // The entry point signature of chrome.dll. 31 // The entry point signature of chrome.dll.
32 typedef int (*DLL_MAIN)(HINSTANCE, sandbox::SandboxInterfaceInfo*, wchar_t*); 32 typedef int (*DLL_MAIN)(HINSTANCE, sandbox::SandboxInterfaceInfo*, wchar_t*);
33 33
34 typedef void (*RelaunchChromeBrowserWithNewCommandLineIfNeededFunc)(); 34 typedef void (*RelaunchChromeBrowserWithNewCommandLineIfNeededFunc)();
35 35
36 // Gets chrome version according to the load path. |exe_path| must be the 36 // Gets chrome version according to the load path. |exe_path| must be the
37 // backslash terminated directory of the current chrome.exe. 37 // backslash terminated directory of the current chrome.exe.
38 bool GetVersion(const wchar_t* exe_path, const wchar_t* key_path, 38 bool GetVersion(const wchar_t* exe_path, const wchar_t* key_path,
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
231 231
232 // Launching is a matter of loading the right dll, setting the CHROME_VERSION 232 // Launching is a matter of loading the right dll, setting the CHROME_VERSION
233 // environment variable and just calling the entry point. Derived classes can 233 // environment variable and just calling the entry point. Derived classes can
234 // add custom code in the OnBeforeLaunch callback. 234 // add custom code in the OnBeforeLaunch callback.
235 int MainDllLoader::Launch(HINSTANCE instance, 235 int MainDllLoader::Launch(HINSTANCE instance,
236 sandbox::SandboxInterfaceInfo* sbox_info) { 236 sandbox::SandboxInterfaceInfo* sbox_info) {
237 std::wstring version; 237 std::wstring version;
238 std::wstring file; 238 std::wstring file;
239 dll_ = Load(&version, &file); 239 dll_ = Load(&version, &file);
240 if (!dll_) 240 if (!dll_)
241 return ResultCodes::MISSING_DATA; 241 return chrome::RESULT_CODE_MISSING_DATA;
242 242
243 scoped_ptr<base::Environment> env(base::Environment::Create()); 243 scoped_ptr<base::Environment> env(base::Environment::Create());
244 env->SetVar(chrome::kChromeVersionEnvVar, WideToUTF8(version)); 244 env->SetVar(chrome::kChromeVersionEnvVar, WideToUTF8(version));
245 245
246 InitCrashReporterWithDllPath(file); 246 InitCrashReporterWithDllPath(file);
247 OnBeforeLaunch(file); 247 OnBeforeLaunch(file);
248 248
249 DLL_MAIN entry_point = 249 DLL_MAIN entry_point =
250 reinterpret_cast<DLL_MAIN>(::GetProcAddress(dll_, "ChromeMain")); 250 reinterpret_cast<DLL_MAIN>(::GetProcAddress(dll_, "ChromeMain"));
251 if (!entry_point) 251 if (!entry_point)
252 return ResultCodes::BAD_PROCESS_TYPE; 252 return content::RESULT_CODE_BAD_PROCESS_TYPE;
253 253
254 int rc = entry_point(instance, sbox_info, ::GetCommandLineW()); 254 int rc = entry_point(instance, sbox_info, ::GetCommandLineW());
255 return OnBeforeExit(rc, file); 255 return OnBeforeExit(rc, file);
256 } 256 }
257 257
258 void MainDllLoader::RelaunchChromeBrowserWithNewCommandLineIfNeeded() { 258 void MainDllLoader::RelaunchChromeBrowserWithNewCommandLineIfNeeded() {
259 RelaunchChromeBrowserWithNewCommandLineIfNeededFunc relaunch_function = 259 RelaunchChromeBrowserWithNewCommandLineIfNeededFunc relaunch_function =
260 reinterpret_cast<RelaunchChromeBrowserWithNewCommandLineIfNeededFunc>( 260 reinterpret_cast<RelaunchChromeBrowserWithNewCommandLineIfNeededFunc>(
261 ::GetProcAddress(dll_, 261 ::GetProcAddress(dll_,
262 "RelaunchChromeBrowserWithNewCommandLineIfNeeded")); 262 "RelaunchChromeBrowserWithNewCommandLineIfNeeded"));
(...skipping 17 matching lines...) Expand all
280 } 280 }
281 281
282 virtual void OnBeforeLaunch(const std::wstring& dll_path) { 282 virtual void OnBeforeLaunch(const std::wstring& dll_path) {
283 RecordDidRun(dll_path); 283 RecordDidRun(dll_path);
284 } 284 }
285 285
286 virtual int OnBeforeExit(int return_code, const std::wstring& dll_path) { 286 virtual int OnBeforeExit(int return_code, const std::wstring& dll_path) {
287 // NORMAL_EXIT_CANCEL is used for experiments when the user cancels 287 // NORMAL_EXIT_CANCEL is used for experiments when the user cancels
288 // so we need to reset the did_run signal so omaha does not count 288 // so we need to reset the did_run signal so omaha does not count
289 // this run as active usage. 289 // this run as active usage.
290 if (ResultCodes::NORMAL_EXIT_CANCEL == return_code) { 290 if (content::RESULT_CODE_NORMAL_EXIT_CANCEL == return_code) {
291 ClearDidRun(dll_path); 291 ClearDidRun(dll_path);
292 } 292 }
293 return return_code; 293 return return_code;
294 } 294 }
295 }; 295 };
296 296
297 //============================================================================= 297 //=============================================================================
298 298
299 class ChromiumDllLoader : public MainDllLoader { 299 class ChromiumDllLoader : public MainDllLoader {
300 public: 300 public:
301 virtual std::wstring GetRegistryPath() { 301 virtual std::wstring GetRegistryPath() {
302 BrowserDistribution* dist = BrowserDistribution::GetDistribution(); 302 BrowserDistribution* dist = BrowserDistribution::GetDistribution();
303 return dist->GetVersionKey(); 303 return dist->GetVersionKey();
304 } 304 }
305 }; 305 };
306 306
307 MainDllLoader* MakeMainDllLoader() { 307 MainDllLoader* MakeMainDllLoader() {
308 #if defined(GOOGLE_CHROME_BUILD) 308 #if defined(GOOGLE_CHROME_BUILD)
309 return new ChromeDllLoader(); 309 return new ChromeDllLoader();
310 #else 310 #else
311 return new ChromiumDllLoader(); 311 return new ChromiumDllLoader();
312 #endif 312 #endif
313 } 313 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698