blob: bc0dd5360ebf107611b55292da4c6d2205e5a155 [file] [log] [blame]
[email protected]c149b9192012-04-20 09:35:381// Copyright (c) 2012 The Chromium Authors. All rights reserved.
[email protected]70dd60b2010-12-09 00:36:172// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
[email protected]70dd60b2010-12-09 00:36:175#include "base/base_paths.h"
[email protected]bd2262e2011-11-23 22:21:236#include "base/bind.h"
[email protected]70dd60b2010-12-09 00:36:177#include "base/command_line.h"
[email protected]57999812013-02-24 05:40:528#include "base/files/file_path.h"
[email protected]70dd60b2010-12-09 00:36:179#include "base/logging.h"
Gabriel Charette14520232018-04-30 23:27:2210#include "base/sequenced_task_runner.h"
[email protected]135cb802013-06-09 16:44:2011#include "base/strings/utf_string_conversions.h"
staniscaf605652017-06-07 19:27:1212#include "base/task_scheduler/post_task.h"
[email protected]70dd60b2010-12-09 00:36:1713#include "base/win/registry.h"
[email protected]a07676b22011-06-17 16:36:5314#include "chrome/browser/background/background_mode_manager.h"
[email protected]9938b1702012-06-05 16:23:0215#include "chrome/common/chrome_switches.h"
[email protected]af39f002014-08-22 10:18:1816#include "chrome/grit/chromium_strings.h"
17#include "chrome/grit/generated_resources.h"
[email protected]6280b5882012-06-05 21:56:4118#include "chrome/installer/util/auto_launch_util.h"
[email protected]c38831a12011-10-28 12:44:4919#include "content/public/browser/browser_thread.h"
[email protected]c051a1b2011-01-21 23:30:1720#include "ui/base/l10n/l10n_util.h"
[email protected]6280b5882012-06-05 21:56:4121#include "ui/gfx/image/image_skia.h"
Evan Stade889ce4712018-01-28 15:26:2622#include "ui/message_center/public/cpp/notifier_id.h"
[email protected]70dd60b2010-12-09 00:36:1723
[email protected]631bb742011-11-02 11:29:3924using content::BrowserThread;
25
johnme92956172015-10-15 16:54:1226const char kAppInstalledNotifierId[] = "background-mode.app-installed";
27
[email protected]70dd60b2010-12-09 00:36:1728void BackgroundModeManager::EnableLaunchOnStartup(bool should_launch) {
29 // This functionality is only defined for default profile, currently.
avi3ef9ec9e2014-12-22 22:50:1730 if (base::CommandLine::ForCurrentProcess()->HasSwitch(switches::kUserDataDir))
[email protected]70dd60b2010-12-09 00:36:1731 return;
staniscaf605652017-06-07 19:27:1232 task_runner_->PostTask(
33 FROM_HERE,
34 should_launch
35 ? base::Bind(auto_launch_util::EnableBackgroundStartAtLogin)
36 : base::Bind(auto_launch_util::DisableBackgroundStartAtLogin));
[email protected]70dd60b2010-12-09 00:36:1737}
38
mvanouwerkerk5abba422015-09-01 15:35:1439void BackgroundModeManager::DisplayClientInstalledNotification(
40 const base::string16& name) {
41 // Create a status tray notification balloon explaining to the user what has
42 // been installed.
[email protected]a034ef462011-06-10 20:08:2343 CreateStatusTrayIcon();
44 status_icon_->DisplayBalloon(
[email protected]6280b5882012-06-05 21:56:4145 gfx::ImageSkia(),
[email protected]6f9eac92011-03-06 17:49:0246 l10n_util::GetStringUTF16(IDS_BACKGROUND_APP_INSTALLED_BALLOON_TITLE),
mvanouwerkerk5abba422015-09-01 15:35:1447 l10n_util::GetStringFUTF16(IDS_BACKGROUND_APP_INSTALLED_BALLOON_BODY,
48 name,
johnme92956172015-10-15 16:54:1249 l10n_util::GetStringUTF16(IDS_PRODUCT_NAME)),
50 message_center::NotifierId(message_center::NotifierId::SYSTEM_COMPONENT,
51 kAppInstalledNotifierId));
[email protected]6f9eac92011-03-06 17:49:0252}
53
[email protected]96920152013-12-04 21:00:1654base::string16 BackgroundModeManager::GetPreferencesMenuLabel() {
[email protected]70dd60b2010-12-09 00:36:1755 return l10n_util::GetStringUTF16(IDS_OPTIONS);
56}
staniscaf605652017-06-07 19:27:1257
58scoped_refptr<base::SequencedTaskRunner>
59BackgroundModeManager::CreateTaskRunner() {
60 return base::CreateSequencedTaskRunnerWithTraits(
61 {base::MayBlock(), base::TaskPriority::BACKGROUND,
62 base::TaskShutdownBehavior::BLOCK_SHUTDOWN});
63}