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

Side by Side Diff: chrome/browser/browser_shutdown.cc

Issue 10885047: Metro mode switching (chrome side) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 3 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 | Annotate | Revision Log
« no previous file with comments | « chrome/browser/browser_process_impl.cc ('k') | chrome/browser/first_run/upgrade_util.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/browser_shutdown.h" 5 #include "chrome/browser/browser_shutdown.h"
6 6
7 #include <map> 7 #include <map>
8 #include <string> 8 #include <string>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 using content::BrowserThread; 58 using content::BrowserThread;
59 59
60 namespace browser_shutdown { 60 namespace browser_shutdown {
61 61
62 // Whether the browser is trying to quit (e.g., Quit chosen from menu). 62 // Whether the browser is trying to quit (e.g., Quit chosen from menu).
63 bool g_trying_to_quit = false; 63 bool g_trying_to_quit = false;
64 64
65 // Whether the browser should quit without closing browsers. 65 // Whether the browser should quit without closing browsers.
66 bool g_shutting_down_without_closing_browsers = false; 66 bool g_shutting_down_without_closing_browsers = false;
67 67
68 #if defined(OS_WIN)
69 // Whether the next restart should happen in the opposite mode; desktop or
70 // metro mode. Windows 8 only.
71 bool g_mode_switch = false;
72 #endif
73
68 Time* shutdown_started_ = NULL; 74 Time* shutdown_started_ = NULL;
69 ShutdownType shutdown_type_ = NOT_VALID; 75 ShutdownType shutdown_type_ = NOT_VALID;
70 int shutdown_num_processes_; 76 int shutdown_num_processes_;
71 int shutdown_num_processes_slow_; 77 int shutdown_num_processes_slow_;
72 78
73 const char kShutdownMsFile[] = "chrome_shutdown_ms.txt"; 79 const char kShutdownMsFile[] = "chrome_shutdown_ms.txt";
74 80
75 void RegisterPrefs(PrefService* local_state) { 81 void RegisterPrefs(PrefService* local_state) {
76 local_state->RegisterIntegerPref(prefs::kShutdownType, NOT_VALID); 82 local_state->RegisterIntegerPref(prefs::kShutdownType, NOT_VALID);
77 local_state->RegisterIntegerPref(prefs::kShutdownNumProcesses, 0); 83 local_state->RegisterIntegerPref(prefs::kShutdownNumProcesses, 0);
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
140 prefs->SetInteger(prefs::kShutdownNumProcessesSlow, 146 prefs->SetInteger(prefs::kShutdownNumProcessesSlow,
141 shutdown_num_processes_slow_); 147 shutdown_num_processes_slow_);
142 } 148 }
143 149
144 // Check local state for the restart flag so we can restart the session below. 150 // Check local state for the restart flag so we can restart the session below.
145 bool restart_last_session = false; 151 bool restart_last_session = false;
146 if (prefs->HasPrefPath(prefs::kRestartLastSessionOnShutdown)) { 152 if (prefs->HasPrefPath(prefs::kRestartLastSessionOnShutdown)) {
147 restart_last_session = 153 restart_last_session =
148 prefs->GetBoolean(prefs::kRestartLastSessionOnShutdown); 154 prefs->GetBoolean(prefs::kRestartLastSessionOnShutdown);
149 prefs->ClearPref(prefs::kRestartLastSessionOnShutdown); 155 prefs->ClearPref(prefs::kRestartLastSessionOnShutdown);
156 #if defined(OS_WIN)
157 if (restart_last_session) {
158 if (prefs->HasPrefPath(prefs::kRestartSwitchMode)) {
159 g_mode_switch = prefs->GetBoolean(prefs::kRestartSwitchMode);
160 prefs->SetBoolean(prefs::kRestartSwitchMode, false);
161 }
162 }
163 #endif
150 } 164 }
151 165
152 prefs->CommitPendingWrite(); 166 prefs->CommitPendingWrite();
153 167
154 #if defined(ENABLE_RLZ) 168 #if defined(ENABLE_RLZ)
155 // Cleanup any statics created by RLZ. Must be done before NotificationService 169 // Cleanup any statics created by RLZ. Must be done before NotificationService
156 // is destroyed. 170 // is destroyed.
157 RLZTracker::CleanupRlz(); 171 RLZTracker::CleanupRlz();
158 #endif 172 #endif
159 173
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
203 switches::RemoveSwitchesForAutostart(&switches); 217 switches::RemoveSwitchesForAutostart(&switches);
204 // Append the old switches to the new command line. 218 // Append the old switches to the new command line.
205 for (std::map<std::string, CommandLine::StringType>::const_iterator i = 219 for (std::map<std::string, CommandLine::StringType>::const_iterator i =
206 switches.begin(); i != switches.end(); ++i) { 220 switches.begin(); i != switches.end(); ++i) {
207 CommandLine::StringType switch_value = i->second; 221 CommandLine::StringType switch_value = i->second;
208 if (!switch_value.empty()) 222 if (!switch_value.empty())
209 new_cl->AppendSwitchNative(i->first, i->second); 223 new_cl->AppendSwitchNative(i->first, i->second);
210 else 224 else
211 new_cl->AppendSwitch(i->first); 225 new_cl->AppendSwitch(i->first);
212 } 226 }
227
228 #if defined(OS_WIN)
229 // On Windows 8 we can relaunch in metro or desktop mode.
230 if (g_mode_switch)
231 upgrade_util::RelaunchChromeWithModeSwitch(*new_cl.get());
232 else
233 upgrade_util::RelaunchChromeBrowser(*new_cl.get());
234 #else
213 upgrade_util::RelaunchChromeBrowser(*new_cl.get()); 235 upgrade_util::RelaunchChromeBrowser(*new_cl.get());
236 #endif // defined(OS_WIN)
237
214 #else 238 #else
215 NOTIMPLEMENTED(); 239 NOTIMPLEMENTED();
216 #endif // !defined(OS_CHROMEOS) 240 #endif // !defined(OS_CHROMEOS)
217 } 241 }
218 242
219 if (shutdown_type_ > NOT_VALID && shutdown_num_processes_ > 0) { 243 if (shutdown_type_ > NOT_VALID && shutdown_num_processes_ > 0) {
220 // Measure total shutdown time as late in the process as possible 244 // Measure total shutdown time as late in the process as possible
221 // and then write it to a file to be read at startup. 245 // and then write it to a file to be read at startup.
222 // We can't use prefs since all services are shutdown at this point. 246 // We can't use prefs since all services are shutdown at this point.
223 TimeDelta shutdown_delta = Time::Now() - *shutdown_started_; 247 TimeDelta shutdown_delta = Time::Now() - *shutdown_started_;
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
307 331
308 bool ShuttingDownWithoutClosingBrowsers() { 332 bool ShuttingDownWithoutClosingBrowsers() {
309 return g_shutting_down_without_closing_browsers; 333 return g_shutting_down_without_closing_browsers;
310 } 334 }
311 335
312 void SetShuttingDownWithoutClosingBrowsers(bool without_close) { 336 void SetShuttingDownWithoutClosingBrowsers(bool without_close) {
313 g_shutting_down_without_closing_browsers = without_close; 337 g_shutting_down_without_closing_browsers = without_close;
314 } 338 }
315 339
316 } // namespace browser_shutdown 340 } // namespace browser_shutdown
OLDNEW
« no previous file with comments | « chrome/browser/browser_process_impl.cc ('k') | chrome/browser/first_run/upgrade_util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698