Add kelvinp@chromium.org to remoting/OWNERS
[chromium-blink-merge.git] / win8 / delegate_execute / command_execute_impl.h
blobf45bcc969db14d3471afd986d43f215220f96ed4
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.
5 #include <atlbase.h>
6 #include <atlcom.h>
7 #include <atlctl.h>
8 #include <ShObjIdl.h>
9 #include <WinInet.h>
11 #include <string>
13 #include "base/command_line.h"
14 #include "base/files/file_path.h"
15 #include "base/process/process_handle.h"
16 #include "win8/delegate_execute/resource.h" // main symbols
18 EXTERN_C const GUID CLSID_CommandExecuteImpl;
20 // CommandExecuteImpl
21 // This class implements the IExecuteCommand and related interfaces for
22 // handling ShellExecute launches of the Chrome browser, i.e. whether to
23 // launch Chrome in metro mode or desktop mode.
24 // The CLSID here is a dummy CLSID not used for anything, since we register
25 // the class with a dynamic CLSID. However, a static CLSID is necessary
26 // so that we can force at least one entry into ATL's object map (it will
27 // treat a 0-element object map as an initialization failure case).
28 class ATL_NO_VTABLE DECLSPEC_UUID("071BB5F2-85A4-424F-BFE7-5F1609BE4C2C")
29 CommandExecuteImpl
30 : public CComObjectRootEx<CComSingleThreadModel>,
31 public CComCoClass<CommandExecuteImpl, &CLSID_CommandExecuteImpl>,
32 public IExecuteCommand,
33 public IObjectWithSiteImpl<CommandExecuteImpl>,
34 public IInitializeCommand,
35 public IObjectWithSelection,
36 public IExecuteCommandApplicationHostEnvironment,
37 public IForegroundTransfer {
38 public:
39 CommandExecuteImpl();
41 DECLARE_REGISTRY_RESOURCEID(IDR_COMMANDEXECUTEIMPL)
43 BEGIN_COM_MAP(CommandExecuteImpl)
44 COM_INTERFACE_ENTRY(IExecuteCommand)
45 COM_INTERFACE_ENTRY(IObjectWithSite)
46 COM_INTERFACE_ENTRY(IInitializeCommand)
47 COM_INTERFACE_ENTRY(IObjectWithSelection)
48 COM_INTERFACE_ENTRY(IExecuteCommandApplicationHostEnvironment)
49 COM_INTERFACE_ENTRY(IForegroundTransfer)
50 END_COM_MAP()
52 DECLARE_PROTECT_FINAL_CONSTRUCT()
54 HRESULT FinalConstruct() {
55 return S_OK;
58 void FinalRelease() {
61 public:
62 // IExecuteCommand
63 STDMETHOD(SetKeyState)(DWORD key_state);
64 STDMETHOD(SetParameters)(LPCWSTR params);
65 STDMETHOD(SetPosition)(POINT pt);
66 STDMETHOD(SetShowWindow)(int show);
67 STDMETHOD(SetNoShowUI)(BOOL no_show_ui);
68 STDMETHOD(SetDirectory)(LPCWSTR directory);
69 STDMETHOD(Execute)(void);
71 // IInitializeCommand
72 STDMETHOD(Initialize)(LPCWSTR name, IPropertyBag* bag);
74 // IObjectWithSelection
75 STDMETHOD(SetSelection)(IShellItemArray* item_array);
76 STDMETHOD(GetSelection)(REFIID riid, void** selection);
78 // IExecuteCommandApplicationHostEnvironment
79 STDMETHOD(GetValue)(enum AHE_TYPE* pahe);
81 // IForegroundTransfer
82 STDMETHOD(AllowForegroundTransfer)(void* reserved);
84 static bool FindChromeExe(base::FilePath* chrome_exe);
86 private:
88 static bool path_provider_initialized_;
90 bool GetLaunchScheme(base::string16* display_name, INTERNET_SCHEME* scheme);
91 HRESULT LaunchDesktopChrome();
92 // Returns the launch mode, i.e. desktop launch/metro launch, etc.
93 EC_HOST_UI_MODE GetLaunchMode();
95 CComPtr<IShellItemArray> item_array_;
96 base::CommandLine parameters_;
97 base::FilePath chrome_exe_;
98 STARTUPINFO start_info_;
99 base::string16 verb_;
100 base::string16 display_name_;
101 INTERNET_SCHEME launch_scheme_;
103 base::IntegrityLevel integrity_level_;
106 OBJECT_ENTRY_AUTO(__uuidof(CommandExecuteImpl), CommandExecuteImpl)