Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / chrome / browser / ui / android / tab_model / tab_model_jni_bridge.h
blob0de051d86ad685434ac1048c4fc7ab2d34133775
1 // Copyright 2014 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_UI_ANDROID_TAB_MODEL_TAB_MODEL_JNI_BRIDGE_H_
6 #define CHROME_BROWSER_UI_ANDROID_TAB_MODEL_TAB_MODEL_JNI_BRIDGE_H_
8 #include <jni.h>
9 #include <vector>
11 #include "base/android/jni_weak_ref.h"
12 #include "base/android/scoped_java_ref.h"
13 #include "base/compiler_specific.h"
14 #include "base/logging.h"
15 #include "chrome/browser/ui/android/tab_model/tab_model.h"
17 class Profile;
18 class TabAndroid;
20 namespace content {
21 class WebContents;
24 // Bridges calls between the C++ and the Java TabModels. Functions in this
25 // class should do little more than make calls out to the Java TabModel, which
26 // is what actually stores Tabs.
27 class TabModelJniBridge : public TabModel {
28 public:
29 TabModelJniBridge(JNIEnv* env, jobject obj, bool is_incognito);
30 void Destroy(JNIEnv* env, jobject obj);
31 ~TabModelJniBridge() override;
33 // Registers the JNI bindings.
34 static bool Register(JNIEnv* env);
36 // Called by JNI
37 base::android::ScopedJavaLocalRef<jobject> GetProfileAndroid(JNIEnv* env,
38 jobject obj);
39 void TabAddedToModel(JNIEnv* env, jobject obj, jobject jtab);
41 // TabModel::
42 int GetTabCount() const override;
43 int GetActiveIndex() const override;
44 content::WebContents* GetWebContentsAt(int index) const override;
45 TabAndroid* GetTabAt(int index) const override;
47 void SetActiveIndex(int index) override;
48 void CloseTabAt(int index) override;
50 void CreateTab(content::WebContents* web_contents,
51 int parent_tab_id) override;
53 content::WebContents* CreateNewTabForDevTools(const GURL& url) override;
55 // Return true if we are currently restoring sessions asynchronously.
56 bool IsSessionRestoreInProgress() const override;
58 // Instructs the TabModel to broadcast a notification that all tabs are now
59 // loaded from storage.
60 void BroadcastSessionRestoreComplete(JNIEnv* env, jobject obj);
62 protected:
63 JavaObjectWeakGlobalRef java_object_;
65 private:
66 DISALLOW_COPY_AND_ASSIGN(TabModelJniBridge);
69 #endif // CHROME_BROWSER_UI_ANDROID_TAB_MODEL_TAB_MODEL_JNI_BRIDGE_H_