OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/background/background_mode_manager.h" | 5 #include "chrome/browser/background/background_mode_manager.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <algorithm> | 8 #include <algorithm> |
9 #include <string> | 9 #include <string> |
10 #include <utility> | 10 #include <utility> |
(...skipping 11 matching lines...) Expand all Loading... |
22 #include "base/thread_task_runner_handle.h" | 22 #include "base/thread_task_runner_handle.h" |
23 #include "build/build_config.h" | 23 #include "build/build_config.h" |
24 #include "chrome/app/chrome_command_ids.h" | 24 #include "chrome/app/chrome_command_ids.h" |
25 #include "chrome/browser/background/background_application_list_model.h" | 25 #include "chrome/browser/background/background_application_list_model.h" |
26 #include "chrome/browser/background/background_trigger.h" | 26 #include "chrome/browser/background/background_trigger.h" |
27 #include "chrome/browser/browser_process.h" | 27 #include "chrome/browser/browser_process.h" |
28 #include "chrome/browser/browser_shutdown.h" | 28 #include "chrome/browser/browser_shutdown.h" |
29 #include "chrome/browser/chrome_notification_types.h" | 29 #include "chrome/browser/chrome_notification_types.h" |
30 #include "chrome/browser/extensions/extension_service.h" | 30 #include "chrome/browser/extensions/extension_service.h" |
31 #include "chrome/browser/lifetime/application_lifetime.h" | 31 #include "chrome/browser/lifetime/application_lifetime.h" |
| 32 #include "chrome/browser/lifetime/keep_alive_registry.h" |
32 #include "chrome/browser/lifetime/keep_alive_types.h" | 33 #include "chrome/browser/lifetime/keep_alive_types.h" |
33 #include "chrome/browser/profiles/profile.h" | 34 #include "chrome/browser/profiles/profile.h" |
34 #include "chrome/browser/profiles/profile_attributes_entry.h" | 35 #include "chrome/browser/profiles/profile_attributes_entry.h" |
35 #include "chrome/browser/profiles/profile_manager.h" | 36 #include "chrome/browser/profiles/profile_manager.h" |
36 #include "chrome/browser/status_icons/status_icon.h" | 37 #include "chrome/browser/status_icons/status_icon.h" |
37 #include "chrome/browser/status_icons/status_tray.h" | 38 #include "chrome/browser/status_icons/status_tray.h" |
38 #include "chrome/browser/ui/browser.h" | 39 #include "chrome/browser/ui/browser.h" |
39 #include "chrome/browser/ui/browser_commands.h" | 40 #include "chrome/browser/ui/browser_commands.h" |
40 #include "chrome/browser/ui/browser_dialogs.h" | 41 #include "chrome/browser/ui/browser_dialogs.h" |
41 #include "chrome/browser/ui/browser_finder.h" | 42 #include "chrome/browser/ui/browser_finder.h" |
(...skipping 599 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
641 break; | 642 break; |
642 case IDC_EXIT: | 643 case IDC_EXIT: |
643 RecordMenuItemClick(MENU_ITEM_EXIT); | 644 RecordMenuItemClick(MENU_ITEM_EXIT); |
644 content::RecordAction(UserMetricsAction("Exit")); | 645 content::RecordAction(UserMetricsAction("Exit")); |
645 chrome::CloseAllBrowsers(); | 646 chrome::CloseAllBrowsers(); |
646 break; | 647 break; |
647 case IDC_STATUS_TRAY_KEEP_CHROME_RUNNING_IN_BACKGROUND: { | 648 case IDC_STATUS_TRAY_KEEP_CHROME_RUNNING_IN_BACKGROUND: { |
648 // Background mode must already be enabled (as otherwise this menu would | 649 // Background mode must already be enabled (as otherwise this menu would |
649 // not be visible). | 650 // not be visible). |
650 DCHECK(IsBackgroundModePrefEnabled()); | 651 DCHECK(IsBackgroundModePrefEnabled()); |
651 DCHECK(chrome::WillKeepAlive()); | 652 DCHECK(KeepAliveRegistry::GetInstance()->IsKeepingAlive()); |
652 | 653 |
653 RecordMenuItemClick(MENU_ITEM_KEEP_RUNNING); | 654 RecordMenuItemClick(MENU_ITEM_KEEP_RUNNING); |
654 | 655 |
655 // Set the background mode pref to "disabled" - the resulting notification | 656 // Set the background mode pref to "disabled" - the resulting notification |
656 // will result in a call to DisableBackgroundMode(). | 657 // will result in a call to DisableBackgroundMode(). |
657 PrefService* service = g_browser_process->local_state(); | 658 PrefService* service = g_browser_process->local_state(); |
658 DCHECK(service); | 659 DCHECK(service); |
659 service->SetBoolean(prefs::kBackgroundModeEnabled, false); | 660 service->SetBoolean(prefs::kBackgroundModeEnabled, false); |
660 break; | 661 break; |
661 } | 662 } |
(...skipping 367 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1029 } | 1030 } |
1030 } | 1031 } |
1031 return profile_it; | 1032 return profile_it; |
1032 } | 1033 } |
1033 | 1034 |
1034 bool BackgroundModeManager::IsBackgroundModePrefEnabled() const { | 1035 bool BackgroundModeManager::IsBackgroundModePrefEnabled() const { |
1035 PrefService* service = g_browser_process->local_state(); | 1036 PrefService* service = g_browser_process->local_state(); |
1036 DCHECK(service); | 1037 DCHECK(service); |
1037 return service->GetBoolean(prefs::kBackgroundModeEnabled); | 1038 return service->GetBoolean(prefs::kBackgroundModeEnabled); |
1038 } | 1039 } |
OLD | NEW |