OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 namespace NativeClientVSAddIn |
| 6 { |
| 7 using System; |
| 8 |
| 9 using EnvDTE80; |
| 10 |
| 11 /// <summary> |
| 12 /// This class handles the details of finding a pepper plugin and attaching to
it. |
| 13 /// </summary> |
| 14 public class PluginDebuggerVS : PluginDebuggerBase |
| 15 { |
| 16 /// <summary> |
| 17 /// Path to the actual plug-in assembly. |
| 18 /// </summary> |
| 19 private string pluginAssembly_; |
| 20 |
| 21 /// <summary> |
| 22 /// Constructs the PluginDebuggerHelper. |
| 23 /// </summary> |
| 24 /// <param name="dte">Automation object from Visual Studio.</param> |
| 25 /// <param name="properties">PropertyManager pointing to a valid project/pla
tform.</param> |
| 26 public PluginDebuggerVS(DTE2 dte, PropertyManager properties) |
| 27 : base(dte, properties) |
| 28 { |
| 29 pluginAssembly_ = properties.PluginAssembly; |
| 30 PluginFoundEvent += new EventHandler<PluginFoundEventArgs>(Attach); |
| 31 } |
| 32 |
| 33 /// <summary> |
| 34 /// Called to check if a process is a valid pepper plugin to attach to. |
| 35 /// </summary> |
| 36 /// <param name="proc">Contains information about the process in question.</
param> |
| 37 /// <param name="mainChromeFlags">Flags on the main Chrome process.</param> |
| 38 /// <returns>True if we should attach to the process.</returns> |
| 39 protected override bool IsPluginProcess(ProcessInfo proc, string mainChromeF
lags) |
| 40 { |
| 41 StringComparison ignoreCase = StringComparison.InvariantCultureIgnoreCase; |
| 42 string identifierFlagTarget = |
| 43 string.Format(Strings.PepperProcessPluginFlagFormat, pluginAssembl
y_); |
| 44 return proc.Name.Equals(Strings.ChromeProcessName, ignoreCase) && |
| 45 proc.CommandLine.Contains(Strings.ChromeRendererFlag, ignoreCase) &
& |
| 46 proc.CommandLine.Contains(identifierFlagTarget, ignoreCase); |
| 47 } |
| 48 |
| 49 /// <summary> |
| 50 /// Attaches the Visual Studio debugger to the given process ID. |
| 51 /// </summary> |
| 52 /// <param name="src">The parameter is not used.</param> |
| 53 /// <param name="args">Contains the process ID to attach to.</param> |
| 54 private void Attach(object src, PluginFoundEventArgs args) |
| 55 { |
| 56 foreach (EnvDTE.Process proc in Dte.Debugger.LocalProcesses) |
| 57 { |
| 58 if (proc.ProcessID == args.ProcessID) |
| 59 { |
| 60 proc.Attach(); |
| 61 break; |
| 62 } |
| 63 } |
| 64 } |
| 65 } |
| 66 } |
OLD | NEW |