| OLD | NEW |
| (Empty) |
| 1 // Copyright 2013 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 "chrome/browser/ui/metro_chrome_win.h" | |
| 6 | |
| 7 #include <windows.h> | |
| 8 #include <shobjidl.h> | |
| 9 | |
| 10 #include "base/files/file_path.h" | |
| 11 #include "base/path_service.h" | |
| 12 #include "base/win/scoped_com_initializer.h" | |
| 13 #include "base/win/scoped_comptr.h" | |
| 14 #include "chrome/installer/util/browser_distribution.h" | |
| 15 #include "chrome/installer/util/install_util.h" | |
| 16 #include "chrome/installer/util/shell_util.h" | |
| 17 | |
| 18 namespace chrome { | |
| 19 | |
| 20 bool ActivateMetroChrome() { | |
| 21 base::FilePath chrome_exe; | |
| 22 if (!PathService::Get(base::FILE_EXE, &chrome_exe)) { | |
| 23 NOTREACHED() << "Failed to get chrome exe path"; | |
| 24 return false; | |
| 25 } | |
| 26 | |
| 27 string16 app_id = ShellUtil::GetBrowserModelId( | |
| 28 BrowserDistribution::GetDistribution(), | |
| 29 InstallUtil::IsPerUserInstall(chrome_exe.value().c_str())); | |
| 30 if (app_id.empty()) { | |
| 31 NOTREACHED() << "Failed to get chrome app user model id."; | |
| 32 return false; | |
| 33 } | |
| 34 | |
| 35 base::win::ScopedComPtr<IApplicationActivationManager> activation_manager; | |
| 36 HRESULT hr = activation_manager.CreateInstance( | |
| 37 CLSID_ApplicationActivationManager); | |
| 38 if (!activation_manager) { | |
| 39 NOTREACHED() << "Failed to cocreate activation manager. Error: " << hr; | |
| 40 return false; | |
| 41 } | |
| 42 | |
| 43 unsigned long pid = 0; | |
| 44 hr = activation_manager->ActivateApplication(app_id.c_str(), | |
| 45 L"open", | |
| 46 AO_NONE, | |
| 47 &pid); | |
| 48 if (FAILED(hr)) { | |
| 49 NOTREACHED() << "Failed to activate metro chrome. Error: " << hr; | |
| 50 return false; | |
| 51 } | |
| 52 | |
| 53 return true; | |
| 54 } | |
| 55 | |
| 56 } // namespace chrome | |
| OLD | NEW |