Update V8 to version 4.7.21.
[chromium-blink-merge.git] / win8 / delegate_execute / command_execute_impl.h
blobd7b60de713ce8db0d1010efdef7bd89e7d3825d3
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_info.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();
40 ~CommandExecuteImpl() override;
42 DECLARE_REGISTRY_RESOURCEID(IDR_COMMANDEXECUTEIMPL)
44 BEGIN_COM_MAP(CommandExecuteImpl)
45 COM_INTERFACE_ENTRY(IExecuteCommand)
46 COM_INTERFACE_ENTRY(IObjectWithSite)
47 COM_INTERFACE_ENTRY(IInitializeCommand)
48 COM_INTERFACE_ENTRY(IObjectWithSelection)
49 COM_INTERFACE_ENTRY(IExecuteCommandApplicationHostEnvironment)
50 COM_INTERFACE_ENTRY(IForegroundTransfer)
51 END_COM_MAP()
53 DECLARE_PROTECT_FINAL_CONSTRUCT()
55 HRESULT FinalConstruct() {
56 return S_OK;
59 void FinalRelease() {
62 public:
63 // IExecuteCommand
64 STDMETHOD(SetKeyState)(DWORD key_state) override;
65 STDMETHOD(SetParameters)(LPCWSTR params) override;
66 STDMETHOD(SetPosition)(POINT pt) override;
67 STDMETHOD(SetShowWindow)(int show) override;
68 STDMETHOD(SetNoShowUI)(BOOL no_show_ui) override;
69 STDMETHOD(SetDirectory)(LPCWSTR directory) override;
70 STDMETHOD(Execute)() override;
72 // IInitializeCommand
73 STDMETHOD(Initialize)(LPCWSTR name, IPropertyBag * bag) override;
75 // IObjectWithSelection
76 STDMETHOD(SetSelection)(IShellItemArray * item_array) override;
77 STDMETHOD(GetSelection)(REFIID riid, void** selection) override;
79 // IExecuteCommandApplicationHostEnvironment
80 STDMETHOD(GetValue)(enum AHE_TYPE * pahe) override;
82 // IForegroundTransfer
83 STDMETHOD(AllowForegroundTransfer)(void* reserved) override;
85 static bool FindChromeExe(base::FilePath* chrome_exe);
87 private:
88 bool GetLaunchScheme(base::string16* display_name, INTERNET_SCHEME* scheme);
89 HRESULT LaunchDesktopChrome();
90 // Returns the launch mode, i.e. desktop launch/metro launch, etc.
91 EC_HOST_UI_MODE GetLaunchMode();
93 static bool path_provider_initialized_;
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)