Chromium Code Reviews| Index: chrome/browser/android/service_tab_creator.h |
| diff --git a/chrome/browser/android/service_tab_creator.h b/chrome/browser/android/service_tab_creator.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..b7da9d090417f356ecbce40467a8cc83d47cd902 |
| --- /dev/null |
| +++ b/chrome/browser/android/service_tab_creator.h |
| @@ -0,0 +1,46 @@ |
| +// Copyright 2015 The Chromium Authors. All rights reserved. |
|
Miguel Garcia
2015/02/03 16:58:40
There is already an intentHelper c++/java that doe
Peter Beverloo
2015/02/03 17:24:54
Nah, because this class will need to keep request
|
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef CHROME_BROWSER_ANDROID_SERVICE_TAB_CREATOR_H_ |
| +#define CHROME_BROWSER_ANDROID_SERVICE_TAB_CREATOR_H_ |
| + |
| +#include "base/android/jni_android.h" |
| +#include "base/callback_forward.h" |
| +#include "base/memory/singleton.h" |
| + |
| +namespace content { |
| +class BrowserContext; |
| +struct OpenURLParams; |
| +class WebContents; |
| +} |
| + |
|
Miguel Garcia
2015/02/03 16:58:40
namespace it?
Peter Beverloo
2015/02/03 17:24:54
Done. "namespace chrome {}" eeuw :-(
|
| +// Class for creating new tabs on Android from a background service, where there |
| +// may not necessarily be an Activity or a tab model at all. The creator is |
| +// able to report back to the user when the tab has been created. |
|
Miguel Garcia
2015/02/03 16:58:40
same thing, we are not quite able to report back y
Peter Beverloo
2015/02/03 17:24:54
Done.
|
| +class ServiceTabCreator { |
| + public: |
| + // Returns the singleton instance of the service tab creator. |
| + static ServiceTabCreator* GetInstance(); |
| + |
| + // Creates a new tab when we're in an Android Service rather than an Activity. |
| + // |callback| will be invoked with the resulting content::WebContents* when |
| + // the tab is avialable. This method must only be called from the UI thread. |
| + void CreateTab(content::BrowserContext* browser_context, |
| + const content::OpenURLParams& params, |
| + base::Callback<void(content::WebContents*)> callback); |
| + |
| + static bool RegisterServiceTabCreator(JNIEnv* env); |
| + |
| + private: |
| + friend struct DefaultSingletonTraits<ServiceTabCreator>; |
| + |
| + ServiceTabCreator(); |
| + ~ServiceTabCreator(); |
| + |
| + base::android::ScopedJavaGlobalRef<jobject> java_object_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(ServiceTabCreator); |
| +}; |
| + |
| +#endif // CHROME_BROWSER_ANDROID_SERVICE_TAB_CREATOR_H_ |