diff options
author | cpu@chromium.org <cpu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-01-18 08:55:49 +0000 |
---|---|---|
committer | cpu@chromium.org <cpu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-01-18 08:55:49 +0000 |
commit | 0d8435d06bc5069868ee9547dad261a7d8c7ea00 (patch) | |
tree | 9e1fd37d66f56e4062705f845be1065e9a0a2562 /win8/delegate_execute | |
parent | a7a40614447afeb87a2ad5242782e8bfbe7f0340 (diff) | |
download | chromium_src-0d8435d06bc5069868ee9547dad261a7d8c7ea00.zip chromium_src-0d8435d06bc5069868ee9547dad261a7d8c7ea00.tar.gz chromium_src-0d8435d06bc5069868ee9547dad261a7d8c7ea00.tar.bz2 |
cleaning delegate execute of non-aura cruft
BUG=none
Review URL: https://codereview.chromium.org/132873007
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@245758 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'win8/delegate_execute')
-rw-r--r-- | win8/delegate_execute/command_execute_impl.cc | 138 | ||||
-rw-r--r-- | win8/delegate_execute/command_execute_impl.h | 1 |
2 files changed, 22 insertions, 117 deletions
diff --git a/win8/delegate_execute/command_execute_impl.cc b/win8/delegate_execute/command_execute_impl.cc index 9381fd2..0d05dc5 100644 --- a/win8/delegate_execute/command_execute_impl.cc +++ b/win8/delegate_execute/command_execute_impl.cc @@ -33,7 +33,6 @@ #include "win8/viewer/metro_viewer_constants.h" namespace { - // Helper function to retrieve the url from IShellItem interface passed in. // Returns S_OK on success. HRESULT GetUrlFromShellItem(IShellItem* shell_item, base::string16* url) { @@ -66,7 +65,6 @@ HRESULT GetUrlFromShellItem(IShellItem* shell_item, base::string16* url) { return S_OK; } -#if defined(USE_AURA) bool LaunchChromeBrowserProcess() { base::FilePath delegate_exe_path; if (!PathService::Get(base::FILE_EXE, &delegate_exe_path)) @@ -104,7 +102,6 @@ bool LaunchChromeBrowserProcess() { return base::LaunchProcess(cl, launch_options, NULL); } -#endif // defined(USE_AURA) } // namespace @@ -137,12 +134,10 @@ bool CommandExecuteImpl::path_provider_initialized_ = false; // 5- Windows calls CommandExecuteImpl::Getvalue() // Here we need to return AHE_IMMERSIVE or AHE_DESKTOP. That depends on: // a) if run in high-integrity return AHE_DESKTOP -// b) if chrome is running return the AHE_ mode of chrome -// c) else we return what GetLaunchMode() tells us, which is: +// b) else we return what GetLaunchMode() tells us, which is: // i) if the command line --force-xxx is present return that // ii) if the registry 'launch_mode' exists return that -// iii) if IsTouchEnabledDevice() is true return AHE_IMMERSIVE -// iv) else return AHE_DESKTOP +// iii) else return AHE_DESKTOP // 6- If we returned AHE_IMMERSIVE in step 5 windows might not call us back // and simply activate chrome in metro by itself, however in some cases // it might proceed at step 7. @@ -161,15 +156,10 @@ bool CommandExecuteImpl::path_provider_initialized_ = false; // in the registry so next time the logic reaches 5c-ii it will use the same // mode again. // -// Also note that if we are not the default browser and IsTouchEnabledDevice() -// returns true, launching chrome can go all the way to 7c, which might be -// a slow way to start chrome. -// CommandExecuteImpl::CommandExecuteImpl() : parameters_(CommandLine::NO_PROGRAM), launch_scheme_(INTERNET_SCHEME_DEFAULT), - integrity_level_(base::INTEGRITY_UNKNOWN), - chrome_mode_(ECHUIM_SYSTEM_LAUNCHER) { + integrity_level_(base::INTEGRITY_UNKNOWN) { memset(&start_info_, 0, sizeof(start_info_)); start_info_.cb = sizeof(start_info_); @@ -184,127 +174,43 @@ CommandExecuteImpl::CommandExecuteImpl() // CommandExecuteImpl STDMETHODIMP CommandExecuteImpl::SetKeyState(DWORD key_state) { - AtlTrace("In %hs\n", __FUNCTION__); return S_OK; } STDMETHODIMP CommandExecuteImpl::SetParameters(LPCWSTR params) { - AtlTrace("In %hs [%S]\n", __FUNCTION__, params); parameters_ = delegate_execute::CommandLineFromParameters(params); return S_OK; } STDMETHODIMP CommandExecuteImpl::SetPosition(POINT pt) { - AtlTrace("In %hs\n", __FUNCTION__); return S_OK; } STDMETHODIMP CommandExecuteImpl::SetShowWindow(int show) { - AtlTrace("In %hs show=%d\n", __FUNCTION__, show); start_info_.wShowWindow = show; start_info_.dwFlags |= STARTF_USESHOWWINDOW; return S_OK; } STDMETHODIMP CommandExecuteImpl::SetNoShowUI(BOOL no_show_ui) { - AtlTrace("In %hs no_show=%d\n", __FUNCTION__, no_show_ui); return S_OK; } STDMETHODIMP CommandExecuteImpl::SetDirectory(LPCWSTR directory) { - AtlTrace("In %hs\n", __FUNCTION__); return S_OK; } STDMETHODIMP CommandExecuteImpl::GetValue(enum AHE_TYPE* pahe) { - AtlTrace("In %hs\n", __FUNCTION__); - if (!GetLaunchScheme(&display_name_, &launch_scheme_)) { AtlTrace("Failed to get scheme, E_FAIL\n"); return E_FAIL; } - if (integrity_level_ == base::HIGH_INTEGRITY) { - // Metro mode apps don't work in high integrity mode. - AtlTrace("High integrity, AHE_DESKTOP\n"); - *pahe = AHE_DESKTOP; - return S_OK; - } - - if (GetAsyncKeyState(VK_SHIFT) && GetAsyncKeyState(VK_F11)) { - AtlTrace("Using Shift-F11 debug hook, returning AHE_IMMERSIVE\n"); - *pahe = AHE_IMMERSIVE; - -#if defined(USE_AURA) - // Launch the chrome browser process that metro chrome will connect to. - LaunchChromeBrowserProcess(); -#endif - - return S_OK; - } - - if (GetAsyncKeyState(VK_SHIFT) && GetAsyncKeyState(VK_F12)) { - AtlTrace("Using Shift-F12 debug hook, returning AHE_DESKTOP\n"); - *pahe = AHE_DESKTOP; - return S_OK; - } - - base::FilePath user_data_dir; - if (!PathService::Get(chrome::DIR_USER_DATA, &user_data_dir)) { - AtlTrace("Failed to get chrome's data dir path, E_FAIL\n"); - return E_FAIL; - } - - bool decision_made = false; - - // New Aura/Ash world we don't want to go throgh FindWindow path - // and instead take decision based on launch mode. -#if !defined(USE_AURA) - HWND chrome_window = base::win::MessageWindow::FindWindow( - user_data_dir.value()); - if (chrome_window) { - AtlTrace("Found chrome window %p\n", chrome_window); - // The failure cases below are deemed to happen due to the inherently racy - // procedure of going from chrome's window to process handle during which - // chrome might have exited. Failing here would probably just cause the - // user to retry at which point we would do the right thing. - DWORD chrome_pid = 0; - ::GetWindowThreadProcessId(chrome_window, &chrome_pid); - if (!chrome_pid) { - AtlTrace("Failed to get chrome's PID, E_FAIL\n"); - return E_FAIL; - } - base::win::ScopedHandle process( - ::OpenProcess(PROCESS_QUERY_INFORMATION, FALSE, chrome_pid)); - if (!process.IsValid()) { - AtlTrace("Failed to open chrome's process [%d], E_FAIL\n", chrome_pid); - return E_FAIL; - } - - if (IsImmersiveProcess(process.Get())) { - AtlTrace("Chrome [%d] is inmmersive, AHE_IMMERSIVE\n", chrome_pid); - chrome_mode_ = ECHUIM_IMMERSIVE; - *pahe = AHE_IMMERSIVE; - } else { - AtlTrace("Chrome [%d] is Desktop, AHE_DESKTOP\n"); - chrome_mode_ = ECHUIM_DESKTOP; - *pahe = AHE_DESKTOP; - } - - decision_made = true; - } -#endif - - if (!decision_made) { - EC_HOST_UI_MODE mode = GetLaunchMode(); - *pahe = (mode == ECHUIM_DESKTOP) ? AHE_DESKTOP : AHE_IMMERSIVE; - } + EC_HOST_UI_MODE mode = GetLaunchMode(); + *pahe = (mode == ECHUIM_DESKTOP) ? AHE_DESKTOP : AHE_IMMERSIVE; -#if defined(USE_AURA) if (*pahe == AHE_IMMERSIVE && verb_ != win8::kMetroViewerConnectVerb) LaunchChromeBrowserProcess(); -#endif - return S_OK; } @@ -356,10 +262,10 @@ STDMETHODIMP CommandExecuteImpl::Execute() { STDMETHODIMP CommandExecuteImpl::Initialize(LPCWSTR name, IPropertyBag* bag) { - AtlTrace("In %hs\n", __FUNCTION__); if (!FindChromeExe(&chrome_exe_)) return E_FAIL; delegate_execute::UpdateChromeIfNeeded(chrome_exe_); + if (name) { AtlTrace("Verb is %S\n", name); verb_ = name; @@ -367,32 +273,25 @@ STDMETHODIMP CommandExecuteImpl::Initialize(LPCWSTR name, base::GetProcessIntegrityLevel(base::GetCurrentProcessHandle(), &integrity_level_); - if (integrity_level_ == base::HIGH_INTEGRITY) { - AtlTrace("Delegate execute launched in high integrity level\n"); - } return S_OK; } STDMETHODIMP CommandExecuteImpl::SetSelection(IShellItemArray* item_array) { - AtlTrace("In %hs\n", __FUNCTION__); item_array_ = item_array; return S_OK; } STDMETHODIMP CommandExecuteImpl::GetSelection(REFIID riid, void** selection) { - AtlTrace("In %hs\n", __FUNCTION__); return S_OK; } STDMETHODIMP CommandExecuteImpl::AllowForegroundTransfer(void* reserved) { - AtlTrace("In %hs\n", __FUNCTION__); return S_OK; } // Returns false if chrome.exe cannot be found. // static bool CommandExecuteImpl::FindChromeExe(base::FilePath* chrome_exe) { - AtlTrace("In %hs\n", __FUNCTION__); // Look for chrome.exe one folder above delegate_execute.exe (as expected in // Chrome installs). Failing that, look for it alonside delegate_execute.exe. base::FilePath dir_exe; @@ -409,8 +308,6 @@ bool CommandExecuteImpl::FindChromeExe(base::FilePath* chrome_exe) { return false; } } - - AtlTrace("Got chrome exe path as %ls\n", chrome_exe->value().c_str()); return true; } @@ -445,8 +342,6 @@ bool CommandExecuteImpl::GetLaunchScheme( return false; } - AtlTrace("url [%ls]\n", display_name->c_str()); - wchar_t scheme_name[16]; URL_COMPONENTS components = {0}; components.lpszScheme = scheme_name; @@ -464,7 +359,6 @@ bool CommandExecuteImpl::GetLaunchScheme( } HRESULT CommandExecuteImpl::LaunchDesktopChrome() { - AtlTrace("In %hs\n", __FUNCTION__); base::string16 display_name = display_name_; switch (launch_scheme_) { @@ -514,13 +408,22 @@ EC_HOST_UI_MODE CommandExecuteImpl::GetLaunchMode() { if (launch_mode_determined) return launch_mode; - if (chrome_mode_ != ECHUIM_SYSTEM_LAUNCHER) { - launch_mode = chrome_mode_; - AtlTrace("Launch mode is that of chrome, %s\n", modes[launch_mode]); + if (integrity_level_ == base::HIGH_INTEGRITY) { + // Metro mode apps don't work in high integrity mode. + AtlTrace("High integrity: launching in desktop mode\n"); + launch_mode = ECHUIM_DESKTOP; + launch_mode_determined = true; + return launch_mode; + } + if (GetAsyncKeyState(VK_SHIFT) && GetAsyncKeyState(VK_F11)) { + AtlTrace("Hotkey: launching in immersive mode\n"); + launch_mode = ECHUIM_IMMERSIVE; launch_mode_determined = true; return launch_mode; } + // From here on, if we can, we will write the outcome + // of this function to the registry. if (parameters_.HasSwitch(switches::kForceImmersive)) { launch_mode = ECHUIM_IMMERSIVE; launch_mode_determined = true; @@ -540,6 +443,8 @@ EC_HOST_UI_MODE CommandExecuteImpl::GetLaunchMode() { chrome::kMetroRegistryPath, key_result); if (!launch_mode_determined) { + // If we cannot open the key and we don't know the + // launch mode we default to desktop mode. launch_mode = ECHUIM_DESKTOP; launch_mode_determined = true; } @@ -553,11 +458,12 @@ EC_HOST_UI_MODE CommandExecuteImpl::GetLaunchMode() { return launch_mode; } + // Use the previous mode if available. Else launch in desktop mode. DWORD reg_value; if (reg_key.ReadValueDW(chrome::kLaunchModeValue, ®_value) != ERROR_SUCCESS) { launch_mode = ECHUIM_DESKTOP; - AtlTrace("Launch mode forced by heuristics to %s\n", modes[launch_mode]); + AtlTrace("Can't read registry, defaulting to %s\n", modes[launch_mode]); } else if (reg_value >= ECHUIM_SYSTEM_LAUNCHER) { AtlTrace("Invalid registry launch mode value %u\n", reg_value); launch_mode = ECHUIM_DESKTOP; diff --git a/win8/delegate_execute/command_execute_impl.h b/win8/delegate_execute/command_execute_impl.h index 7e4bf7c..f27bf7a 100644 --- a/win8/delegate_execute/command_execute_impl.h +++ b/win8/delegate_execute/command_execute_impl.h @@ -102,7 +102,6 @@ class ATL_NO_VTABLE DECLSPEC_UUID("071BB5F2-85A4-424F-BFE7-5F1609BE4C2C") INTERNET_SCHEME launch_scheme_; base::IntegrityLevel integrity_level_; - EC_HOST_UI_MODE chrome_mode_; }; OBJECT_ENTRY_AUTO(__uuidof(CommandExecuteImpl), CommandExecuteImpl) |