OLD | NEW |
---|---|
(Empty) | |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #include "chrome/browser/android/tab_base_android_impl.h" | |
6 | |
7 #include "base/android/jni_string.h" | |
8 #include "base/logging.h" | |
9 #include "chrome/browser/android/chrome_web_contents_delegate_android.h" | |
10 #include "chrome/browser/net/url_fixer_upper.h" | |
11 #include "content/public/browser/android/content_view_core.h" | |
12 #include "content/public/browser/web_contents.h" | |
13 #include "googleurl/src/gurl.h" | |
14 #include "jni/TabBase_jni.h" | |
15 #include "third_party/WebKit/Source/Platform/chromium/public/WebLayer.h" | |
16 | |
17 using base::android::ConvertJavaStringToUTF8; | |
18 using base::android::ConvertUTF8ToJavaString; | |
19 using base::android::ScopedJavaLocalRef; | |
20 using chrome::android::ChromeWebContentsDelegateAndroid; | |
21 using content::WebContents; | |
22 | |
23 namespace { | |
24 class ChromeWebContentsDelegateRenderAndroid | |
25 : public ChromeWebContentsDelegateAndroid { | |
26 public: | |
27 ChromeWebContentsDelegateRenderAndroid(TabBaseAndroidImpl* tab_android_impl, | |
28 JNIEnv* env, jobject obj) | |
sky
2012/09/25 15:57:39
each param on own line.
David Trainor- moved to gerrit
2012/09/25 19:07:12
Done.
| |
29 : ChromeWebContentsDelegateAndroid(env, obj), | |
30 tab_android_impl_(tab_android_impl) { | |
31 } | |
32 | |
33 virtual ~ChromeWebContentsDelegateRenderAndroid() { | |
34 } | |
35 | |
36 virtual void AttachLayer(WebContents* web_contents, | |
37 WebKit::WebLayer* layer) OVERRIDE { | |
38 tab_android_impl_->tab_layer()->addChild(layer); | |
39 } | |
40 | |
41 virtual void RemoveLayer(WebContents* web_contents, | |
42 WebKit::WebLayer* layer) OVERRIDE { | |
43 layer->removeFromParent(); | |
44 } | |
45 | |
46 private: | |
47 TabBaseAndroidImpl* tab_android_impl_; | |
48 }; | |
sky
2012/09/25 15:57:39
DISALLOW_...
David Trainor- moved to gerrit
2012/09/25 19:07:12
Done.
| |
49 } // namespace | |
50 | |
51 TabBaseAndroidImpl::TabBaseAndroidImpl(JNIEnv* env, | |
52 jobject obj, | |
53 WebContents* web_contents) | |
54 : web_contents_(web_contents), | |
55 tab_layer_(WebKit::WebLayer::create()) { | |
56 } | |
57 | |
58 TabBaseAndroidImpl::~TabBaseAndroidImpl() { | |
59 } | |
60 | |
61 void TabBaseAndroidImpl::Destroy(JNIEnv* env, jobject obj) { | |
62 delete this; | |
63 } | |
64 | |
65 browser_sync::SyncedTabDelegate* TabBaseAndroidImpl::GetSyncedTabDelegate() { | |
66 NOTIMPLEMENTED(); | |
67 return NULL; | |
68 } | |
69 | |
70 void TabBaseAndroidImpl::OnReceivedHttpAuthRequest(jobject auth_handler, | |
71 const string16& host, | |
72 const string16& realm) { | |
73 NOTIMPLEMENTED(); | |
74 } | |
75 | |
76 void TabBaseAndroidImpl::ShowContextMenu( | |
77 const content::ContextMenuParams& params) { | |
78 NOTIMPLEMENTED(); | |
79 } | |
80 | |
81 void TabBaseAndroidImpl::ShowCustomContextMenu( | |
82 const content::ContextMenuParams& params, | |
83 const base::Callback<void(int)>& callback) { | |
84 NOTIMPLEMENTED(); | |
85 } | |
86 | |
87 void TabBaseAndroidImpl::ShowSelectFileDialog( | |
88 const base::android::ScopedJavaLocalRef<jobject>& select_file) { | |
89 NOTIMPLEMENTED(); | |
90 } | |
91 | |
92 void TabBaseAndroidImpl::AddShortcutToBookmark( | |
93 const GURL& url, const string16& title, const SkBitmap& skbitmap, | |
94 int r_value, int g_value, int b_value) { | |
95 NOTIMPLEMENTED(); | |
96 } | |
97 | |
98 void TabBaseAndroidImpl::RunExternalProtocolDialog(const GURL& url) { | |
99 NOTIMPLEMENTED(); | |
100 } | |
101 | |
102 bool TabBaseAndroidImpl::RegisterTabBaseAndroidImpl(JNIEnv* env) { | |
103 return RegisterNativesImpl(env); | |
104 } | |
105 | |
106 void TabBaseAndroidImpl::InitWebContentsDelegate( | |
107 JNIEnv* env, | |
108 jobject obj, | |
109 jobject web_contents_delegate) { | |
110 web_contents_delegate_.reset( | |
111 new ChromeWebContentsDelegateRenderAndroid(this, | |
112 env, | |
113 web_contents_delegate)); | |
114 web_contents_->SetDelegate(web_contents_delegate_.get()); | |
115 } | |
116 | |
117 ScopedJavaLocalRef<jstring> TabBaseAndroidImpl::FixupUrl(JNIEnv* env, | |
118 jobject obj, | |
119 jstring url) { | |
120 GURL fixed_url(URLFixerUpper::FixupURL(ConvertJavaStringToUTF8(env, url), | |
121 std::string())); | |
122 | |
123 std::string fixed_spec; | |
124 if (fixed_url.is_valid()) | |
125 fixed_spec = fixed_url.spec(); | |
126 | |
127 return ConvertUTF8ToJavaString(env, fixed_spec); | |
128 } | |
129 | |
130 static jint Init(JNIEnv* env, | |
131 jobject obj, | |
132 jint web_contents_ptr) { | |
133 TabBaseAndroidImpl* tab = new TabBaseAndroidImpl( | |
134 env, | |
135 obj, | |
136 reinterpret_cast<WebContents*>(web_contents_ptr)); | |
137 return reinterpret_cast<jint>(tab); | |
138 } | |
OLD | NEW |