Chromium Code Reviews| Index: chrome/browser/process_singleton_win.cc |
| =================================================================== |
| --- chrome/browser/process_singleton_win.cc (revision 156844) |
| +++ chrome/browser/process_singleton_win.cc (working copy) |
| @@ -5,6 +5,7 @@ |
| #include "chrome/browser/process_singleton.h" |
| #include <shellapi.h> |
| +#include <shobjidl.h> |
| #include "base/base_paths.h" |
| #include "base/command_line.h" |
| @@ -14,10 +15,14 @@ |
| #include "base/stringprintf.h" |
| #include "base/utf_string_conversions.h" |
| #include "base/win/metro.h" |
| +#include "base/win/scoped_com_initializer.h" |
| +#include "base/win/scoped_comptr.h" |
| #include "base/win/scoped_handle.h" |
| #include "base/win/wrapped_window_proc.h" |
| #include "chrome/browser/ui/simple_message_box.h" |
| #include "chrome/common/chrome_constants.h" |
| +#include "chrome/installer/util/browser_distribution.h" |
| +#include "chrome/installer/util/shell_util.h" |
| #include "chrome/installer/util/wmi.h" |
| #include "content/public/common/result_codes.h" |
| #include "grit/chromium_strings.h" |
| @@ -120,6 +125,41 @@ |
| return false; |
| } |
| +bool ActivateMetroChrome() { |
| + base::win::ScopedCOMInitializer com_init; |
|
cpu_(ooo_6.6-7.5)
2012/09/17 20:39:06
we are trying to limit the com initialization to o
ananta
2012/09/17 22:16:31
Removed
|
| + |
| + FilePath chrome_exe; |
| + if (!PathService::Get(base::FILE_EXE, &chrome_exe)) { |
| + NOTREACHED() << "Failed to get chrome exe path"; |
| + return false; |
| + } |
| + string16 app_id = ShellUtil::GetBrowserModelId( |
| + BrowserDistribution::GetDistribution(), chrome_exe.value()); |
| + if (app_id.empty()) { |
| + NOTREACHED() << "Failed to get chrome app user model id."; |
| + return false; |
| + } |
| + |
| + base::win::ScopedComPtr<IApplicationActivationManager> activation_manager; |
| + HRESULT hr = activation_manager.CreateInstance( |
| + CLSID_ApplicationActivationManager); |
| + if (!activation_manager) { |
| + NOTREACHED() << "Failed to cocreate activation manager. Error: " << hr; |
| + return false; |
| + } |
| + |
| + unsigned long pid = 0; |
| + hr = activation_manager->ActivateApplication(app_id.c_str(), |
| + L"open", |
| + AO_NONE, |
| + &pid); |
| + if (FAILED(hr)) { |
| + NOTREACHED() << "Failed to activate metro chrome. Error: " << hr; |
| + return false; |
| + } |
| + return true; |
| +} |
| + |
| } // namespace |
| // Microsoft's Softricity virtualization breaks the sandbox processes. |
| @@ -310,6 +350,14 @@ |
| remote_window_ = NULL; |
| return PROCESS_NONE; |
| } |
| + |
|
cpu_(ooo_6.6-7.5)
2012/09/17 20:39:06
check for win8 or bigger here, that is less expens
ananta
2012/09/17 22:16:31
Done.
|
| + base::win::ScopedHandle process_handle; |
| + if (base::OpenProcessHandleWithAccess( |
| + process_id, PROCESS_QUERY_INFORMATION, |
| + process_handle.Receive())) { |
| + if (base::win::IsImmersiveProcess(process_handle.Get())) |
| + ActivateMetroChrome(); |
| + } |
| return PROCESS_NOTIFIED; |
| } |