Do not use MockQuadCuller when only testing with RenderPass
[chromium-blink-merge.git] / win8 / delegate_execute / command_execute_impl.h
blob72e1085cf9d4b4c4a0c3b94fac77ec2169f4ac08
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 using namespace ATL;
20 EXTERN_C const GUID CLSID_CommandExecuteImpl;
22 // CommandExecuteImpl
23 // This class implements the IExecuteCommand and related interfaces for
24 // handling ShellExecute launches of the Chrome browser, i.e. whether to
25 // launch Chrome in metro mode or desktop mode.
26 // The CLSID here is a dummy CLSID not used for anything, since we register
27 // the class with a dynamic CLSID. However, a static CLSID is necessary
28 // so that we can force at least one entry into ATL's object map (it will
29 // treat a 0-element object map as an initialization failure case).
30 class ATL_NO_VTABLE DECLSPEC_UUID("071BB5F2-85A4-424F-BFE7-5F1609BE4C2C")
31 CommandExecuteImpl
32 : public CComObjectRootEx<CComSingleThreadModel>,
33 public CComCoClass<CommandExecuteImpl, &CLSID_CommandExecuteImpl>,
34 public IExecuteCommand,
35 public IObjectWithSiteImpl<CommandExecuteImpl>,
36 public IInitializeCommand,
37 public IObjectWithSelection,
38 public IExecuteCommandApplicationHostEnvironment,
39 public IForegroundTransfer {
40 public:
41 CommandExecuteImpl();
43 DECLARE_REGISTRY_RESOURCEID(IDR_COMMANDEXECUTEIMPL)
45 BEGIN_COM_MAP(CommandExecuteImpl)
46 COM_INTERFACE_ENTRY(IExecuteCommand)
47 COM_INTERFACE_ENTRY(IObjectWithSite)
48 COM_INTERFACE_ENTRY(IInitializeCommand)
49 COM_INTERFACE_ENTRY(IObjectWithSelection)
50 COM_INTERFACE_ENTRY(IExecuteCommandApplicationHostEnvironment)
51 COM_INTERFACE_ENTRY(IForegroundTransfer)
52 END_COM_MAP()
54 DECLARE_PROTECT_FINAL_CONSTRUCT()
56 HRESULT FinalConstruct() {
57 return S_OK;
60 void FinalRelease() {
63 public:
64 // IExecuteCommand
65 STDMETHOD(SetKeyState)(DWORD key_state);
66 STDMETHOD(SetParameters)(LPCWSTR params);
67 STDMETHOD(SetPosition)(POINT pt);
68 STDMETHOD(SetShowWindow)(int show);
69 STDMETHOD(SetNoShowUI)(BOOL no_show_ui);
70 STDMETHOD(SetDirectory)(LPCWSTR directory);
71 STDMETHOD(Execute)(void);
73 // IInitializeCommand
74 STDMETHOD(Initialize)(LPCWSTR name, IPropertyBag* bag);
76 // IObjectWithSelection
77 STDMETHOD(SetSelection)(IShellItemArray* item_array);
78 STDMETHOD(GetSelection)(REFIID riid, void** selection);
80 // IExecuteCommandApplicationHostEnvironment
81 STDMETHOD(GetValue)(enum AHE_TYPE* pahe);
83 // IForegroundTransfer
84 STDMETHOD(AllowForegroundTransfer)(void* reserved);
86 private:
87 static bool FindChromeExe(base::FilePath* chrome_exe);
89 static bool path_provider_initialized_;
91 bool GetLaunchScheme(base::string16* display_name, INTERNET_SCHEME* scheme);
92 HRESULT LaunchDesktopChrome();
93 // Returns the launch mode, i.e. desktop launch/metro launch, etc.
94 EC_HOST_UI_MODE GetLaunchMode();
96 CComPtr<IShellItemArray> item_array_;
97 base::CommandLine parameters_;
98 base::FilePath chrome_exe_;
99 STARTUPINFO start_info_;
100 base::string16 verb_;
101 base::string16 display_name_;
102 INTERNET_SCHEME launch_scheme_;
104 base::IntegrityLevel integrity_level_;
107 OBJECT_ENTRY_AUTO(__uuidof(CommandExecuteImpl), CommandExecuteImpl)