Extract code handling PrinterProviderAPI from PrintPreviewHandler
[chromium-blink-merge.git] / chrome / browser / android / service_tab_launcher.h
blob3e9fb233170f7fb2a258a66ec6ea7bb2d9f9c06c
1 // 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.
5 #ifndef CHROME_BROWSER_ANDROID_SERVICE_TAB_LAUNCHER_H_
6 #define CHROME_BROWSER_ANDROID_SERVICE_TAB_LAUNCHER_H_
8 #include "base/android/jni_android.h"
9 #include "base/callback_forward.h"
10 #include "base/memory/singleton.h"
12 namespace content {
13 class BrowserContext;
14 struct OpenURLParams;
15 class WebContents;
18 namespace chrome {
19 namespace android {
21 // Launcher for creating new tabs on Android from a background service, where
22 // there may not necessarily be an Activity or a tab model at all.
23 class ServiceTabLauncher {
24 public:
25 // Returns the singleton instance of the service tab launcher.
26 static ServiceTabLauncher* GetInstance();
28 // Launches a new tab when we're in a Service rather than in an Activity.
29 // |callback| will be invoked with the resulting content::WebContents* when
30 // the tab is avialable. This method must only be called from the UI thread.
31 void LaunchTab(content::BrowserContext* browser_context,
32 const content::OpenURLParams& params,
33 const base::Callback<void(content::WebContents*)>& callback);
35 static bool RegisterServiceTabLauncher(JNIEnv* env);
37 private:
38 friend struct DefaultSingletonTraits<ServiceTabLauncher>;
40 ServiceTabLauncher();
41 ~ServiceTabLauncher();
43 base::android::ScopedJavaGlobalRef<jobject> java_object_;
45 DISALLOW_COPY_AND_ASSIGN(ServiceTabLauncher);
48 } // namespace android
49 } // namespace chrome
51 #endif // CHROME_BROWSER_ANDROID_SERVICE_TAB_LAUNCHER_H_