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/background_application_list_model.h" | 12 #include "chrome/browser/background/background_application_list_model.h" |
13 #include "chrome/browser/background/background_mode_manager.h" | 13 #include "chrome/browser/background/background_mode_manager.h" |
14 #include "chrome/browser/browser_process.h" | 14 #include "chrome/browser/browser_process.h" |
15 #include "chrome/browser/browser_shutdown.h" | 15 #include "chrome/browser/browser_shutdown.h" |
16 #include "chrome/browser/extensions/extension_service.h" | 16 #include "chrome/browser/extensions/extension_service.h" |
17 #include "chrome/browser/profiles/profile.h" | 17 #include "chrome/browser/profiles/profile.h" |
18 #include "chrome/browser/profiles/profile_info_cache.h" | 18 #include "chrome/browser/profiles/profile_info_cache.h" |
19 #include "chrome/browser/status_icons/status_icon.h" | 19 #include "chrome/browser/status_icons/status_icon.h" |
20 #include "chrome/browser/status_icons/status_tray.h" | 20 #include "chrome/browser/status_icons/status_tray.h" |
21 #include "chrome/browser/ui/browser_list.h" | 21 #include "chrome/browser/ui/browser_list.h" |
22 #include "chrome/common/chrome_constants.h" | 22 #include "chrome/common/chrome_constants.h" |
23 #include "chrome/common/chrome_notification_types.h" | 23 #include "chrome/common/chrome_notification_types.h" |
24 #include "chrome/common/chrome_switches.h" | 24 #include "chrome/common/chrome_switches.h" |
25 #include "chrome/common/extensions/extension.h" | 25 #include "chrome/common/extensions/extension.h" |
26 #include "chrome/common/extensions/extension_constants.h" | 26 #include "chrome/common/extensions/extension_constants.h" |
27 #include "chrome/common/pref_names.h" | 27 #include "chrome/common/pref_names.h" |
28 #include "content/browser/user_metrics.h" | 28 #include "content/browser/user_metrics.h" |
29 #include "content/common/notification_service.h" | 29 #include "content/public/browser/notification_service.h" |
30 #include "content/public/browser/notification_types.h" | 30 #include "content/public/browser/notification_types.h" |
31 #include "grit/chromium_strings.h" | 31 #include "grit/chromium_strings.h" |
32 #include "grit/generated_resources.h" | 32 #include "grit/generated_resources.h" |
33 #include "grit/theme_resources.h" | 33 #include "grit/theme_resources.h" |
34 #include "ui/base/l10n/l10n_util.h" | 34 #include "ui/base/l10n/l10n_util.h" |
35 #include "ui/base/resource/resource_bundle.h" | 35 #include "ui/base/resource/resource_bundle.h" |
36 | 36 |
37 BackgroundModeManager::BackgroundModeData::BackgroundModeData( | 37 BackgroundModeManager::BackgroundModeData::BackgroundModeData( |
38 int command_id, | 38 int command_id, |
39 Profile* profile, | 39 Profile* profile, |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
169 // in the background until the user explicitly terminates it, by acting as if | 169 // in the background until the user explicitly terminates it, by acting as if |
170 // we loaded a background app. | 170 // we loaded a background app. |
171 if (command_line->HasSwitch(switches::kKeepAliveForTest)) { | 171 if (command_line->HasSwitch(switches::kKeepAliveForTest)) { |
172 keep_alive_for_test_ = true; | 172 keep_alive_for_test_ = true; |
173 StartBackgroundMode(); | 173 StartBackgroundMode(); |
174 } | 174 } |
175 | 175 |
176 // Listen for the application shutting down so we can decrement our KeepAlive | 176 // Listen for the application shutting down so we can decrement our KeepAlive |
177 // count. | 177 // count. |
178 registrar_.Add(this, content::NOTIFICATION_APP_TERMINATING, | 178 registrar_.Add(this, content::NOTIFICATION_APP_TERMINATING, |
179 NotificationService::AllSources()); | 179 content::NotificationService::AllSources()); |
180 } | 180 } |
181 | 181 |
182 BackgroundModeManager::~BackgroundModeManager() { | 182 BackgroundModeManager::~BackgroundModeManager() { |
183 // Remove ourselves from the application observer list (only needed by unit | 183 // Remove ourselves from the application observer list (only needed by unit |
184 // tests since APP_TERMINATING is what does this in a real running system). | 184 // tests since APP_TERMINATING is what does this in a real running system). |
185 for (std::map<Profile*, BackgroundModeInfo>::iterator it = | 185 for (std::map<Profile*, BackgroundModeInfo>::iterator it = |
186 background_mode_data_.begin(); | 186 background_mode_data_.begin(); |
187 it != background_mode_data_.end(); | 187 it != background_mode_data_.end(); |
188 ++it) { | 188 ++it) { |
189 it->second->applications_->RemoveObserver(this); | 189 it->second->applications_->RemoveObserver(this); |
(...skipping 459 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
649 command_line->HasSwitch(switches::kDisableExtensions); | 649 command_line->HasSwitch(switches::kDisableExtensions); |
650 return background_mode_disabled; | 650 return background_mode_disabled; |
651 #endif | 651 #endif |
652 } | 652 } |
653 | 653 |
654 bool BackgroundModeManager::IsBackgroundModePrefEnabled() const { | 654 bool BackgroundModeManager::IsBackgroundModePrefEnabled() const { |
655 PrefService* service = g_browser_process->local_state(); | 655 PrefService* service = g_browser_process->local_state(); |
656 DCHECK(service); | 656 DCHECK(service); |
657 return service->GetBoolean(prefs::kBackgroundModeEnabled); | 657 return service->GetBoolean(prefs::kBackgroundModeEnabled); |
658 } | 658 } |
OLD | NEW |