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

Side by Side Diff: chrome/browser/ui/android/tab_model/tab_model_jni_bridge.h

Issue 583373002: Break apart the TabModelBase's JNI calls into its own class (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Blarg. Created 6 years, 2 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 2014 The Chromium Authors. All rights reserved. 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 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 CHROME_BROWSER_UI_ANDROID_TAB_MODEL_TAB_MODEL_BASE_H_ 5 #ifndef CHROME_BROWSER_UI_ANDROID_TAB_MODEL_TAB_MODEL_JNI_BRIDGE_H_
6 #define CHROME_BROWSER_UI_ANDROID_TAB_MODEL_TAB_MODEL_BASE_H_ 6 #define CHROME_BROWSER_UI_ANDROID_TAB_MODEL_TAB_MODEL_JNI_BRIDGE_H_
7 7
8 #include <jni.h> 8 #include <jni.h>
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/android/jni_weak_ref.h" 11 #include "base/android/jni_weak_ref.h"
12 #include "base/android/scoped_java_ref.h" 12 #include "base/android/scoped_java_ref.h"
13 #include "base/compiler_specific.h" 13 #include "base/compiler_specific.h"
14 #include "base/logging.h" 14 #include "base/logging.h"
15 #include "chrome/browser/ui/android/tab_model/tab_model.h" 15 #include "chrome/browser/ui/android/tab_model/tab_model.h"
16 16
17 class Profile; 17 class Profile;
18 class TabAndroid; 18 class TabAndroid;
19 19
20 namespace content { 20 namespace content {
21 class WebContents; 21 class WebContents;
22 } 22 }
23 23
24 // Native representation of TabModelBase which provides access to information 24 // Bridges calls between the C++ and the Java TabModels. Functions in this
25 // about a tabstrip to native code and could potentially be used in place of 25 // class should do little more than make calls out to the Java TabModel, which
26 // Browser for some functionality in Clank. 26 // is what actually stores Tabs.
27 class TabModelBase : public TabModel { 27 class TabModelJniBridge : public TabModel {
28 public: 28 public:
29 TabModelBase(JNIEnv* env, jobject obj, Profile* profile); 29 TabModelJniBridge(JNIEnv* env, jobject obj, bool is_incognito);
30 void Destroy(JNIEnv* env, jobject obj); 30 void Destroy(JNIEnv* env, jobject obj);
31 virtual ~TabModelJniBridge();
32
33 // Registers the JNI bindings.
34 static bool Register(JNIEnv* env);
31 35
32 // Called by JNI 36 // Called by JNI
33 base::android::ScopedJavaLocalRef<jobject> GetProfileAndroid(JNIEnv* env, 37 base::android::ScopedJavaLocalRef<jobject> GetProfileAndroid(JNIEnv* env,
34 jobject obj); 38 jobject obj);
35 void TabAddedToModel(JNIEnv* env, jobject obj, jobject jtab); 39 void TabAddedToModel(JNIEnv* env, jobject obj, jobject jtab);
36 40
37 // TabModel: 41 // TabModel::
38 virtual int GetTabCount() const override; 42 virtual int GetTabCount() const override;
39 virtual int GetActiveIndex() const override; 43 virtual int GetActiveIndex() const override;
40 virtual content::WebContents* GetWebContentsAt(int index) const override; 44 virtual content::WebContents* GetWebContentsAt(int index) const override;
41 virtual TabAndroid* GetTabAt(int index) const override; 45 virtual TabAndroid* GetTabAt(int index) const override;
42 46
43 virtual void SetActiveIndex(int index) override; 47 virtual void SetActiveIndex(int index) override;
44 virtual void CloseTabAt(int index) override; 48 virtual void CloseTabAt(int index) override;
45 49
46 virtual void CreateTab(content::WebContents* web_contents, 50 virtual void CreateTab(content::WebContents* web_contents,
47 int parent_tab_id) override; 51 int parent_tab_id) override;
52
48 virtual content::WebContents* CreateNewTabForDevTools( 53 virtual content::WebContents* CreateNewTabForDevTools(
49 const GURL& url) override; 54 const GURL& url) override;
50 55
51 // Return true if we are currently restoring sessions asynchronously. 56 // Return true if we are currently restoring sessions asynchronously.
52 virtual bool IsSessionRestoreInProgress() const override; 57 virtual bool IsSessionRestoreInProgress() const override;
53 58
54 // Instructs the TabModel to broadcast a notification that all tabs are now 59 // Instructs the TabModel to broadcast a notification that all tabs are now
55 // loaded from storage. 60 // loaded from storage.
56 void BroadcastSessionRestoreComplete(JNIEnv* env, jobject obj); 61 void BroadcastSessionRestoreComplete(JNIEnv* env, jobject obj);
57 62
63 protected:
64 JavaObjectWeakGlobalRef java_object_;
65
58 private: 66 private:
59 virtual ~TabModelBase(); 67 DISALLOW_COPY_AND_ASSIGN(TabModelJniBridge);
60
61 JavaObjectWeakGlobalRef java_object_;
62 }; 68 };
63 69
64 // Register the Tab's native methods through jni. 70 #endif // CHROME_BROWSER_UI_ANDROID_TAB_MODEL_TAB_MODEL_JNI_BRIDGE_H_
65 bool RegisterTabModelBase(JNIEnv* env);
66
67 #endif // CHROME_BROWSER_UI_ANDROID_TAB_MODEL_TAB_MODEL_BASE_H_
OLDNEW
« no previous file with comments | « chrome/browser/ui/android/tab_model/tab_model_base.cc ('k') | chrome/browser/ui/android/tab_model/tab_model_jni_bridge.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698