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 626 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
637 // BackgroundModeManager::BackgroundModeData, StatusIconMenuModel overrides | 637 // BackgroundModeManager::BackgroundModeData, StatusIconMenuModel overrides |
638 void BackgroundModeManager::ExecuteCommand(int command_id, int event_flags) { | 638 void BackgroundModeManager::ExecuteCommand(int command_id, int event_flags) { |
639 BackgroundModeData* bmd = GetBackgroundModeDataForLastProfile(); | 639 BackgroundModeData* bmd = GetBackgroundModeDataForLastProfile(); |
640 switch (command_id) { | 640 switch (command_id) { |
641 case IDC_ABOUT: | 641 case IDC_ABOUT: |
642 RecordMenuItemClick(MENU_ITEM_ABOUT); | 642 RecordMenuItemClick(MENU_ITEM_ABOUT); |
643 if (bmd) { | 643 if (bmd) { |
644 chrome::ShowAboutChrome(bmd->GetBrowserWindow()); | 644 chrome::ShowAboutChrome(bmd->GetBrowserWindow()); |
645 } else { | 645 } else { |
646 UserManager::Show(base::FilePath(), | 646 UserManager::Show(base::FilePath(), |
647 profiles::USER_MANAGER_NO_TUTORIAL, | |
648 profiles::USER_MANAGER_SELECT_PROFILE_ABOUT_CHROME); | 647 profiles::USER_MANAGER_SELECT_PROFILE_ABOUT_CHROME); |
649 } | 648 } |
650 break; | 649 break; |
651 case IDC_TASK_MANAGER: | 650 case IDC_TASK_MANAGER: |
652 RecordMenuItemClick(MENU_ITEM_TASK_MANAGER); | 651 RecordMenuItemClick(MENU_ITEM_TASK_MANAGER); |
653 if (bmd) { | 652 if (bmd) { |
654 chrome::OpenTaskManager(bmd->GetBrowserWindow()); | 653 chrome::OpenTaskManager(bmd->GetBrowserWindow()); |
655 } else { | 654 } else { |
656 UserManager::Show(base::FilePath(), | 655 UserManager::Show(base::FilePath(), |
657 profiles::USER_MANAGER_NO_TUTORIAL, | |
658 profiles::USER_MANAGER_SELECT_PROFILE_TASK_MANAGER); | 656 profiles::USER_MANAGER_SELECT_PROFILE_TASK_MANAGER); |
659 } | 657 } |
660 break; | 658 break; |
661 case IDC_EXIT: | 659 case IDC_EXIT: |
662 RecordMenuItemClick(MENU_ITEM_EXIT); | 660 RecordMenuItemClick(MENU_ITEM_EXIT); |
663 base::RecordAction(UserMetricsAction("Exit")); | 661 base::RecordAction(UserMetricsAction("Exit")); |
664 chrome::CloseAllBrowsers(); | 662 chrome::CloseAllBrowsers(); |
665 break; | 663 break; |
666 case IDC_STATUS_TRAY_KEEP_CHROME_RUNNING_IN_BACKGROUND: { | 664 case IDC_STATUS_TRAY_KEEP_CHROME_RUNNING_IN_BACKGROUND: { |
667 // Background mode must already be enabled (as otherwise this menu would | 665 // Background mode must already be enabled (as otherwise this menu would |
668 // not be visible). | 666 // not be visible). |
669 DCHECK(IsBackgroundModePrefEnabled()); | 667 DCHECK(IsBackgroundModePrefEnabled()); |
670 DCHECK(KeepAliveRegistry::GetInstance()->IsKeepingAlive()); | 668 DCHECK(KeepAliveRegistry::GetInstance()->IsKeepingAlive()); |
671 | 669 |
672 RecordMenuItemClick(MENU_ITEM_KEEP_RUNNING); | 670 RecordMenuItemClick(MENU_ITEM_KEEP_RUNNING); |
673 | 671 |
674 // Set the background mode pref to "disabled" - the resulting notification | 672 // Set the background mode pref to "disabled" - the resulting notification |
675 // will result in a call to DisableBackgroundMode(). | 673 // will result in a call to DisableBackgroundMode(). |
676 PrefService* service = g_browser_process->local_state(); | 674 PrefService* service = g_browser_process->local_state(); |
677 DCHECK(service); | 675 DCHECK(service); |
678 service->SetBoolean(prefs::kBackgroundModeEnabled, false); | 676 service->SetBoolean(prefs::kBackgroundModeEnabled, false); |
679 break; | 677 break; |
680 } | 678 } |
681 default: | 679 default: |
682 if (bmd) { | 680 if (bmd) { |
683 bmd->ExecuteCommand(command_id, event_flags); | 681 bmd->ExecuteCommand(command_id, event_flags); |
684 } else { | 682 } else { |
685 UserManager::Show(base::FilePath(), | 683 UserManager::Show(base::FilePath(), |
686 profiles::USER_MANAGER_NO_TUTORIAL, | |
687 profiles::USER_MANAGER_SELECT_PROFILE_NO_ACTION); | 684 profiles::USER_MANAGER_SELECT_PROFILE_NO_ACTION); |
688 } | 685 } |
689 break; | 686 break; |
690 } | 687 } |
691 } | 688 } |
692 | 689 |
693 | 690 |
694 /////////////////////////////////////////////////////////////////////////////// | 691 /////////////////////////////////////////////////////////////////////////////// |
695 // BackgroundModeManager, private | 692 // BackgroundModeManager, private |
696 void BackgroundModeManager::ReleaseStartupKeepAliveCallback() { | 693 void BackgroundModeManager::ReleaseStartupKeepAliveCallback() { |
(...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1050 } | 1047 } |
1051 } | 1048 } |
1052 return profile_it; | 1049 return profile_it; |
1053 } | 1050 } |
1054 | 1051 |
1055 bool BackgroundModeManager::IsBackgroundModePrefEnabled() const { | 1052 bool BackgroundModeManager::IsBackgroundModePrefEnabled() const { |
1056 PrefService* service = g_browser_process->local_state(); | 1053 PrefService* service = g_browser_process->local_state(); |
1057 DCHECK(service); | 1054 DCHECK(service); |
1058 return service->GetBoolean(prefs::kBackgroundModeEnabled); | 1055 return service->GetBoolean(prefs::kBackgroundModeEnabled); |
1059 } | 1056 } |
OLD | NEW |