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 #include <atlbase.h> |
| 6 #include <atlcom.h> |
| 7 #include <atlctl.h> |
| 8 #include <ShObjIdl.h> |
| 9 #include <WinInet.h> |
| 10 |
| 11 #include <string> |
| 12 |
| 13 #include "base/file_path.h" |
| 14 #include "base/process_util.h" |
| 15 #include "win8/delegate_execute/resource.h" // main symbols |
| 16 |
| 17 using namespace ATL; |
| 18 |
| 19 EXTERN_C const GUID CLSID_CommandExecuteImpl; |
| 20 |
| 21 // CommandExecuteImpl |
| 22 // This class implements the IExecuteCommand and related interfaces for |
| 23 // handling ShellExecute launches of the Chrome browser, i.e. whether to |
| 24 // launch Chrome in metro mode or desktop mode. |
| 25 #if defined(GOOGLE_CHROME_BUILD) |
| 26 class ATL_NO_VTABLE DECLSPEC_UUID("5C65F4B0-3651-4514-B207-D10CB699B14B") |
| 27 CommandExecuteImpl |
| 28 #else // GOOGLE_CHROME_BUILD |
| 29 class ATL_NO_VTABLE DECLSPEC_UUID("A2DF06F9-A21A-44A8-8A99-8B9C84F29160") |
| 30 CommandExecuteImpl |
| 31 #endif // GOOGLE_CHROME_BUILD |
| 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(); |
| 42 |
| 43 DECLARE_REGISTRY_RESOURCEID(IDR_COMMANDEXECUTEIMPL) |
| 44 |
| 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() |
| 53 |
| 54 DECLARE_PROTECT_FINAL_CONSTRUCT() |
| 55 |
| 56 HRESULT FinalConstruct() { |
| 57 return S_OK; |
| 58 } |
| 59 |
| 60 void FinalRelease() { |
| 61 } |
| 62 |
| 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); |
| 72 |
| 73 // IInitializeCommand |
| 74 STDMETHOD(Initialize)(LPCWSTR name, IPropertyBag* bag); |
| 75 |
| 76 // IObjectWithSelection |
| 77 STDMETHOD(SetSelection)(IShellItemArray* item_array); |
| 78 STDMETHOD(GetSelection)(REFIID riid, void** selection); |
| 79 |
| 80 // IExecuteCommandApplicationHostEnvironment |
| 81 STDMETHOD(GetValue)(enum AHE_TYPE* pahe); |
| 82 |
| 83 // IForegroundTransfer |
| 84 STDMETHOD(AllowForegroundTransfer)(void* reserved); |
| 85 |
| 86 private: |
| 87 static bool FindChromeExe(FilePath* chrome_exe); |
| 88 bool GetLaunchScheme(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(); |
| 92 |
| 93 CComPtr<IShellItemArray> item_array_; |
| 94 string16 parameters_; |
| 95 FilePath chrome_exe_; |
| 96 STARTUPINFO start_info_; |
| 97 string16 verb_; |
| 98 string16 display_name_; |
| 99 INTERNET_SCHEME launch_scheme_; |
| 100 |
| 101 base::IntegrityLevel integrity_level_; |
| 102 EC_HOST_UI_MODE chrome_mode_; |
| 103 }; |
| 104 |
| 105 OBJECT_ENTRY_AUTO(__uuidof(CommandExecuteImpl), CommandExecuteImpl) |
OLD | NEW |