OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 <string> | 5 #include <string> |
6 | 6 |
7 #include "base/base_paths.h" | 7 #include "base/base_paths.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
11 #include "chrome/app/chrome_command_ids.h" | 11 #include "chrome/app/chrome_command_ids.h" |
12 #include "chrome/browser/background_application_list_model.h" | 12 #include "chrome/browser/background_application_list_model.h" |
13 #include "chrome/browser/background_mode_manager.h" | 13 #include "chrome/browser/background_mode_manager.h" |
14 #include "chrome/browser/browser_process.h" | 14 #include "chrome/browser/browser_process.h" |
15 #include "chrome/browser/extensions/extension_service.h" | 15 #include "chrome/browser/extensions/extension_service.h" |
16 #include "chrome/browser/platform_util.h" | |
17 #include "chrome/browser/profiles/profile.h" | 16 #include "chrome/browser/profiles/profile.h" |
18 #include "chrome/browser/status_icons/status_icon.h" | 17 #include "chrome/browser/status_icons/status_icon.h" |
19 #include "chrome/browser/status_icons/status_tray.h" | 18 #include "chrome/browser/status_icons/status_tray.h" |
20 #include "chrome/browser/ui/browser_list.h" | 19 #include "chrome/browser/ui/browser_list.h" |
21 #include "chrome/common/chrome_switches.h" | 20 #include "chrome/common/chrome_switches.h" |
22 #include "chrome/common/extensions/extension.h" | 21 #include "chrome/common/extensions/extension.h" |
23 #include "chrome/common/pref_names.h" | 22 #include "chrome/common/pref_names.h" |
24 #include "content/browser/user_metrics.h" | 23 #include "content/browser/user_metrics.h" |
25 #include "content/common/notification_service.h" | 24 #include "content/common/notification_service.h" |
26 #include "content/common/notification_type.h" | 25 #include "content/common/notification_type.h" |
(...skipping 362 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
389 GetBrowserWindow()->OpenOptionsDialog(); | 388 GetBrowserWindow()->OpenOptionsDialog(); |
390 break; | 389 break; |
391 case IDC_TASK_MANAGER: | 390 case IDC_TASK_MANAGER: |
392 GetBrowserWindow()->OpenTaskManager(true); | 391 GetBrowserWindow()->OpenTaskManager(true); |
393 break; | 392 break; |
394 case IDC_STATUS_TRAY_KEEP_CHROME_RUNNING_IN_BACKGROUND: { | 393 case IDC_STATUS_TRAY_KEEP_CHROME_RUNNING_IN_BACKGROUND: { |
395 // Background mode must already be enabled (as otherwise this menu would | 394 // Background mode must already be enabled (as otherwise this menu would |
396 // not be visible). | 395 // not be visible). |
397 DCHECK(IsBackgroundModePrefEnabled()); | 396 DCHECK(IsBackgroundModePrefEnabled()); |
398 DCHECK(BrowserList::WillKeepAlive()); | 397 DCHECK(BrowserList::WillKeepAlive()); |
399 if (BrowserList::size() == 0) { | |
400 // There are no windows open - unchecking this will exit Chrome. Warn | |
401 // the user. | |
402 string16 tab_title = l10n_util::GetStringFUTF16(IDS_OPTIONS_TAB_TITLE, | |
403 l10n_util::GetStringUTF16(IDS_SETTINGS_TITLE), | |
404 l10n_util::GetStringUTF16(IDS_OPTIONS_ADVANCED_TAB_LABEL)); | |
405 | |
406 if (!platform_util::SimpleYesNoBox( | |
407 NULL, | |
408 l10n_util::GetStringUTF16(IDS_PRODUCT_NAME), | |
409 l10n_util::GetStringFUTF16( | |
410 IDS_CONFIRM_EXIT_BACKGROUND_MODE_BODY, | |
411 tab_title))) { | |
412 return; | |
413 } | |
414 } | |
415 | 398 |
416 // Set the background mode pref to "disabled" - the resulting notification | 399 // Set the background mode pref to "disabled" - the resulting notification |
417 // will result in a call to DisableBackgroundMode(). | 400 // will result in a call to DisableBackgroundMode(). |
418 PrefService* service = g_browser_process->local_state(); | 401 PrefService* service = g_browser_process->local_state(); |
419 DCHECK(service); | 402 DCHECK(service); |
420 service->SetBoolean(prefs::kBackgroundModeEnabled, false); | 403 service->SetBoolean(prefs::kBackgroundModeEnabled, false); |
421 break; | 404 break; |
422 } | 405 } |
423 default: | 406 default: |
424 ExecuteApplication(item); | 407 ExecuteApplication(item); |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
457 PrefService* service = g_browser_process->local_state(); | 440 PrefService* service = g_browser_process->local_state(); |
458 DCHECK(service); | 441 DCHECK(service); |
459 return service->GetBoolean(prefs::kBackgroundModeEnabled); | 442 return service->GetBoolean(prefs::kBackgroundModeEnabled); |
460 } | 443 } |
461 | 444 |
462 // static | 445 // static |
463 void BackgroundModeManager::RegisterPrefs(PrefService* prefs) { | 446 void BackgroundModeManager::RegisterPrefs(PrefService* prefs) { |
464 prefs->RegisterBooleanPref(prefs::kUserCreatedLoginItem, false); | 447 prefs->RegisterBooleanPref(prefs::kUserCreatedLoginItem, false); |
465 prefs->RegisterBooleanPref(prefs::kBackgroundModeEnabled, true); | 448 prefs->RegisterBooleanPref(prefs::kBackgroundModeEnabled, true); |
466 } | 449 } |
OLD | NEW |