blob: be547a8897ab7c15e705ccc7f36094b1dd105ce5 [file] [log] [blame]
jkarlindb185222015-05-29 12:02:001// Copyright 2015 The Chromium Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
iclelland8467f462015-10-21 14:03:135#ifndef CHROME_BROWSER_ANDROID_BACKGROUND_SYNC_LAUNCHER_ANDROID_H_
6#define CHROME_BROWSER_ANDROID_BACKGROUND_SYNC_LAUNCHER_ANDROID_H_
jkarlindb185222015-05-29 12:02:007
avie4d7b6f2015-12-26 00:59:188#include <stdint.h>
9
jkarlindb185222015-05-29 12:02:0010#include <set>
11
12#include "base/android/jni_android.h"
13#include "base/lazy_instance.h"
14#include "base/macros.h"
jkarlindb185222015-05-29 12:02:0015
jkarlindb185222015-05-29 12:02:0016// The BackgroundSyncLauncherAndroid singleton owns the Java
17// BackgroundSyncLauncher object and is used to register interest in starting
18// the browser the next time the device goes online. This class runs on the UI
19// thread.
iclelland8467f462015-10-21 14:03:1320class BackgroundSyncLauncherAndroid {
jkarlindb185222015-05-29 12:02:0021 public:
22 static BackgroundSyncLauncherAndroid* Get();
23
jkarlin4302d712015-11-10 10:59:0124 static void LaunchBrowserIfStopped(bool launch_when_next_online,
25 int64_t min_delay_ms);
jkarlindb185222015-05-29 12:02:0026
iclellandd054a6f2016-01-11 20:16:1427 static bool ShouldDisableBackgroundSync();
28
29 // TODO(iclelland): Remove this once the bots have their play services package
30 // updated before every test run. (https://crbug.com/514449)
31 static void SetPlayServicesVersionCheckDisabledForTests(bool disabled);
32
jkarlindb185222015-05-29 12:02:0033 private:
scottmg5e65e3a2017-03-08 08:48:4634 friend struct base::LazyInstanceTraitsBase<BackgroundSyncLauncherAndroid>;
jkarlindb185222015-05-29 12:02:0035
36 // Constructor and destructor marked private to enforce singleton
37 BackgroundSyncLauncherAndroid();
38 ~BackgroundSyncLauncherAndroid();
39
jkarlin4302d712015-11-10 10:59:0140 void LaunchBrowserIfStoppedImpl(bool launch_when_next_online,
41 int64_t min_delay_ms);
jkarlindb185222015-05-29 12:02:0042
jkarlindb185222015-05-29 12:02:0043 base::android::ScopedJavaGlobalRef<jobject> java_launcher_;
44 DISALLOW_COPY_AND_ASSIGN(BackgroundSyncLauncherAndroid);
45};
46
iclelland8467f462015-10-21 14:03:1347#endif // CHROME_BROWSER_ANDROID_BACKGROUND_SYNC_LAUNCHER_ANDROID_H_