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

Side by Side Diff: chrome/browser/ui/cocoa/apps/quit_with_apps_controller_mac.cc

Issue 494033002: Move AppWindow to extensions (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Remove unneeded include in chrome_shell_delegate.cc Created 6 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
OLDNEW
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"
8 #include "apps/app_window_registry.h"
9 #include "base/command_line.h" 7 #include "base/command_line.h"
10 #include "base/i18n/number_formatting.h" 8 #include "base/i18n/number_formatting.h"
11 #include "base/prefs/pref_registry_simple.h" 9 #include "base/prefs/pref_registry_simple.h"
12 #include "base/prefs/pref_service.h" 10 #include "base/prefs/pref_service.h"
13 #include "base/strings/sys_string_conversions.h" 11 #include "base/strings/sys_string_conversions.h"
14 #include "base/strings/utf_string_conversions.h" 12 #include "base/strings/utf_string_conversions.h"
15 #include "chrome/browser/browser_process.h" 13 #include "chrome/browser/browser_process.h"
16 #include "chrome/browser/notifications/notification.h" 14 #include "chrome/browser/notifications/notification.h"
17 #include "chrome/browser/notifications/notification_ui_manager.h" 15 #include "chrome/browser/notifications/notification_ui_manager.h"
18 #include "chrome/browser/profiles/profile_manager.h" 16 #include "chrome/browser/profiles/profile_manager.h"
19 #include "chrome/browser/ui/browser_iterator.h" 17 #include "chrome/browser/ui/browser_iterator.h"
20 #include "chrome/common/chrome_switches.h" 18 #include "chrome/common/chrome_switches.h"
21 #include "chrome/common/pref_names.h" 19 #include "chrome/common/pref_names.h"
22 #include "chrome/grit/chromium_strings.h" 20 #include "chrome/grit/chromium_strings.h"
23 #include "chrome/grit/generated_resources.h" 21 #include "chrome/grit/generated_resources.h"
24 #include "chrome/grit/google_chrome_strings.h" 22 #include "chrome/grit/google_chrome_strings.h"
23 #include "extensions/browser/app_window/app_window.h"
24 #include "extensions/browser/app_window/app_window_registry.h"
25 #include "extensions/browser/app_window/native_app_window.h" 25 #include "extensions/browser/app_window/native_app_window.h"
26 #include "extensions/common/extension.h" 26 #include "extensions/common/extension.h"
27 #include "grit/chrome_unscaled_resources.h" 27 #include "grit/chrome_unscaled_resources.h"
28 #include "ui/base/l10n/l10n_util.h" 28 #include "ui/base/l10n/l10n_util.h"
29 #include "ui/base/l10n/l10n_util_mac.h" 29 #include "ui/base/l10n/l10n_util_mac.h"
30 #include "ui/base/resource/resource_bundle.h" 30 #include "ui/base/resource/resource_bundle.h"
31 31
32 const char kQuitWithAppsOriginUrl[] = "chrome://quit-with-apps"; 32 const char kQuitWithAppsOriginUrl[] = "chrome://quit-with-apps";
33 const int kQuitAllAppsButtonIndex = 0; 33 const int kQuitAllAppsButtonIndex = 0;
34 const int kDontShowAgainButtonIndex = 1; 34 const int kDontShowAgainButtonIndex = 1;
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 suppress_for_session_ = true; 79 suppress_for_session_ = true;
80 } 80 }
81 81
82 void QuitWithAppsController::Click() { 82 void QuitWithAppsController::Click() {
83 g_browser_process->notification_ui_manager()->CancelById(id()); 83 g_browser_process->notification_ui_manager()->CancelById(id());
84 } 84 }
85 85
86 void QuitWithAppsController::ButtonClick(int button_index) { 86 void QuitWithAppsController::ButtonClick(int button_index) {
87 g_browser_process->notification_ui_manager()->CancelById(id()); 87 g_browser_process->notification_ui_manager()->CancelById(id());
88 if (button_index == kQuitAllAppsButtonIndex) { 88 if (button_index == kQuitAllAppsButtonIndex) {
89 apps::AppWindowRegistry::CloseAllAppWindows(); 89 extensions::AppWindowRegistry::CloseAllAppWindows();
90 } else if (button_index == kDontShowAgainButtonIndex) { 90 } else if (button_index == kDontShowAgainButtonIndex) {
91 g_browser_process->local_state()->SetBoolean( 91 g_browser_process->local_state()->SetBoolean(
92 prefs::kNotifyWhenAppsKeepChromeAlive, false); 92 prefs::kNotifyWhenAppsKeepChromeAlive, false);
93 } 93 }
94 } 94 }
95 95
96 content::WebContents* QuitWithAppsController::GetWebContents() const { 96 content::WebContents* QuitWithAppsController::GetWebContents() const {
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 // Quit immediately if this is a test. 107 // Quit immediately if this is a test.
108 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kTestType) && 108 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kTestType) &&
109 !CommandLine::ForCurrentProcess()->HasSwitch( 109 !CommandLine::ForCurrentProcess()->HasSwitch(
110 switches::kAppsKeepChromeAliveInTests)) { 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 (!extensions::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
121 // quitting. If there are no browser windows, always show the notification. 121 // quitting. If there are no browser windows, always show the notification.
122 bool suppress_always = !g_browser_process->local_state()->GetBoolean( 122 bool suppress_always = !g_browser_process->local_state()->GetBoolean(
123 prefs::kNotifyWhenAppsKeepChromeAlive); 123 prefs::kNotifyWhenAppsKeepChromeAlive);
124 if (!chrome::BrowserIterator().done() && 124 if (!chrome::BrowserIterator().done() &&
125 (suppress_for_session_ || suppress_always)) { 125 (suppress_for_session_ || suppress_always)) {
126 return false; 126 return false;
(...skipping 12 matching lines...) Expand all
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 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698