2020-07-06 20:14:57 +02:00
|
|
|
diff --git chrome/browser/app_controller_mac.mm chrome/browser/app_controller_mac.mm
|
2020-08-29 00:39:23 +02:00
|
|
|
index 8493d1b2233b..69efa5114c6f 100644
|
2020-07-06 20:14:57 +02:00
|
|
|
--- chrome/browser/app_controller_mac.mm
|
|
|
|
+++ chrome/browser/app_controller_mac.mm
|
2020-08-29 00:39:23 +02:00
|
|
|
@@ -1141,6 +1141,7 @@ static base::mac::ScopedObjCClassSwizzler* g_swizzle_imk_input_session;
|
2020-07-06 20:14:57 +02:00
|
|
|
|
|
|
|
// Run a (background) application in a new tab.
|
|
|
|
- (void)executeApplication:(id)sender {
|
|
|
|
+#if BUILDFLAG(ENABLE_BACKGROUND_MODE)
|
|
|
|
NSInteger tag = [sender tag];
|
|
|
|
Profile* profile = [self lastProfile];
|
|
|
|
DCHECK(profile);
|
2020-08-29 00:39:23 +02:00
|
|
|
@@ -1149,6 +1150,7 @@ static base::mac::ScopedObjCClassSwizzler* g_swizzle_imk_input_session;
|
2020-07-06 20:14:57 +02:00
|
|
|
tag < static_cast<int>(applications.size()));
|
|
|
|
const extensions::Extension* extension = applications.GetExtension(tag);
|
|
|
|
BackgroundModeManager::LaunchBackgroundApplication(profile, extension);
|
|
|
|
+#endif // BUILDFLAG(ENABLE_BACKGROUND_MODE)
|
|
|
|
}
|
|
|
|
|
|
|
|
// Same as |-commandDispatch:|, but executes commands using a disposition
|
2020-08-29 00:39:23 +02:00
|
|
|
@@ -1530,6 +1532,7 @@ static base::mac::ScopedObjCClassSwizzler* g_swizzle_imk_input_session;
|
2020-07-06 20:14:57 +02:00
|
|
|
// TODO(rickcam): Mock out BackgroundApplicationListModel, then add unit
|
|
|
|
// tests which use the mock in place of the profile-initialized model.
|
|
|
|
|
|
|
|
+#if BUILDFLAG(ENABLE_BACKGROUND_MODE)
|
|
|
|
// Avoid breaking unit tests which have no profile.
|
|
|
|
if (profile) {
|
|
|
|
BackgroundApplicationListModel applications(profile);
|
2020-08-29 00:39:23 +02:00
|
|
|
@@ -1556,6 +1559,7 @@ static base::mac::ScopedObjCClassSwizzler* g_swizzle_imk_input_session;
|
2020-07-06 20:14:57 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
+#endif // BUILDFLAG(ENABLE_BACKGROUND_MODE)
|
|
|
|
|
|
|
|
return dockMenu;
|
|
|
|
}
|
2020-06-27 22:43:23 +02:00
|
|
|
diff --git chrome/browser/browser_process.h chrome/browser/browser_process.h
|
2020-07-08 19:23:29 +02:00
|
|
|
index 132f2a8d15fd..1262f31d39db 100644
|
2020-06-27 22:43:23 +02:00
|
|
|
--- chrome/browser/browser_process.h
|
|
|
|
+++ chrome/browser/browser_process.h
|
2020-07-08 19:23:29 +02:00
|
|
|
@@ -201,10 +201,12 @@ class BrowserProcess {
|
2020-06-27 22:43:23 +02:00
|
|
|
virtual DownloadStatusUpdater* download_status_updater() = 0;
|
|
|
|
virtual DownloadRequestLimiter* download_request_limiter() = 0;
|
|
|
|
|
|
|
|
+#if BUILDFLAG(ENABLE_BACKGROUND_MODE)
|
|
|
|
// Returns the object that manages background applications.
|
|
|
|
virtual BackgroundModeManager* background_mode_manager() = 0;
|
|
|
|
virtual void set_background_mode_manager_for_test(
|
|
|
|
std::unique_ptr<BackgroundModeManager> manager) = 0;
|
|
|
|
+#endif
|
|
|
|
|
|
|
|
// Returns the StatusTray, which provides an API for displaying status icons
|
|
|
|
// in the system status tray. Returns NULL if status icons are not supported
|
|
|
|
diff --git chrome/browser/browser_process_impl.cc chrome/browser/browser_process_impl.cc
|
2020-08-29 00:39:23 +02:00
|
|
|
index 254173b22652..93f0eb216cc7 100644
|
2020-06-27 22:43:23 +02:00
|
|
|
--- chrome/browser/browser_process_impl.cc
|
|
|
|
+++ chrome/browser/browser_process_impl.cc
|
2020-08-29 00:39:23 +02:00
|
|
|
@@ -955,24 +955,19 @@ DownloadRequestLimiter* BrowserProcessImpl::download_request_limiter() {
|
2020-06-27 22:43:23 +02:00
|
|
|
return download_request_limiter_.get();
|
|
|
|
}
|
|
|
|
|
|
|
|
+#if BUILDFLAG(ENABLE_BACKGROUND_MODE)
|
|
|
|
BackgroundModeManager* BrowserProcessImpl::background_mode_manager() {
|
|
|
|
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
|
|
|
|
-#if BUILDFLAG(ENABLE_BACKGROUND_MODE)
|
|
|
|
if (!background_mode_manager_)
|
|
|
|
CreateBackgroundModeManager();
|
|
|
|
return background_mode_manager_.get();
|
|
|
|
-#else
|
|
|
|
- NOTIMPLEMENTED();
|
|
|
|
- return NULL;
|
|
|
|
-#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
void BrowserProcessImpl::set_background_mode_manager_for_test(
|
|
|
|
std::unique_ptr<BackgroundModeManager> manager) {
|
|
|
|
-#if BUILDFLAG(ENABLE_BACKGROUND_MODE)
|
|
|
|
background_mode_manager_ = std::move(manager);
|
|
|
|
-#endif
|
|
|
|
}
|
|
|
|
+#endif
|
|
|
|
|
|
|
|
StatusTray* BrowserProcessImpl::status_tray() {
|
|
|
|
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
|
|
|
|
diff --git chrome/browser/browser_process_impl.h chrome/browser/browser_process_impl.h
|
2020-08-29 00:39:23 +02:00
|
|
|
index 124ebbf06ea2..c47e6b6cf24c 100644
|
2020-06-27 22:43:23 +02:00
|
|
|
--- chrome/browser/browser_process_impl.h
|
|
|
|
+++ chrome/browser/browser_process_impl.h
|
2020-08-29 00:39:23 +02:00
|
|
|
@@ -163,9 +163,11 @@ class BrowserProcessImpl : public BrowserProcess,
|
2020-06-27 22:43:23 +02:00
|
|
|
void SetApplicationLocale(const std::string& actual_locale) override;
|
|
|
|
DownloadStatusUpdater* download_status_updater() override;
|
|
|
|
DownloadRequestLimiter* download_request_limiter() override;
|
|
|
|
+#if BUILDFLAG(ENABLE_BACKGROUND_MODE)
|
|
|
|
BackgroundModeManager* background_mode_manager() override;
|
|
|
|
void set_background_mode_manager_for_test(
|
|
|
|
std::unique_ptr<BackgroundModeManager> manager) override;
|
|
|
|
+#endif
|
|
|
|
StatusTray* status_tray() override;
|
|
|
|
safe_browsing::SafeBrowsingService* safe_browsing_service() override;
|
|
|
|
subresource_filter::RulesetService* subresource_filter_ruleset_service()
|
|
|
|
diff --git chrome/browser/lifetime/browser_close_manager.cc chrome/browser/lifetime/browser_close_manager.cc
|
2020-08-29 00:39:23 +02:00
|
|
|
index d20c93b35f39..badf57a88d90 100644
|
2020-06-27 22:43:23 +02:00
|
|
|
--- chrome/browser/lifetime/browser_close_manager.cc
|
|
|
|
+++ chrome/browser/lifetime/browser_close_manager.cc
|
2020-07-08 19:23:29 +02:00
|
|
|
@@ -148,12 +148,14 @@ void BrowserCloseManager::CloseBrowsers() {
|
2020-06-27 22:43:23 +02:00
|
|
|
// exit can restore all browsers open before exiting.
|
|
|
|
ProfileManager::ShutdownSessionServices();
|
|
|
|
#endif
|
|
|
|
+#if BUILDFLAG(ENABLE_BACKGROUND_MODE)
|
|
|
|
if (!browser_shutdown::IsTryingToQuit()) {
|
|
|
|
BackgroundModeManager* background_mode_manager =
|
|
|
|
g_browser_process->background_mode_manager();
|
|
|
|
if (background_mode_manager)
|
|
|
|
background_mode_manager->SuspendBackgroundMode();
|
|
|
|
}
|
|
|
|
+#endif
|
|
|
|
|
|
|
|
// Make a copy of the BrowserList to simplify the case where we need to
|
|
|
|
// destroy a Browser during the loop.
|
|
|
|
diff --git chrome/browser/sessions/session_service.cc chrome/browser/sessions/session_service.cc
|
2020-08-29 00:39:23 +02:00
|
|
|
index 73d97b1da62a..eec9c645366f 100644
|
2020-06-27 22:43:23 +02:00
|
|
|
--- chrome/browser/sessions/session_service.cc
|
|
|
|
+++ chrome/browser/sessions/session_service.cc
|
2020-08-29 00:39:23 +02:00
|
|
|
@@ -939,12 +939,19 @@ void SessionService::MaybeDeleteSessionOnlyData() {
|
2020-06-27 22:43:23 +02:00
|
|
|
if (!profile() || profile()->AsTestingProfile())
|
|
|
|
return;
|
|
|
|
|
|
|
|
+#if BUILDFLAG(ENABLE_BACKGROUND_MODE)
|
|
|
|
+ const bool background_mode_active =
|
|
|
|
+ g_browser_process->background_mode_manager()->IsBackgroundModeActive();
|
|
|
|
+#else
|
|
|
|
+ const bool background_mode_active = false;
|
|
|
|
+#endif
|
|
|
|
+
|
|
|
|
// Clear session data if the last window for a profile has been closed and
|
|
|
|
// closing the last window would normally close Chrome, unless background mode
|
|
|
|
// is active. Tests don't have a background_mode_manager.
|
|
|
|
if (has_open_trackable_browsers_ ||
|
|
|
|
browser_defaults::kBrowserAliveWithNoWindows ||
|
|
|
|
- g_browser_process->background_mode_manager()->IsBackgroundModeActive()) {
|
|
|
|
+ background_mode_active) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|