Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(111)

Side by Side Diff: chrome/browser/android/service_tab_launcher.h

Issue 1057533005: Make service tab launcher a component (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
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.
4
5 #ifndef CHROME_BROWSER_ANDROID_SERVICE_TAB_LAUNCHER_H_
6 #define CHROME_BROWSER_ANDROID_SERVICE_TAB_LAUNCHER_H_
7
8 #include "base/android/jni_android.h"
9 #include "base/callback_forward.h"
10 #include "base/id_map.h"
11 #include "base/memory/singleton.h"
12
13 namespace content {
14 class BrowserContext;
15 struct OpenURLParams;
16 class WebContents;
17 }
18
19 namespace chrome {
20 namespace android {
21
22 // Launcher for creating new tabs on Android from a background service, where
23 // there may not necessarily be an Activity or a tab model at all. When the
24 // tab has been launched, the user of this class will be informed with the
25 // content::WebContents instance associated with the tab.
26 class ServiceTabLauncher {
27 using TabLaunchedCallback = base::Callback<void(content::WebContents*)>;
28
29 public:
30 // Returns the singleton instance of the service tab launcher.
31 static ServiceTabLauncher* GetInstance();
32
33 // Launches a new tab when we're in a Service rather than in an Activity.
34 // |callback| will be invoked with the resulting content::WebContents* when
35 // the tab is avialable. This method must only be called from the UI thread.
36 void LaunchTab(content::BrowserContext* browser_context,
37 const content::OpenURLParams& params,
38 const TabLaunchedCallback& callback);
39
40 // To be called when the tab for |request_id| has launched, with the
41 // associated |web_contents|. The WebContents must not yet have started
42 // the provisional load for the main frame of the navigation.
43 void OnTabLaunched(int request_id, content::WebContents* web_contents);
44
45 static bool RegisterServiceTabLauncher(JNIEnv* env);
46
47 private:
48 friend struct DefaultSingletonTraits<ServiceTabLauncher>;
49
50 ServiceTabLauncher();
51 ~ServiceTabLauncher();
52
53 IDMap<TabLaunchedCallback> tab_launched_callbacks_;
54
55 base::android::ScopedJavaGlobalRef<jobject> java_object_;
56
57 DISALLOW_COPY_AND_ASSIGN(ServiceTabLauncher);
58 };
59
60 } // namespace android
61 } // namespace chrome
62
63 #endif // CHROME_BROWSER_ANDROID_SERVICE_TAB_LAUNCHER_H_
OLDNEW
« no previous file with comments | « chrome/browser/android/chrome_jni_registrar.cc ('k') | chrome/browser/android/service_tab_launcher.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698