blob: 2d39984f59846c8d103d49ef34df61fd2923ced3 (
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
73
74
75
76
77
78
79
|
// Copyright (c) 2012 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/lifetime/application_lifetime.h"
#include "base/bind.h"
#include "base/environment.h"
#include "base/files/file_path.h"
#include "base/path_service.h"
#include "base/prefs/pref_service.h"
#include "base/win/metro.h"
#include "base/win/windows_version.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/first_run/upgrade_util.h"
#include "chrome/browser/metro_utils/metro_chrome_win.h"
#include "chrome/browser/metro_viewer/chrome_metro_viewer_process_host_aurawin.h"
#include "chrome/browser/shell_integration.h"
#include "chrome/browser/ui/browser_finder.h"
#include "chrome/common/chrome_constants.h"
#include "chrome/common/pref_names.h"
#include "chrome/installer/util/util_constants.h"
#include "content/public/browser/web_contents.h"
#include "ui/views/widget/widget.h"
namespace chrome {
// Following set of functions, which are used to switch chrome mode after
// restart are used for in places where either user explicitly wants to switch
// mode or some functionality is not available in either mode and we ask user
// to switch mode.
// Here mode refers to Windows 8 modes such as Metro (also called immersive)
// and desktop mode (Classic or traditional).
void ActivateDesktopHelper(AshExecutionStatus ash_execution_status) {
scoped_ptr<base::Environment> env(base::Environment::Create());
std::string version_str;
// Get the version variable and remove it from the environment.
if (!env->GetVar(chrome::kChromeVersionEnvVar, &version_str))
version_str.clear();
base::FilePath exe_path;
if (!PathService::Get(base::FILE_EXE, &exe_path))
return;
base::FilePath path(exe_path.DirName());
// The relauncher is ordinarily in the version directory. When running in a
// build tree however (where CHROME_VERSION is not set in the environment)
// look for it in Chrome's directory.
if (!version_str.empty())
path = path.AppendASCII(version_str);
path = path.Append(installer::kDelegateExecuteExe);
// Actually launching the process needs to happen in the metro viewer,
// otherwise it won't automatically transition to desktop. So we have
// to send an IPC to the viewer to do the ShellExecute.
ChromeMetroViewerProcessHost::HandleActivateDesktop(
path, ash_execution_status == ASH_TERMINATE);
}
void AttemptRestartToDesktopMode() {
PrefService* prefs = g_browser_process->local_state();
prefs->SetString(prefs::kRelaunchMode,
upgrade_util::kRelaunchModeDesktop);
AttemptRestart();
}
void AttemptRestartToMetroMode() {
PrefService* prefs = g_browser_process->local_state();
prefs->SetString(prefs::kRelaunchMode,
upgrade_util::kRelaunchModeMetro);
AttemptRestart();
}
} // namespace chrome
|