| 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/bind.h" | 8 #include "base/bind.h" |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| 11 #include "base/utf_string_conversions.h" | 11 #include "base/utf_string_conversions.h" |
| 12 #include "chrome/app/chrome_command_ids.h" | 12 #include "chrome/app/chrome_command_ids.h" |
| 13 #include "chrome/browser/background/background_application_list_model.h" | 13 #include "chrome/browser/background/background_application_list_model.h" |
| 14 #include "chrome/browser/background/background_mode_manager.h" | 14 #include "chrome/browser/background/background_mode_manager.h" |
| 15 #include "chrome/browser/browser_process.h" | 15 #include "chrome/browser/browser_process.h" |
| 16 #include "chrome/browser/browser_shutdown.h" | 16 #include "chrome/browser/browser_shutdown.h" |
| 17 #include "chrome/browser/extensions/extension_service.h" | 17 #include "chrome/browser/extensions/extension_service.h" |
| 18 #include "chrome/browser/profiles/profile.h" | 18 #include "chrome/browser/profiles/profile.h" |
| 19 #include "chrome/browser/profiles/profile_info_cache.h" | 19 #include "chrome/browser/profiles/profile_info_cache.h" |
| 20 #include "chrome/browser/status_icons/status_icon.h" | 20 #include "chrome/browser/status_icons/status_icon.h" |
| 21 #include "chrome/browser/status_icons/status_tray.h" | 21 #include "chrome/browser/status_icons/status_tray.h" |
| 22 #include "chrome/browser/ui/browser_list.h" | 22 #include "chrome/browser/ui/browser_list.h" |
| 23 #include "chrome/common/chrome_constants.h" | 23 #include "chrome/common/chrome_constants.h" |
| 24 #include "chrome/common/chrome_notification_types.h" | 24 #include "chrome/common/chrome_notification_types.h" |
| 25 #include "chrome/common/chrome_switches.h" | 25 #include "chrome/common/chrome_switches.h" |
| 26 #include "chrome/common/extensions/extension.h" | 26 #include "chrome/common/extensions/extension.h" |
| 27 #include "chrome/common/extensions/extension_constants.h" | 27 #include "chrome/common/extensions/extension_constants.h" |
| 28 #include "chrome/common/pref_names.h" | 28 #include "chrome/common/pref_names.h" |
| 29 #include "content/browser/user_metrics.h" | |
| 30 #include "content/public/browser/notification_service.h" | 29 #include "content/public/browser/notification_service.h" |
| 31 #include "content/public/browser/notification_types.h" | 30 #include "content/public/browser/notification_types.h" |
| 31 #include "content/public/browser/user_metrics.h" |
| 32 #include "grit/chromium_strings.h" | 32 #include "grit/chromium_strings.h" |
| 33 #include "grit/generated_resources.h" | 33 #include "grit/generated_resources.h" |
| 34 #include "grit/theme_resources.h" | 34 #include "grit/theme_resources.h" |
| 35 #include "ui/base/l10n/l10n_util.h" | 35 #include "ui/base/l10n/l10n_util.h" |
| 36 #include "ui/base/resource/resource_bundle.h" | 36 #include "ui/base/resource/resource_bundle.h" |
| 37 | 37 |
| 38 using content::UserMetricsAction; |
| 39 |
| 38 BackgroundModeManager::BackgroundModeData::BackgroundModeData( | 40 BackgroundModeManager::BackgroundModeData::BackgroundModeData( |
| 39 int command_id, | 41 int command_id, |
| 40 Profile* profile) | 42 Profile* profile) |
| 41 : applications_(new BackgroundApplicationListModel(profile)), | 43 : applications_(new BackgroundApplicationListModel(profile)), |
| 42 command_id_(command_id), | 44 command_id_(command_id), |
| 43 profile_(profile) { | 45 profile_(profile) { |
| 44 } | 46 } |
| 45 | 47 |
| 46 BackgroundModeManager::BackgroundModeData::~BackgroundModeData() { | 48 BackgroundModeManager::BackgroundModeData::~BackgroundModeData() { |
| 47 } | 49 } |
| (...skipping 412 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 460 // work and the first is convenient. | 462 // work and the first is convenient. |
| 461 BackgroundModeData* bmd = background_mode_data_.begin()->second.get(); | 463 BackgroundModeData* bmd = background_mode_data_.begin()->second.get(); |
| 462 switch (command_id) { | 464 switch (command_id) { |
| 463 case IDC_ABOUT: | 465 case IDC_ABOUT: |
| 464 bmd->GetBrowserWindow()->OpenAboutChromeDialog(); | 466 bmd->GetBrowserWindow()->OpenAboutChromeDialog(); |
| 465 break; | 467 break; |
| 466 case IDC_TASK_MANAGER: | 468 case IDC_TASK_MANAGER: |
| 467 bmd->GetBrowserWindow()->OpenTaskManager(true); | 469 bmd->GetBrowserWindow()->OpenTaskManager(true); |
| 468 break; | 470 break; |
| 469 case IDC_EXIT: | 471 case IDC_EXIT: |
| 470 UserMetrics::RecordAction(UserMetricsAction("Exit")); | 472 content::RecordAction(UserMetricsAction("Exit")); |
| 471 BrowserList::AttemptExit(); | 473 BrowserList::AttemptExit(); |
| 472 break; | 474 break; |
| 473 case IDC_STATUS_TRAY_KEEP_CHROME_RUNNING_IN_BACKGROUND: { | 475 case IDC_STATUS_TRAY_KEEP_CHROME_RUNNING_IN_BACKGROUND: { |
| 474 // Background mode must already be enabled (as otherwise this menu would | 476 // Background mode must already be enabled (as otherwise this menu would |
| 475 // not be visible). | 477 // not be visible). |
| 476 DCHECK(IsBackgroundModePrefEnabled()); | 478 DCHECK(IsBackgroundModePrefEnabled()); |
| 477 DCHECK(BrowserList::WillKeepAlive()); | 479 DCHECK(BrowserList::WillKeepAlive()); |
| 478 | 480 |
| 479 // Set the background mode pref to "disabled" - the resulting notification | 481 // Set the background mode pref to "disabled" - the resulting notification |
| 480 // will result in a call to DisableBackgroundMode(). | 482 // will result in a call to DisableBackgroundMode(). |
| (...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 738 command_line->HasSwitch(switches::kDisableExtensions); | 740 command_line->HasSwitch(switches::kDisableExtensions); |
| 739 return background_mode_disabled; | 741 return background_mode_disabled; |
| 740 #endif | 742 #endif |
| 741 } | 743 } |
| 742 | 744 |
| 743 bool BackgroundModeManager::IsBackgroundModePrefEnabled() const { | 745 bool BackgroundModeManager::IsBackgroundModePrefEnabled() const { |
| 744 PrefService* service = g_browser_process->local_state(); | 746 PrefService* service = g_browser_process->local_state(); |
| 745 DCHECK(service); | 747 DCHECK(service); |
| 746 return service->GetBoolean(prefs::kBackgroundModeEnabled); | 748 return service->GetBoolean(prefs::kBackgroundModeEnabled); |
| 747 } | 749 } |
| OLD | NEW |