OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/ui/cocoa/apps/quit_with_apps_controller_mac.h" | 5 #include "chrome/browser/ui/cocoa/apps/quit_with_apps_controller_mac.h" |
6 | 6 |
7 #include "apps/app_window.h" | 7 #include "apps/app_window.h" |
8 #include "apps/app_window_registry.h" | 8 #include "apps/app_window_registry.h" |
9 #include "apps/ui/native_app_window.h" | 9 #include "apps/ui/native_app_window.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
97 return NULL; | 97 return NULL; |
98 } | 98 } |
99 | 99 |
100 std::string QuitWithAppsController::id() const { | 100 std::string QuitWithAppsController::id() const { |
101 return kQuitWithAppsNotificationID; | 101 return kQuitWithAppsNotificationID; |
102 } | 102 } |
103 | 103 |
104 bool QuitWithAppsController::ShouldQuit() { | 104 bool QuitWithAppsController::ShouldQuit() { |
105 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 105 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
106 | 106 |
107 if (!CommandLine::ForCurrentProcess()->HasSwitch( | 107 // Quit immediately if this is a test. |
108 switches::kAppsKeepChromeAlive)) { | 108 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kTestType) && |
109 g_browser_process->local_state()->ClearPref( | 109 !CommandLine::ForCurrentProcess()->HasSwitch( |
110 prefs::kNotifyWhenAppsKeepChromeAlive); | 110 switches::kAppsKeepChromeAliveInTests)) { |
111 return true; | 111 return true; |
112 } | 112 } |
113 | 113 |
114 // Quit immediately if there are no windows or the confirmation has been | 114 // Quit immediately if there are no windows or the confirmation has been |
115 // suppressed. | 115 // suppressed. |
116 if (!apps::AppWindowRegistry::IsAppWindowRegisteredInAnyProfile(0)) | 116 if (!apps::AppWindowRegistry::IsAppWindowRegisteredInAnyProfile(0)) |
117 return true; | 117 return true; |
118 | 118 |
119 // If there are browser windows, and this notification has been suppressed for | 119 // If there are browser windows, and this notification has been suppressed for |
120 // this session or permanently, then just return false to prevent Chrome from | 120 // this session or permanently, then just return false to prevent Chrome from |
(...skipping 18 matching lines...) Expand all Loading... |
139 | 139 |
140 // Always return false, the notification UI can be used to quit all apps which | 140 // Always return false, the notification UI can be used to quit all apps which |
141 // will cause Chrome to quit. | 141 // will cause Chrome to quit. |
142 return false; | 142 return false; |
143 } | 143 } |
144 | 144 |
145 // static | 145 // static |
146 void QuitWithAppsController::RegisterPrefs(PrefRegistrySimple* registry) { | 146 void QuitWithAppsController::RegisterPrefs(PrefRegistrySimple* registry) { |
147 registry->RegisterBooleanPref(prefs::kNotifyWhenAppsKeepChromeAlive, true); | 147 registry->RegisterBooleanPref(prefs::kNotifyWhenAppsKeepChromeAlive, true); |
148 } | 148 } |
OLD | NEW |