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 <algorithm> | 5 #include <algorithm> |
6 #include <string> | 6 #include <string> |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/base_paths.h" | 9 #include "base/base_paths.h" |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
11 #include "base/command_line.h" | 11 #include "base/command_line.h" |
12 #include "base/logging.h" | 12 #include "base/logging.h" |
13 #include "base/utf_string_conversions.h" | 13 #include "base/utf_string_conversions.h" |
14 #include "chrome/app/chrome_command_ids.h" | 14 #include "chrome/app/chrome_command_ids.h" |
15 #include "chrome/browser/background/background_application_list_model.h" | 15 #include "chrome/browser/background/background_application_list_model.h" |
16 #include "chrome/browser/background/background_mode_manager.h" | 16 #include "chrome/browser/background/background_mode_manager.h" |
17 #include "chrome/browser/browser_process.h" | 17 #include "chrome/browser/browser_process.h" |
18 #include "chrome/browser/browser_shutdown.h" | 18 #include "chrome/browser/browser_shutdown.h" |
19 #include "chrome/browser/extensions/extension_service.h" | 19 #include "chrome/browser/extensions/extension_service.h" |
20 #include "chrome/browser/extensions/extension_system.h" | 20 #include "chrome/browser/extensions/extension_system.h" |
21 #include "chrome/browser/lifetime/application_lifetime.h" | 21 #include "chrome/browser/lifetime/application_lifetime.h" |
| 22 #include "chrome/browser/prefs/pref_registry_simple.h" |
22 #include "chrome/browser/prefs/pref_service.h" | 23 #include "chrome/browser/prefs/pref_service.h" |
23 #include "chrome/browser/profiles/profile.h" | 24 #include "chrome/browser/profiles/profile.h" |
24 #include "chrome/browser/profiles/profile_info_cache.h" | 25 #include "chrome/browser/profiles/profile_info_cache.h" |
25 #include "chrome/browser/profiles/profile_manager.h" | 26 #include "chrome/browser/profiles/profile_manager.h" |
26 #include "chrome/browser/status_icons/status_icon.h" | 27 #include "chrome/browser/status_icons/status_icon.h" |
27 #include "chrome/browser/status_icons/status_tray.h" | 28 #include "chrome/browser/status_icons/status_tray.h" |
28 #include "chrome/browser/ui/browser.h" | 29 #include "chrome/browser/ui/browser.h" |
29 #include "chrome/browser/ui/browser_commands.h" | 30 #include "chrome/browser/ui/browser_commands.h" |
30 #include "chrome/browser/ui/browser_finder.h" | 31 #include "chrome/browser/ui/browser_finder.h" |
31 #include "chrome/browser/ui/chrome_pages.h" | 32 #include "chrome/browser/ui/chrome_pages.h" |
32 #include "chrome/browser/ui/extensions/application_launch.h" | 33 #include "chrome/browser/ui/extensions/application_launch.h" |
33 #include "chrome/browser/ui/host_desktop.h" | 34 #include "chrome/browser/ui/host_desktop.h" |
34 #include "chrome/common/chrome_constants.h" | 35 #include "chrome/common/chrome_constants.h" |
35 #include "chrome/common/chrome_notification_types.h" | 36 #include "chrome/common/chrome_notification_types.h" |
36 #include "chrome/common/chrome_switches.h" | 37 #include "chrome/common/chrome_switches.h" |
37 #include "chrome/common/extensions/extension.h" | 38 #include "chrome/common/extensions/extension.h" |
38 #include "chrome/common/extensions/extension_constants.h" | 39 #include "chrome/common/extensions/extension_constants.h" |
39 #include "chrome/common/extensions/permissions/permission_set.h" | 40 #include "chrome/common/extensions/permissions/permission_set.h" |
40 #include "chrome/common/pref_names.h" | 41 #include "chrome/common/pref_names.h" |
41 #include "content/public/browser/notification_service.h" | 42 #include "content/public/browser/notification_service.h" |
42 #include "content/public/browser/user_metrics.h" | 43 #include "content/public/browser/user_metrics.h" |
| 44 #include "grit/chrome_unscaled_resources.h" |
43 #include "grit/chromium_strings.h" | 45 #include "grit/chromium_strings.h" |
44 #include "grit/generated_resources.h" | 46 #include "grit/generated_resources.h" |
45 #include "grit/chrome_unscaled_resources.h" | |
46 #include "ui/base/l10n/l10n_util.h" | 47 #include "ui/base/l10n/l10n_util.h" |
47 #include "ui/base/resource/resource_bundle.h" | 48 #include "ui/base/resource/resource_bundle.h" |
48 | 49 |
49 using content::UserMetricsAction; | 50 using content::UserMetricsAction; |
50 using extensions::Extension; | 51 using extensions::Extension; |
51 using extensions::UpdatedExtensionPermissionsInfo; | 52 using extensions::UpdatedExtensionPermissionsInfo; |
52 | 53 |
53 BackgroundModeManager::BackgroundModeData::BackgroundModeData( | 54 BackgroundModeManager::BackgroundModeData::BackgroundModeData( |
54 int command_id, | 55 int command_id, |
55 Profile* profile) | 56 Profile* profile) |
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
212 } | 213 } |
213 | 214 |
214 // We're going away, so exit background mode (does nothing if we aren't in | 215 // We're going away, so exit background mode (does nothing if we aren't in |
215 // background mode currently). This is primarily needed for unit tests, | 216 // background mode currently). This is primarily needed for unit tests, |
216 // because in an actual running system we'd get an APP_TERMINATING | 217 // because in an actual running system we'd get an APP_TERMINATING |
217 // notification before being destroyed. | 218 // notification before being destroyed. |
218 EndBackgroundMode(); | 219 EndBackgroundMode(); |
219 } | 220 } |
220 | 221 |
221 // static | 222 // static |
222 void BackgroundModeManager::RegisterPrefs(PrefServiceSimple* prefs) { | 223 void BackgroundModeManager::RegisterPrefs(PrefRegistrySimple* prefs) { |
223 prefs->RegisterBooleanPref(prefs::kUserCreatedLoginItem, false); | 224 prefs->RegisterBooleanPref(prefs::kUserCreatedLoginItem, false); |
224 prefs->RegisterBooleanPref(prefs::kUserRemovedLoginItem, false); | 225 prefs->RegisterBooleanPref(prefs::kUserRemovedLoginItem, false); |
225 prefs->RegisterBooleanPref(prefs::kBackgroundModeEnabled, true); | 226 prefs->RegisterBooleanPref(prefs::kBackgroundModeEnabled, true); |
226 } | 227 } |
227 | 228 |
228 | 229 |
229 void BackgroundModeManager::RegisterProfile(Profile* profile) { | 230 void BackgroundModeManager::RegisterProfile(Profile* profile) { |
230 // We don't want to register multiple times for one profile. | 231 // We don't want to register multiple times for one profile. |
231 DCHECK(background_mode_data_.find(profile) == background_mode_data_.end()); | 232 DCHECK(background_mode_data_.find(profile) == background_mode_data_.end()); |
232 BackgroundModeInfo bmd(new BackgroundModeData(current_command_id_++, | 233 BackgroundModeInfo bmd(new BackgroundModeData(current_command_id_++, |
(...skipping 537 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
770 } | 771 } |
771 } | 772 } |
772 return profile_it; | 773 return profile_it; |
773 } | 774 } |
774 | 775 |
775 bool BackgroundModeManager::IsBackgroundModePrefEnabled() const { | 776 bool BackgroundModeManager::IsBackgroundModePrefEnabled() const { |
776 PrefService* service = g_browser_process->local_state(); | 777 PrefService* service = g_browser_process->local_state(); |
777 DCHECK(service); | 778 DCHECK(service); |
778 return service->GetBoolean(prefs::kBackgroundModeEnabled); | 779 return service->GetBoolean(prefs::kBackgroundModeEnabled); |
779 } | 780 } |
OLD | NEW |