Skip to content
This repository was archived by the owner on Dec 6, 2022. It is now read-only.

Call host to launch Chrome unelevated if host sends supportsLaunchUnelevatedProcessRequest flag.#676

Merged
roblourens merged 1 commit into
microsoft:masterfrom
changsi-an:master
Jun 4, 2018
Merged

Call host to launch Chrome unelevated if host sends supportsLaunchUnelevatedProcessRequest flag.#676
roblourens merged 1 commit into
microsoft:masterfrom
changsi-an:master

Conversation

@changsi-an

Copy link
Copy Markdown
Contributor

host sends supportsLaunchUnelevatedProcessRequest flag.

Now PZ host is capable of supporting a launchUnelevated request from DA. If supportsLaunchUnelevatedProcessRequest flag is set through initialize request, DA will choose to use host's ability to launch Chrome unelevated (when needed).

spawnChromeUnelevatedWithWindowsScriptHost() is extracted old code.

spawnChromeUnelevatedWithPineZorro() is the new logic to ask host to launch Chrome unelevated.

@changsi-an

Copy link
Copy Markdown
Contributor Author

@digeff @roblourens @rakatyal

@changsi-an changsi-an changed the title Call host to launch Chrome unelevated if Call host to launch Chrome unelevated if host sends supportsLaunchUnelevatedProcessRequest flag. Jun 1, 2018
Comment thread src/chromeDebugAdapter.ts

private async spawnChromeUnelevatedWithPineZorro(chromePath: string, chromeArgs: string[]): Promise<number> {
return new Promise<number>((resolve, reject) => {
this._session.sendRequest("launchUnelevated", {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We are wrapping sendRequest in a promise in a similar way here: https://github.com/Microsoft/vscode-chrome-debug-core/blob/47782a37b6df5efd3a50bf1813019c0068a984fe/src/transformers/fallbackToClientPathTransformer.ts#L36
Would it make sense to extract the async sendRequest logic someplace else?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does it need telemetry?

@changsi-an changsi-an Jun 1, 2018

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@digeff The two usages are not quite the same, they are very different in the parameters they each have respectively. Having a common utility function will carry the different parameters as well, it almost like repeating this code. So extracting a common logic does not improve much, but reduces readability.

@roblourens if the operation does not succeed it will reject, and the call will get an exception thrown then telemetry handler will capture that. Otherwise, there is C# telemetry implemented in the host for each PZ extension request.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@changsi-an would we know from the telemetry that the error happened because of Chrome launch failure when running as Administrator?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dhanvikapila Yes, the admin flag is right on the same DA event (clientRequest/launch). The C# error is on a separate event.

Comment thread src/chromeDebugAdapter.ts Outdated
logger.log(`Parsed output file and got Chrome PID ${pidStr}`);
this._chromePID = parseInt(pidStr, 10);
if (this._doesHostSupportLaunchUnelevatedProcessRequest) {
chromePid = await this.spawnChromeUnelevatedWithPineZorro(chromePath, chromeArgs);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would this be equivalent to use this._chromePID here instead?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

Comment thread src/chromeDebugAdapter.ts Outdated
'meteor://💻app/*': '${webRoot}/*'
};

interface IExtendedInitializeRequestArgumetns extends DebugProtocol.InitializeRequestArguments{

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

Comment thread src/chromeDebugAdapter.ts Outdated
return null
}

private async spawnChromeUnelevatedWithPineZorro(chromePath: string, chromeArgs: string[]): Promise<number> {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe don't name this specifically for pinezorro, just "WithClient"

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

Comment thread src/chromeDebugAdapter.ts

private async spawnChromeUnelevatedWithPineZorro(chromePath: string, chromeArgs: string[]): Promise<number> {
return new Promise<number>((resolve, reject) => {
this._session.sendRequest("launchUnelevated", {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does it need telemetry?

host sends supportsLaunchUnelevatedProcessRequest flag.
@changsi-an

Copy link
Copy Markdown
Contributor Author

PTAL

@rakatyal

rakatyal commented Jun 1, 2018

Copy link
Copy Markdown
Contributor

Can we add tests for this change?

@roblourens

Copy link
Copy Markdown
Member

@changsi-an LMK when this is ready to merge. I'm ok with or without tests.

@changsi-an

Copy link
Copy Markdown
Contributor Author

@roblourens Please help merge it now. I will submit a PR for unit test later.

@roblourens roblourens merged commit f26a832 into microsoft:master Jun 4, 2018
@roblourens roblourens added this to the June 2018 milestone Jun 29, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants