OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 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 "apps/app_launch_for_metro_restart_win.h" | 5 #include "apps/app_launch_for_metro_restart_win.h" |
6 | 6 |
7 #include "apps/pref_names.h" | 7 #include "apps/pref_names.h" |
8 #include "base/bind.h" | 8 #include "base/bind.h" |
9 #include "base/files/file_path.h" | 9 #include "base/files/file_path.h" |
10 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
69 prefs->ClearPref(prefs::kAppLaunchForMetroRestart); | 69 prefs->ClearPref(prefs::kAppLaunchForMetroRestart); |
70 | 70 |
71 if (win8::IsSingleWindowMetroMode()) { | 71 if (win8::IsSingleWindowMetroMode()) { |
72 // In this case we have relaunched with the correct profile, but we are not | 72 // In this case we have relaunched with the correct profile, but we are not |
73 // in Desktop mode, so can not launch apps. Leave the preferences cleared so | 73 // in Desktop mode, so can not launch apps. Leave the preferences cleared so |
74 // there are no surprises later. | 74 // there are no surprises later. |
75 return; | 75 return; |
76 } | 76 } |
77 | 77 |
78 const int kRestartAppLaunchDelayMs = 1000; | 78 const int kRestartAppLaunchDelayMs = 1000; |
79 MessageLoop::current()->PostDelayedTask( | 79 base::MessageLoop::current()->PostDelayedTask( |
80 FROM_HERE, | 80 FROM_HERE, |
81 base::Bind(&LaunchAppWithId, | 81 base::Bind(&LaunchAppWithId, profile, extension_id), |
82 profile, | |
83 extension_id), | |
84 base::TimeDelta::FromMilliseconds(kRestartAppLaunchDelayMs)); | 82 base::TimeDelta::FromMilliseconds(kRestartAppLaunchDelayMs)); |
85 } | 83 } |
86 | 84 |
87 void SetAppLaunchForMetroRestart(Profile* profile, | 85 void SetAppLaunchForMetroRestart(Profile* profile, |
88 const std::string& extension_id) { | 86 const std::string& extension_id) { |
89 PrefService* prefs = g_browser_process->local_state(); | 87 PrefService* prefs = g_browser_process->local_state(); |
90 prefs->SetString(prefs::kAppLaunchForMetroRestartProfile, | 88 prefs->SetString(prefs::kAppLaunchForMetroRestartProfile, |
91 profile->GetPath().BaseName().MaybeAsASCII()); | 89 profile->GetPath().BaseName().MaybeAsASCII()); |
92 prefs->SetString(prefs::kAppLaunchForMetroRestart, extension_id); | 90 prefs->SetString(prefs::kAppLaunchForMetroRestart, extension_id); |
93 } | 91 } |
94 | 92 |
95 } // namespace apps | 93 } // namespace apps |
OLD | NEW |