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

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

Issue 1633021: Detect new instance of the browser when running in the background in persiste... (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: '' Created 10 years, 7 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
« no previous file with comments | « chrome/app/client_util.h ('k') | chrome/browser/browser_main.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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 "chrome/app/breakpad_win.h" 8 #include "chrome/app/breakpad_win.h"
9 #include "chrome/app/client_util.h" 9 #include "chrome/app/client_util.h"
10 #include "chrome/common/chrome_switches.h" 10 #include "chrome/common/chrome_switches.h"
11 #include "chrome/common/result_codes.h" 11 #include "chrome/common/result_codes.h"
12 #include "chrome/installer/util/browser_distribution.h" 12 #include "chrome/installer/util/browser_distribution.h"
13 #include "chrome/installer/util/install_util.h" 13 #include "chrome/installer/util/install_util.h"
14 #include "chrome/installer/util/google_update_constants.h" 14 #include "chrome/installer/util/google_update_constants.h"
15 #include "chrome/installer/util/util_constants.h" 15 #include "chrome/installer/util/util_constants.h"
16 16
17 namespace { 17 namespace {
18 // The entry point signature of chrome.dll. 18 // The entry point signature of chrome.dll.
19 typedef int (*DLL_MAIN)(HINSTANCE, sandbox::SandboxInterfaceInfo*, wchar_t*); 19 typedef int (*DLL_MAIN)(HINSTANCE, sandbox::SandboxInterfaceInfo*, wchar_t*);
20 20
21 typedef void (*RelaunchChromeBrowserWithNewCommandLineIfNeededFunc)();
22
21 // Not generic, we only handle strings up to 128 chars. 23 // Not generic, we only handle strings up to 128 chars.
22 bool ReadRegistryStr(HKEY key, const wchar_t* name, std::wstring* value) { 24 bool ReadRegistryStr(HKEY key, const wchar_t* name, std::wstring* value) {
23 BYTE out[128 * sizeof(wchar_t)]; 25 BYTE out[128 * sizeof(wchar_t)];
24 DWORD size = sizeof(out); 26 DWORD size = sizeof(out);
25 DWORD type = 0; 27 DWORD type = 0;
26 if (ERROR_SUCCESS != ::RegQueryValueExW(key, name, NULL, &type, out, &size)) 28 if (ERROR_SUCCESS != ::RegQueryValueExW(key, name, NULL, &type, out, &size))
27 return false; 29 return false;
28 if (type != REG_SZ) 30 if (type != REG_SZ)
29 return false; 31 return false;
30 value->assign(reinterpret_cast<wchar_t*>(out)); 32 value->assign(reinterpret_cast<wchar_t*>(out));
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 191
190 DLL_MAIN entry_point = 192 DLL_MAIN entry_point =
191 reinterpret_cast<DLL_MAIN>(::GetProcAddress(dll_, "ChromeMain")); 193 reinterpret_cast<DLL_MAIN>(::GetProcAddress(dll_, "ChromeMain"));
192 if (!entry_point) 194 if (!entry_point)
193 return ResultCodes::BAD_PROCESS_TYPE; 195 return ResultCodes::BAD_PROCESS_TYPE;
194 196
195 int rc = entry_point(instance, sbox_info, ::GetCommandLineW()); 197 int rc = entry_point(instance, sbox_info, ::GetCommandLineW());
196 return OnBeforeExit(rc); 198 return OnBeforeExit(rc);
197 } 199 }
198 200
201 void MainDllLoader::RelaunchChromeBrowserWithNewCommandLineIfNeeded() {
202 RelaunchChromeBrowserWithNewCommandLineIfNeededFunc relaunch_function =
203 reinterpret_cast<RelaunchChromeBrowserWithNewCommandLineIfNeededFunc>(
204 ::GetProcAddress(dll_,
205 "RelaunchChromeBrowserWithNewCommandLineIfNeeded"));
206 if (!relaunch_function) {
207 LOG(ERROR) << "Could not find exported function "
208 << "RelaunchChromeBrowserWithNewCommandLineIfNeeded";
209 } else {
210 relaunch_function();
211 }
212 }
213
199 //============================================================================= 214 //=============================================================================
200 215
201 class ChromeDllLoader : public MainDllLoader { 216 class ChromeDllLoader : public MainDllLoader {
202 public: 217 public:
203 virtual std::wstring GetRegistryPath() { 218 virtual std::wstring GetRegistryPath() {
204 std::wstring key(google_update::kRegPathClients); 219 std::wstring key(google_update::kRegPathClients);
205 BrowserDistribution* dist = BrowserDistribution::GetDistribution(); 220 BrowserDistribution* dist = BrowserDistribution::GetDistribution();
206 key.append(L"\\").append(dist->GetAppGuid()); 221 key.append(L"\\").append(dist->GetAppGuid());
207 return key; 222 return key;
208 } 223 }
(...skipping 25 matching lines...) Expand all
234 } 249 }
235 }; 250 };
236 251
237 MainDllLoader* MakeMainDllLoader() { 252 MainDllLoader* MakeMainDllLoader() {
238 #if defined(GOOGLE_CHROME_BUILD) 253 #if defined(GOOGLE_CHROME_BUILD)
239 return new ChromeDllLoader(); 254 return new ChromeDllLoader();
240 #else 255 #else
241 return new ChromiumDllLoader(); 256 return new ChromiumDllLoader();
242 #endif 257 #endif
243 } 258 }
OLDNEW
« no previous file with comments | « chrome/app/client_util.h ('k') | chrome/browser/browser_main.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698