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 "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/i18n/number_formatting.h" | 8 #include "base/i18n/number_formatting.h" |
9 #include "base/prefs/pref_registry_simple.h" | 9 #include "base/prefs/pref_registry_simple.h" |
10 #include "base/prefs/pref_service.h" | 10 #include "base/prefs/pref_service.h" |
11 #include "base/strings/sys_string_conversions.h" | 11 #include "base/strings/sys_string_conversions.h" |
12 #include "base/strings/utf_string_conversions.h" | 12 #include "base/strings/utf_string_conversions.h" |
13 #include "chrome/browser/apps/app_window_registry_util.h" | 13 #include "chrome/browser/apps/app_window_registry_util.h" |
14 #include "chrome/browser/browser_process.h" | 14 #include "chrome/browser/browser_process.h" |
15 #include "chrome/browser/chrome_notification_types.h" | 15 #include "chrome/browser/chrome_notification_types.h" |
16 #include "chrome/browser/lifetime/application_lifetime.h" | 16 #include "chrome/browser/lifetime/application_lifetime.h" |
17 #include "chrome/browser/notifications/notification.h" | 17 #include "chrome/browser/notifications/notification.h" |
18 #include "chrome/browser/notifications/notification_ui_manager.h" | 18 #include "chrome/browser/notifications/notification_ui_manager.h" |
19 #include "chrome/browser/profiles/profile_manager.h" | 19 #include "chrome/browser/profiles/profile_manager.h" |
20 #include "chrome/browser/ui/browser_iterator.h" | 20 #include "chrome/browser/ui/browser_list.h" |
21 #include "chrome/browser/ui/browser_window.h" | 21 #include "chrome/browser/ui/browser_window.h" |
22 #include "chrome/browser/web_applications/web_app.h" | 22 #include "chrome/browser/web_applications/web_app.h" |
23 #include "chrome/common/chrome_switches.h" | 23 #include "chrome/common/chrome_switches.h" |
24 #include "chrome/common/pref_names.h" | 24 #include "chrome/common/pref_names.h" |
25 #include "chrome/grit/chromium_strings.h" | 25 #include "chrome/grit/chromium_strings.h" |
26 #include "chrome/grit/generated_resources.h" | 26 #include "chrome/grit/generated_resources.h" |
27 #include "content/public/browser/notification_service.h" | 27 #include "content/public/browser/notification_service.h" |
28 #include "content/public/common/content_switches.h" | 28 #include "content/public/common/content_switches.h" |
29 #include "extensions/browser/app_window/app_window.h" | 29 #include "extensions/browser/app_window/app_window.h" |
30 #include "extensions/browser/app_window/native_app_window.h" | 30 #include "extensions/browser/app_window/native_app_window.h" |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
162 if (!AppWindowRegistryUtil::IsAppWindowVisibleInAnyProfile( | 162 if (!AppWindowRegistryUtil::IsAppWindowVisibleInAnyProfile( |
163 extensions::AppWindow::WINDOW_TYPE_DEFAULT)) | 163 extensions::AppWindow::WINDOW_TYPE_DEFAULT)) |
164 return true; | 164 return true; |
165 } | 165 } |
166 | 166 |
167 // If there are browser windows, and this notification has been suppressed for | 167 // If there are browser windows, and this notification has been suppressed for |
168 // this session or permanently, then just return false to prevent Chrome from | 168 // this session or permanently, then just return false to prevent Chrome from |
169 // quitting. If there are no browser windows, always show the notification. | 169 // quitting. If there are no browser windows, always show the notification. |
170 bool suppress_always = !g_browser_process->local_state()->GetBoolean( | 170 bool suppress_always = !g_browser_process->local_state()->GetBoolean( |
171 prefs::kNotifyWhenAppsKeepChromeAlive); | 171 prefs::kNotifyWhenAppsKeepChromeAlive); |
172 if (!chrome::BrowserIterator().done() && | 172 if (!BrowserList::GetInstance()->empty() && |
173 (suppress_for_session_ || suppress_always)) { | 173 (suppress_for_session_ || suppress_always)) { |
174 return false; | 174 return false; |
175 } | 175 } |
176 | 176 |
177 ProfileManager* profile_manager = g_browser_process->profile_manager(); | 177 ProfileManager* profile_manager = g_browser_process->profile_manager(); |
178 DCHECK(profile_manager); | 178 DCHECK(profile_manager); |
179 | 179 |
180 std::vector<Profile*> profiles(profile_manager->GetLoadedProfiles()); | 180 std::vector<Profile*> profiles(profile_manager->GetLoadedProfiles()); |
181 DCHECK(profiles.size()); | 181 DCHECK(profiles.size()); |
182 | 182 |
(...skipping 10 matching lines...) Expand all Loading... |
193 | 193 |
194 // Always return false, the notification UI can be used to quit all apps which | 194 // Always return false, the notification UI can be used to quit all apps which |
195 // will cause Chrome to quit. | 195 // will cause Chrome to quit. |
196 return false; | 196 return false; |
197 } | 197 } |
198 | 198 |
199 // static | 199 // static |
200 void QuitWithAppsController::RegisterPrefs(PrefRegistrySimple* registry) { | 200 void QuitWithAppsController::RegisterPrefs(PrefRegistrySimple* registry) { |
201 registry->RegisterBooleanPref(prefs::kNotifyWhenAppsKeepChromeAlive, true); | 201 registry->RegisterBooleanPref(prefs::kNotifyWhenAppsKeepChromeAlive, true); |
202 } | 202 } |
OLD | NEW |