OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #include "chrome/browser/android/tab_base_android_impl.h" | 5 #include "chrome/browser/android/tab_base_android_impl.h" |
6 | 6 |
7 #include "base/android/jni_string.h" | 7 #include "base/android/jni_string.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "chrome/browser/android/chrome_web_contents_delegate_android.h" | 9 #include "chrome/browser/android/chrome_web_contents_delegate_android.h" |
10 #include "chrome/browser/net/url_fixer_upper.h" | 10 #include "chrome/browser/net/url_fixer_upper.h" |
| 11 #include "chrome/browser/ui/android/window_android_helper.h" |
11 #include "content/public/browser/android/content_view_core.h" | 12 #include "content/public/browser/android/content_view_core.h" |
12 #include "content/public/browser/web_contents.h" | 13 #include "content/public/browser/web_contents.h" |
13 #include "googleurl/src/gurl.h" | 14 #include "googleurl/src/gurl.h" |
14 #include "jni/TabBase_jni.h" | 15 #include "jni/TabBase_jni.h" |
15 #include "third_party/WebKit/Source/Platform/chromium/public/WebLayer.h" | 16 #include "third_party/WebKit/Source/Platform/chromium/public/WebLayer.h" |
| 17 #include "ui/gfx/android/window_android.h" |
16 | 18 |
17 using base::android::ConvertJavaStringToUTF8; | 19 using base::android::ConvertJavaStringToUTF8; |
18 using base::android::ConvertUTF8ToJavaString; | 20 using base::android::ConvertUTF8ToJavaString; |
19 using base::android::ScopedJavaLocalRef; | 21 using base::android::ScopedJavaLocalRef; |
20 using chrome::android::ChromeWebContentsDelegateAndroid; | 22 using chrome::android::ChromeWebContentsDelegateAndroid; |
21 using content::WebContents; | 23 using content::WebContents; |
| 24 using ui::WindowAndroid; |
22 | 25 |
23 namespace { | 26 namespace { |
24 class ChromeWebContentsDelegateRenderAndroid | 27 class ChromeWebContentsDelegateRenderAndroid |
25 : public ChromeWebContentsDelegateAndroid { | 28 : public ChromeWebContentsDelegateAndroid { |
26 public: | 29 public: |
27 ChromeWebContentsDelegateRenderAndroid(TabBaseAndroidImpl* tab_android_impl, | 30 ChromeWebContentsDelegateRenderAndroid(TabBaseAndroidImpl* tab_android_impl, |
28 JNIEnv* env, | 31 JNIEnv* env, |
29 jobject obj) | 32 jobject obj) |
30 : ChromeWebContentsDelegateAndroid(env, obj), | 33 : ChromeWebContentsDelegateAndroid(env, obj), |
31 tab_android_impl_(tab_android_impl) { | 34 tab_android_impl_(tab_android_impl) { |
(...skipping 14 matching lines...) Expand all Loading... |
46 | 49 |
47 private: | 50 private: |
48 TabBaseAndroidImpl* tab_android_impl_; | 51 TabBaseAndroidImpl* tab_android_impl_; |
49 | 52 |
50 DISALLOW_COPY_AND_ASSIGN(ChromeWebContentsDelegateRenderAndroid); | 53 DISALLOW_COPY_AND_ASSIGN(ChromeWebContentsDelegateRenderAndroid); |
51 }; | 54 }; |
52 } // namespace | 55 } // namespace |
53 | 56 |
54 TabBaseAndroidImpl::TabBaseAndroidImpl(JNIEnv* env, | 57 TabBaseAndroidImpl::TabBaseAndroidImpl(JNIEnv* env, |
55 jobject obj, | 58 jobject obj, |
56 WebContents* web_contents) | 59 WebContents* web_contents, |
| 60 WindowAndroid* window_android) |
57 : web_contents_(web_contents), | 61 : web_contents_(web_contents), |
58 tab_layer_(WebKit::WebLayer::create()) { | 62 tab_layer_(WebKit::WebLayer::create()) { |
| 63 InitTabHelpers(web_contents); |
| 64 WindowAndroidHelper::FromWebContents(web_contents)-> |
| 65 SetWindowAndroid(window_android); |
59 } | 66 } |
60 | 67 |
61 TabBaseAndroidImpl::~TabBaseAndroidImpl() { | 68 TabBaseAndroidImpl::~TabBaseAndroidImpl() { |
62 } | 69 } |
63 | 70 |
64 void TabBaseAndroidImpl::Destroy(JNIEnv* env, jobject obj) { | 71 void TabBaseAndroidImpl::Destroy(JNIEnv* env, jobject obj) { |
65 delete this; | 72 delete this; |
66 } | 73 } |
67 | 74 |
68 browser_sync::SyncedTabDelegate* TabBaseAndroidImpl::GetSyncedTabDelegate() { | 75 browser_sync::SyncedTabDelegate* TabBaseAndroidImpl::GetSyncedTabDelegate() { |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
116 | 123 |
117 std::string fixed_spec; | 124 std::string fixed_spec; |
118 if (fixed_url.is_valid()) | 125 if (fixed_url.is_valid()) |
119 fixed_spec = fixed_url.spec(); | 126 fixed_spec = fixed_url.spec(); |
120 | 127 |
121 return ConvertUTF8ToJavaString(env, fixed_spec); | 128 return ConvertUTF8ToJavaString(env, fixed_spec); |
122 } | 129 } |
123 | 130 |
124 static jint Init(JNIEnv* env, | 131 static jint Init(JNIEnv* env, |
125 jobject obj, | 132 jobject obj, |
126 jint web_contents_ptr) { | 133 jint web_contents_ptr, |
| 134 jint window_android_ptr) { |
127 TabBaseAndroidImpl* tab = new TabBaseAndroidImpl( | 135 TabBaseAndroidImpl* tab = new TabBaseAndroidImpl( |
128 env, | 136 env, |
129 obj, | 137 obj, |
130 reinterpret_cast<WebContents*>(web_contents_ptr)); | 138 reinterpret_cast<WebContents*>(web_contents_ptr), |
| 139 reinterpret_cast<WindowAndroid*>(window_android_ptr)); |
131 return reinterpret_cast<jint>(tab); | 140 return reinterpret_cast<jint>(tab); |
132 } | 141 } |
OLD | NEW |