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.
13 #include "base/command_line.h"
14 #include "base/files/file_path.h"
15 #include "base/process_util.h"
16 #include "win8/delegate_execute/resource.h" // main symbols
20 EXTERN_C
const GUID CLSID_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 #if defined(GOOGLE_CHROME_BUILD)
27 class ATL_NO_VTABLE
DECLSPEC_UUID("5C65F4B0-3651-4514-B207-D10CB699B14B")
29 #else // GOOGLE_CHROME_BUILD
30 class ATL_NO_VTABLE
DECLSPEC_UUID("A2DF06F9-A21A-44A8-8A99-8B9C84F29160")
32 #endif // GOOGLE_CHROME_BUILD
33 : public CComObjectRootEx
<CComSingleThreadModel
>,
34 public CComCoClass
<CommandExecuteImpl
, &CLSID_CommandExecuteImpl
>,
35 public IExecuteCommand
,
36 public IObjectWithSiteImpl
<CommandExecuteImpl
>,
37 public IInitializeCommand
,
38 public IObjectWithSelection
,
39 public IExecuteCommandApplicationHostEnvironment
,
40 public IForegroundTransfer
{
44 DECLARE_REGISTRY_RESOURCEID(IDR_COMMANDEXECUTEIMPL
)
46 BEGIN_COM_MAP(CommandExecuteImpl
)
47 COM_INTERFACE_ENTRY(IExecuteCommand
)
48 COM_INTERFACE_ENTRY(IObjectWithSite
)
49 COM_INTERFACE_ENTRY(IInitializeCommand
)
50 COM_INTERFACE_ENTRY(IObjectWithSelection
)
51 COM_INTERFACE_ENTRY(IExecuteCommandApplicationHostEnvironment
)
52 COM_INTERFACE_ENTRY(IForegroundTransfer
)
55 DECLARE_PROTECT_FINAL_CONSTRUCT()
57 HRESULT
FinalConstruct() {
66 STDMETHOD(SetKeyState
)(DWORD key_state
);
67 STDMETHOD(SetParameters
)(LPCWSTR params
);
68 STDMETHOD(SetPosition
)(POINT pt
);
69 STDMETHOD(SetShowWindow
)(int show
);
70 STDMETHOD(SetNoShowUI
)(BOOL no_show_ui
);
71 STDMETHOD(SetDirectory
)(LPCWSTR directory
);
72 STDMETHOD(Execute
)(void);
75 STDMETHOD(Initialize
)(LPCWSTR name
, IPropertyBag
* bag
);
77 // IObjectWithSelection
78 STDMETHOD(SetSelection
)(IShellItemArray
* item_array
);
79 STDMETHOD(GetSelection
)(REFIID riid
, void** selection
);
81 // IExecuteCommandApplicationHostEnvironment
82 STDMETHOD(GetValue
)(enum AHE_TYPE
* pahe
);
84 // IForegroundTransfer
85 STDMETHOD(AllowForegroundTransfer
)(void* reserved
);
88 static bool FindChromeExe(base::FilePath
* chrome_exe
);
90 static bool path_provider_initialized_
;
92 bool GetLaunchScheme(string16
* display_name
, INTERNET_SCHEME
* scheme
);
93 HRESULT
LaunchDesktopChrome();
94 // Returns the launch mode, i.e. desktop launch/metro launch, etc.
95 EC_HOST_UI_MODE
GetLaunchMode();
97 CComPtr
<IShellItemArray
> item_array_
;
98 CommandLine parameters_
;
99 base::FilePath chrome_exe_
;
100 STARTUPINFO start_info_
;
102 string16 display_name_
;
103 INTERNET_SCHEME launch_scheme_
;
105 base::IntegrityLevel integrity_level_
;
106 EC_HOST_UI_MODE chrome_mode_
;
109 OBJECT_ENTRY_AUTO(__uuidof(CommandExecuteImpl
), CommandExecuteImpl
)