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

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

Issue 2119273002: Merge ChromeServiceTabLauncher and ServiceTabLauncher (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Merge branch 'master' into chrome_service_tab_launcher Created 4 years, 5 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
1 // Copyright 2015 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef COMPONENTS_SERVICE_TAB_LAUNCHER_BROWSER_ANDROID_SERVICE_TAB_LAUNCHER_H_ 5 #ifndef CHROME_BROWSER_ANDROID_CHROME_SERVICE_TAB_LAUNCHER_H_
6 #define COMPONENTS_SERVICE_TAB_LAUNCHER_BROWSER_ANDROID_SERVICE_TAB_LAUNCHER_H_ 6 #define CHROME_BROWSER_ANDROID_CHROME_SERVICE_TAB_LAUNCHER_H_
7 7
8 #include "base/android/jni_android.h" 8 #include "base/android/jni_android.h"
9 #include "base/callback_forward.h" 9 #include "base/callback_forward.h"
10 #include "base/id_map.h" 10 #include "base/id_map.h"
11 #include "base/macros.h" 11 #include "base/macros.h"
12 #include "base/memory/singleton.h" 12 #include "base/memory/singleton.h"
13 13
14 namespace content { 14 namespace content {
15 class BrowserContext; 15 class BrowserContext;
16 struct OpenURLParams; 16 struct OpenURLParams;
17 class WebContents; 17 class WebContents;
18 } 18 }
19 19
20 namespace service_tab_launcher {
21
22 // Launcher for creating new tabs on Android from a background service, where 20 // 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 21 // 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 22 // tab has been launched, the user of this class will be informed with the
25 // content::WebContents instance associated with the tab. 23 // content::WebContents instance associated with the tab.
26 class ServiceTabLauncher { 24 class ChromeServiceTabLauncher {
Peter Beverloo 2016/07/05 11:23:04 What about just calling this ServiceTabLauncher? (
pkotwicz 2016/07/05 17:09:59 I renamed this class to ServiceTabLauncher (and th
27 using TabLaunchedCallback = base::Callback<void(content::WebContents*)>; 25 using TabLaunchedCallback = base::Callback<void(content::WebContents*)>;
28 26
29 public: 27 public:
30 // Returns the singleton instance of the service tab launcher. 28 // Returns the singleton instance of the service tab launcher.
31 static ServiceTabLauncher* GetInstance(); 29 static ChromeServiceTabLauncher* GetInstance();
32 30
33 // Launches a new tab when we're in a Service rather than in an Activity. 31 // 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 32 // |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. 33 // the tab is avialable. This method must only be called from the UI thread.
36 void LaunchTab(content::BrowserContext* browser_context, 34 void LaunchTab(content::BrowserContext* browser_context,
37 const content::OpenURLParams& params, 35 const content::OpenURLParams& params,
38 const TabLaunchedCallback& callback); 36 const TabLaunchedCallback& callback);
39 37
40 // To be called when the tab for |request_id| has launched, with the 38 // To be called when the tab for |request_id| has launched, with the
41 // associated |web_contents|. The WebContents must not yet have started 39 // associated |web_contents|. The WebContents must not yet have started
42 // the provisional load for the main frame of the navigation. 40 // the provisional load for the main frame of the navigation.
43 void OnTabLaunched(int request_id, content::WebContents* web_contents); 41 void OnTabLaunched(int request_id, content::WebContents* web_contents);
44 42
45 static bool RegisterServiceTabLauncher(JNIEnv* env); 43 static bool Register(JNIEnv* env);
46 44
47 private: 45 private:
48 friend struct base::DefaultSingletonTraits<ServiceTabLauncher>; 46 friend struct base::DefaultSingletonTraits<ChromeServiceTabLauncher>;
49 47
50 ServiceTabLauncher(); 48 ChromeServiceTabLauncher();
51 ~ServiceTabLauncher(); 49 ~ChromeServiceTabLauncher();
52 50
53 IDMap<TabLaunchedCallback, IDMapOwnPointer> tab_launched_callbacks_; 51 IDMap<TabLaunchedCallback, IDMapOwnPointer> tab_launched_callbacks_;
54 52
55 base::android::ScopedJavaGlobalRef<jobject> java_object_; 53 base::android::ScopedJavaGlobalRef<jobject> java_object_;
56 54
57 DISALLOW_COPY_AND_ASSIGN(ServiceTabLauncher); 55 DISALLOW_COPY_AND_ASSIGN(ChromeServiceTabLauncher);
58 }; 56 };
59 57
60 } // namespace service_tab_launcher 58 #endif // CHROME_BROWSER_ANDROID_CHROME_SERVICE_TAB_LAUNCHER_H_
61
62 #endif // COMPONENTS_SERVICE_TAB_LAUNCHER_BROWSER_ANDROID_SERVICE_TAB_LAUNCHER_ H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698