blob: 86a459279d2ef1aefe6d4979b5685cd8f0a7eb10 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
|
// Copyright 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/metro_utils/metro_chrome_win.h"
#include <windows.h>
#include <shobjidl.h>
#include "base/files/file_path.h"
#include "base/path_service.h"
#include "base/win/metro.h"
#include "base/win/scoped_com_initializer.h"
#include "base/win/scoped_comptr.h"
#include "chrome/installer/util/browser_distribution.h"
#include "chrome/installer/util/install_util.h"
#include "chrome/installer/util/shell_util.h"
namespace chrome {
bool ActivateMetroChrome() {
base::FilePath chrome_exe;
if (!PathService::Get(base::FILE_EXE, &chrome_exe)) {
NOTREACHED() << "Failed to get chrome exe path";
return false;
}
base::string16 app_id = ShellUtil::GetBrowserModelId(
BrowserDistribution::GetDistribution(),
InstallUtil::IsPerUserInstall(chrome_exe.value().c_str()));
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;
}
Win8Environment GetWin8Environment(HostDesktopType desktop) {
#if defined(USE_AURA) && defined(USE_ASH)
if (desktop == chrome::HOST_DESKTOP_TYPE_ASH)
return WIN_8_ENVIRONMENT_METRO_AURA;
else
return WIN_8_ENVIRONMENT_DESKTOP_AURA;
#else
if (base::win::IsProcessImmersive(::GetCurrentProcess()))
return WIN_8_ENVIRONMENT_METRO;
else
return WIN_8_ENVIRONMENT_DESKTOP;
#endif
}
} // namespace chrome
|