Skip to content
This repository has been archived by the owner on Oct 12, 2022. It is now read-only.

Commit

Permalink
Improved finding where Chrome is installed and added an error message
Browse files Browse the repository at this point in the history
in the case where we cannot find Chrome.
  • Loading branch information
alexcope committed May 1, 2015
1 parent 877fc0f commit bed03a6
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 10 deletions.
26 changes: 17 additions & 9 deletions IEDiagnosticsAdapter/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include "Helpers.h"
#include <iostream>
#include <Shellapi.h>
#include <Shlobj.h>

CHandle hChromeProcess;

Expand All @@ -33,29 +34,30 @@ int wmain(int argc, wchar_t* argv[])
CString chromePath;

// Find the chrome install location via the registry
CString keyPath;
keyPath.Format(L"SOFTWARE\\%sMicrosoft\\Windows\\CurrentVersion\\Uninstall\\Google Chrome", (Helpers::Is64OS() ? L"Wow6432Node\\" : L""));
CString keyPath = L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\App Paths\\chrome.exe";

CRegKey regKey;

// First see if we can find where Chrome is installed from the registry. This will only succeed if Chrome is installed for all users
if (regKey.Open(HKEY_LOCAL_MACHINE, keyPath, KEY_READ) == ERROR_SUCCESS)
{
ULONG bufferSize = MAX_PATH;
CString path;
LRESULT result = regKey.QueryStringValue(L"InstallLocation", path.GetBufferSetLength(bufferSize), &bufferSize);
LRESULT result = regKey.QueryStringValue(nullptr, path.GetBufferSetLength(bufferSize), &bufferSize);
path.ReleaseBufferSetLength(bufferSize);
if (result == ERROR_SUCCESS)
{
chromePath.Format(L"%s\\chrome.exe", path);
chromePath = path;
}
}

if (chromePath.GetLength() == 0)
{
// Default to program files instead
CString progFiles;
Helpers::ExpandEnvironmentString((Helpers::Is64OS() ? L"%ProgramFiles(x86)%" : L"%ProgramFiles%"), progFiles);

chromePath.Format(L"%s\\Google\\Chrome\\Application\\chrome.exe", progFiles);
// If Chrome is only installed for the current user, look in \AppData\Local\Google\Chrome\Application\ for Chrome.exe
CString appPath;
::SHGetFolderPath(NULL, CSIDL_LOCAL_APPDATA, NULL, SHGFP_TYPE_CURRENT, appPath.GetBuffer(MAX_PATH + 1));
appPath.ReleaseBuffer();
chromePath = appPath + L"\\Google\\Chrome\\Application\\chrome.exe";
}

// Get a temp location
Expand Down Expand Up @@ -92,6 +94,12 @@ int wmain(int argc, wchar_t* argv[])
hChromeProcess.Attach(pi.hProcess);
DWORD waitResult = ::WaitForInputIdle(hChromeProcess, 30000);
}
else
{
std::cerr << "Could not open Chrome. Please ensure that Chrome is installed." << std::endl;
system("pause");
return -1;
}
}

// Get the current path that we are running from
Expand Down
2 changes: 1 addition & 1 deletion IEWebKitImpl/Browser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ module Proxy {
break;
case "Worker":
if (methodParts[1] === "canInspectWorkers") {
var processedResult: IWebKitResult = { result: false};
var processedResult: IWebKitResult = { result: false };
browserHandler.postResponse(request.id, processedResult);
}
break;
Expand Down
3 changes: 3 additions & 0 deletions IEWebKitImpl/Page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,15 @@ module Proxy {
case "getResourceTree":
processedResult = this.getResourceTree(request);
break;

case "canScreencast":
processedResult = { result: false };
break;

case "canEmulate":
processedResult = { result: false };
break;

default:
processedResult = null;
break;
Expand Down

0 comments on commit bed03a6

Please sign in to comment.