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 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
50 #include "chrome/browser/ui/user_manager.h" | 50 #include "chrome/browser/ui/user_manager.h" |
51 #include "chrome/common/chrome_constants.h" | 51 #include "chrome/common/chrome_constants.h" |
52 #include "chrome/common/chrome_switches.h" | 52 #include "chrome/common/chrome_switches.h" |
53 #include "chrome/common/extensions/extension_constants.h" | 53 #include "chrome/common/extensions/extension_constants.h" |
54 #include "chrome/common/pref_names.h" | 54 #include "chrome/common/pref_names.h" |
55 #include "chrome/grit/chrome_unscaled_resources.h" | 55 #include "chrome/grit/chrome_unscaled_resources.h" |
56 #include "chrome/grit/chromium_strings.h" | 56 #include "chrome/grit/chromium_strings.h" |
57 #include "chrome/grit/generated_resources.h" | 57 #include "chrome/grit/generated_resources.h" |
58 #include "components/prefs/pref_registry_simple.h" | 58 #include "components/prefs/pref_registry_simple.h" |
59 #include "components/prefs/pref_service.h" | 59 #include "components/prefs/pref_service.h" |
60 #include "components/startup_metric_utils/browser/startup_metric_utils.h" | |
60 #include "content/public/browser/notification_service.h" | 61 #include "content/public/browser/notification_service.h" |
61 #include "extensions/browser/extension_system.h" | 62 #include "extensions/browser/extension_system.h" |
62 #include "extensions/common/constants.h" | 63 #include "extensions/common/constants.h" |
63 #include "extensions/common/extension.h" | 64 #include "extensions/common/extension.h" |
64 #include "extensions/common/manifest_handlers/options_page_info.h" | 65 #include "extensions/common/manifest_handlers/options_page_info.h" |
65 #include "extensions/common/one_shot_event.h" | 66 #include "extensions/common/one_shot_event.h" |
66 #include "extensions/common/permissions/permission_set.h" | 67 #include "extensions/common/permissions/permission_set.h" |
67 #include "ui/base/l10n/l10n_util.h" | 68 #include "ui/base/l10n/l10n_util.h" |
68 #include "ui/base/resource/resource_bundle.h" | 69 #include "ui/base/resource/resource_bundle.h" |
69 | 70 |
(...skipping 640 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
710 } | 711 } |
711 } | 712 } |
712 | 713 |
713 void BackgroundModeManager::StartBackgroundMode() { | 714 void BackgroundModeManager::StartBackgroundMode() { |
714 DCHECK(ShouldBeInBackgroundMode()); | 715 DCHECK(ShouldBeInBackgroundMode()); |
715 // Don't bother putting ourselves in background mode if we're already there | 716 // Don't bother putting ourselves in background mode if we're already there |
716 // or if background mode is disabled. | 717 // or if background mode is disabled. |
717 if (in_background_mode_) | 718 if (in_background_mode_) |
718 return; | 719 return; |
719 | 720 |
721 startup_metric_utils::SetBackgroundModeEnabled(); | |
sky
2017/04/11 17:13:36
How come you don't need a matching End?
themblsha
2017/04/12 17:18:28
The intent is to set this once per startup, as it
| |
722 | |
720 // Mark ourselves as running in background mode. | 723 // Mark ourselves as running in background mode. |
721 in_background_mode_ = true; | 724 in_background_mode_ = true; |
722 | 725 |
723 UpdateKeepAliveAndTrayIcon(); | 726 UpdateKeepAliveAndTrayIcon(); |
724 | 727 |
725 content::NotificationService::current()->Notify( | 728 content::NotificationService::current()->Notify( |
726 chrome::NOTIFICATION_BACKGROUND_MODE_CHANGED, | 729 chrome::NOTIFICATION_BACKGROUND_MODE_CHANGED, |
727 content::Source<BackgroundModeManager>(this), | 730 content::Source<BackgroundModeManager>(this), |
728 content::Details<bool>(&in_background_mode_)); | 731 content::Details<bool>(&in_background_mode_)); |
729 } | 732 } |
(...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1047 } | 1050 } |
1048 } | 1051 } |
1049 return profile_it; | 1052 return profile_it; |
1050 } | 1053 } |
1051 | 1054 |
1052 bool BackgroundModeManager::IsBackgroundModePrefEnabled() const { | 1055 bool BackgroundModeManager::IsBackgroundModePrefEnabled() const { |
1053 PrefService* service = g_browser_process->local_state(); | 1056 PrefService* service = g_browser_process->local_state(); |
1054 DCHECK(service); | 1057 DCHECK(service); |
1055 return service->GetBoolean(prefs::kBackgroundModeEnabled); | 1058 return service->GetBoolean(prefs::kBackgroundModeEnabled); |
1056 } | 1059 } |
OLD | NEW |