Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(455)

Side by Side Diff: chrome/browser/lifetime/application_lifetime_win.cc

Issue 909183002: win/aura: Remove some more non-aura code for Windows. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/lifetime/application_lifetime.h" 5 #include "chrome/browser/lifetime/application_lifetime.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/environment.h"
9 #include "base/files/file_path.h"
10 #include "base/path_service.h"
8 #include "base/prefs/pref_service.h" 11 #include "base/prefs/pref_service.h"
9 #include "base/win/metro.h" 12 #include "base/win/metro.h"
10 #include "base/win/windows_version.h" 13 #include "base/win/windows_version.h"
11 #include "chrome/browser/browser_process.h" 14 #include "chrome/browser/browser_process.h"
12 #include "chrome/browser/first_run/upgrade_util.h" 15 #include "chrome/browser/first_run/upgrade_util.h"
13 #include "chrome/browser/ui/browser_finder.h"
14 #include "chrome/common/pref_names.h"
15 #include "ui/views/widget/widget.h"
16
17 #if defined(USE_AURA)
18 #include "base/environment.h"
19 #include "base/files/file_path.h"
20 #include "base/path_service.h"
21 #include "chrome/browser/metro_utils/metro_chrome_win.h" 16 #include "chrome/browser/metro_utils/metro_chrome_win.h"
22 #include "chrome/browser/metro_viewer/chrome_metro_viewer_process_host_aurawin.h " 17 #include "chrome/browser/metro_viewer/chrome_metro_viewer_process_host_aurawin.h "
23 #include "chrome/browser/shell_integration.h" 18 #include "chrome/browser/shell_integration.h"
19 #include "chrome/browser/ui/browser_finder.h"
24 #include "chrome/common/chrome_constants.h" 20 #include "chrome/common/chrome_constants.h"
21 #include "chrome/common/pref_names.h"
25 #include "chrome/installer/util/util_constants.h" 22 #include "chrome/installer/util/util_constants.h"
26 #include "content/public/browser/web_contents.h" 23 #include "content/public/browser/web_contents.h"
27 #endif 24 #include "ui/views/widget/widget.h"
28 25
29 namespace chrome { 26 namespace chrome {
30 27
31 #if !defined(USE_AURA)
32 void HandleAppExitingForPlatform() {
33 views::Widget::CloseAllSecondaryWidgets();
34 }
35 #endif
36
37 // Following set of functions, which are used to switch chrome mode after 28 // Following set of functions, which are used to switch chrome mode after
38 // restart are used for in places where either user explicitly wants to switch 29 // restart are used for in places where either user explicitly wants to switch
39 // mode or some functionality is not available in either mode and we ask user 30 // mode or some functionality is not available in either mode and we ask user
40 // to switch mode. 31 // to switch mode.
41 // Here mode refers to Windows 8 modes such as Metro (also called immersive) 32 // Here mode refers to Windows 8 modes such as Metro (also called immersive)
42 // and desktop mode (Classic or traditional). 33 // and desktop mode (Classic or traditional).
43 34
44 // Mode switch based on current mode which is devised from current process.
45 void AttemptRestartWithModeSwitch() {
46 #if defined(USE_AURA)
47 // This function should be called only from non aura code path.
48 // In aura/ash windows world browser process is always non metro.
49 NOTREACHED();
50 #else
51 // The kRestartSwitchMode preference does not exists for Windows 7 and older
52 // operating systems so there is no need for OS version check.
53 PrefService* prefs = g_browser_process->local_state();
54 if (base::win::IsMetroProcess()) {
55 prefs->SetString(prefs::kRelaunchMode,
56 upgrade_util::kRelaunchModeDesktop);
57 } else {
58 prefs->SetString(prefs::kRelaunchMode,
59 upgrade_util::kRelaunchModeMetro);
60 }
61 AttemptRestart();
62 #endif
63 }
64
65 #if defined(USE_AURA)
66 void ActivateDesktopHelper(AshExecutionStatus ash_execution_status) { 35 void ActivateDesktopHelper(AshExecutionStatus ash_execution_status) {
67 scoped_ptr<base::Environment> env(base::Environment::Create()); 36 scoped_ptr<base::Environment> env(base::Environment::Create());
68 std::string version_str; 37 std::string version_str;
69 38
70 // Get the version variable and remove it from the environment. 39 // Get the version variable and remove it from the environment.
71 if (!env->GetVar(chrome::kChromeVersionEnvVar, &version_str)) 40 if (!env->GetVar(chrome::kChromeVersionEnvVar, &version_str))
72 version_str.clear(); 41 version_str.clear();
73 42
74 base::FilePath exe_path; 43 base::FilePath exe_path;
75 if (!PathService::Get(base::FILE_EXE, &exe_path)) 44 if (!PathService::Get(base::FILE_EXE, &exe_path))
76 return; 45 return;
77 46
78 base::FilePath path(exe_path.DirName()); 47 base::FilePath path(exe_path.DirName());
79 48
80 // The relauncher is ordinarily in the version directory. When running in a 49 // The relauncher is ordinarily in the version directory. When running in a
81 // build tree however (where CHROME_VERSION is not set in the environment) 50 // build tree however (where CHROME_VERSION is not set in the environment)
82 // look for it in Chrome's directory. 51 // look for it in Chrome's directory.
83 if (!version_str.empty()) 52 if (!version_str.empty())
84 path = path.AppendASCII(version_str); 53 path = path.AppendASCII(version_str);
85 54
86 path = path.Append(installer::kDelegateExecuteExe); 55 path = path.Append(installer::kDelegateExecuteExe);
87 56
88 // Actually launching the process needs to happen in the metro viewer, 57 // Actually launching the process needs to happen in the metro viewer,
89 // otherwise it won't automatically transition to desktop. So we have 58 // otherwise it won't automatically transition to desktop. So we have
90 // to send an IPC to the viewer to do the ShellExecute. 59 // to send an IPC to the viewer to do the ShellExecute.
91 ChromeMetroViewerProcessHost::HandleActivateDesktop( 60 ChromeMetroViewerProcessHost::HandleActivateDesktop(
92 path, ash_execution_status == ASH_TERMINATE); 61 path, ash_execution_status == ASH_TERMINATE);
93 } 62 }
94 #endif
95 63
96 void AttemptRestartToDesktopMode() { 64 void AttemptRestartToDesktopMode() {
97 PrefService* prefs = g_browser_process->local_state(); 65 PrefService* prefs = g_browser_process->local_state();
98 prefs->SetString(prefs::kRelaunchMode, 66 prefs->SetString(prefs::kRelaunchMode,
99 upgrade_util::kRelaunchModeDesktop); 67 upgrade_util::kRelaunchModeDesktop);
100 68
101 AttemptRestart(); 69 AttemptRestart();
102 } 70 }
103 71
104 void AttemptRestartToMetroMode() { 72 void AttemptRestartToMetroMode() {
105 PrefService* prefs = g_browser_process->local_state(); 73 PrefService* prefs = g_browser_process->local_state();
106 prefs->SetString(prefs::kRelaunchMode, 74 prefs->SetString(prefs::kRelaunchMode,
107 upgrade_util::kRelaunchModeMetro); 75 upgrade_util::kRelaunchModeMetro);
108 AttemptRestart(); 76 AttemptRestart();
109 } 77 }
110 78
111 } // namespace chrome 79 } // namespace chrome
OLDNEW
« no previous file with comments | « chrome/browser/lifetime/application_lifetime.h ('k') | chrome/browser/metro_utils/metro_chrome_win.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698