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

Side by Side Diff: chrome/browser/android/tab_base_android_impl.cc

Issue 10968003: Add rendering support to the TestShell. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebased on top of test apk changes. Created 8 years, 3 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 | Annotate | Revision Log
OLDNEW
(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 "chrome/browser/ui/tab_contents/tab_contents.h"
12 #include "content/public/browser/android/content_view_core.h"
13 #include "content/public/browser/web_contents.h"
14 #include "googleurl/src/gurl.h"
15 #include "jni/TabBase_jni.h"
16 #include "third_party/WebKit/Source/Platform/chromium/public/WebLayer.h"
17
18 using base::android::ConvertJavaStringToUTF8;
19 using base::android::ConvertUTF8ToJavaString;
20 using base::android::ScopedJavaLocalRef;
21 using chrome::android::ChromeWebContentsDelegateAndroid;
22 using content::WebContents;
23
24 namespace {
25 class ChromeWebContentsDelegateRenderAndroid
26 : public ChromeWebContentsDelegateAndroid {
27 public:
28 ChromeWebContentsDelegateRenderAndroid(TabBaseAndroidImpl* tab_android_impl,
29 JNIEnv* env, jobject obj)
30 : ChromeWebContentsDelegateAndroid(env, obj),
31 tab_android_impl_(tab_android_impl) {
32 }
33
34 virtual ~ChromeWebContentsDelegateRenderAndroid() {
35 }
36
37 virtual void AttachLayer(WebContents* web_contents,
38 WebKit::WebLayer* layer) OVERRIDE {
39 tab_android_impl_->tab_layer()->addChild(layer);
40 }
41
42 virtual void RemoveLayer(WebContents* web_contents,
43 WebKit::WebLayer* layer) OVERRIDE {
44 layer->removeFromParent();
45 }
46 private:
Jay Civelli 2012/09/24 22:43:08 Nit: 1 blank line before private:
David Trainor- moved to gerrit 2012/09/24 23:39:57 Done.
47 TabBaseAndroidImpl* tab_android_impl_;
48 };
49 } // namespace
50
51 TabBaseAndroidImpl::TabBaseAndroidImpl(JNIEnv* env, jobject obj)
52 : TabAndroid() {
Jay Civelli 2012/09/24 22:43:08 Is calling TabAndroid() needed?
David Trainor- moved to gerrit 2012/09/24 23:39:57 No. Refactor bug sorry. On 2012/09/24 22:43:08,
53 }
54
55 TabBaseAndroidImpl::~TabBaseAndroidImpl() {
56 }
57
58 void TabBaseAndroidImpl::Destroy(JNIEnv* env, jobject obj) {
59 delete this;
60 }
61
62 browser_sync::SyncedTabDelegate* TabBaseAndroidImpl::GetSyncedTabDelegate() {
63 NOTIMPLEMENTED();
64 return NULL;
65 }
66
67 void TabBaseAndroidImpl::OnReceivedHttpAuthRequest(jobject auth_handler,
68 const string16& host,
nilesh 2012/09/24 20:46:41 fix indentation.
David Trainor- moved to gerrit 2012/09/24 23:39:57 Done.
69 const string16& realm) {
70 NOTIMPLEMENTED();
71 }
72
73 void TabBaseAndroidImpl::ShowContextMenu(
74 const content::ContextMenuParams& params) {
75 NOTIMPLEMENTED();
76 }
77
78 void TabBaseAndroidImpl::ShowCustomContextMenu(
79 const content::ContextMenuParams& params,
80 const base::Callback<void(int)>& callback) {
81 NOTIMPLEMENTED();
82 }
83
84 void TabBaseAndroidImpl::ShowSelectFileDialog(
85 const base::android::ScopedJavaLocalRef<jobject>& select_file) {
86 NOTIMPLEMENTED();
87 }
88
89 void TabBaseAndroidImpl::AddShortcutToBookmark(
90 const GURL& url, const string16& title, const SkBitmap& skbitmap,
91 int r_value, int g_value, int b_value) {
92 NOTIMPLEMENTED();
93 }
94
95 void TabBaseAndroidImpl::RunExternalProtocolDialog(const GURL& url) {
96 NOTIMPLEMENTED();
97 }
98
99 bool TabBaseAndroidImpl::RegisterTabBaseAndroidImpl(JNIEnv* env) {
100 return RegisterNativesImpl(env);
101 }
102
103 void TabBaseAndroidImpl::InitTabContents(JNIEnv* env, jobject obj, jobject view,
104 jobject web_contents_delegate) {
nilesh 2012/09/24 20:46:41 fix indentation
David Trainor- moved to gerrit 2012/09/24 23:39:57 Done.
105 // Build our tab layer.
106 if (!tab_layer_.get())
107 tab_layer_.reset(WebKit::WebLayer::create());
108
109 content::ContentViewCore* content_view_core =
110 content::ContentViewCore::GetNativeContentViewCore(env, view);
111 DCHECK(content_view_core);
112 // If this is a pop-up, a TabContents may have been created
nilesh 2012/09/24 20:46:41 This comment does not seem relevant here. There is
David Trainor- moved to gerrit 2012/09/24 23:39:57 Redid how this works. Removed most of this. On 2
113 // in ContentViewClient::AddNewContents(). Check before creating a
114 // new one.
115 tab_contents_.reset(InitTabContentsFromView(env, view));
116 DCHECK(tab_contents_.get());
117 WebContents* web_contents = tab_contents_->web_contents();
118 DCHECK(web_contents);
119 web_contents_delegate_.reset(
120 new ChromeWebContentsDelegateRenderAndroid(this,
121 env,
122 web_contents_delegate));
123 web_contents->SetDelegate(web_contents_delegate_.get());
124 }
125
126 void TabBaseAndroidImpl::DestroyTabContents(JNIEnv* env, jobject obj) {
127 DCHECK(tab_contents_.get());
128 WebContents* web_contents = tab_contents_->web_contents();
129 DCHECK(web_contents);
130 web_contents->SetDelegate(NULL);
131 tab_contents_.reset();
132 }
133
134 ScopedJavaLocalRef<jstring> TabBaseAndroidImpl::FixupUrl(JNIEnv* env,
135 jobject obj,
136 jstring url) {
137 GURL fixed_url(URLFixerUpper::FixupURL(ConvertJavaStringToUTF8(env, url),
138 std::string()));
139
140 std::string fixed_spec;
141 if (fixed_url.is_valid())
142 fixed_spec = fixed_url.spec();
143
144 return ConvertUTF8ToJavaString(env, fixed_spec);
145 }
146
147 // ----------------------------------------------------------------------------
148 // Native JNI methods
nilesh 2012/09/24 20:46:41 I think we can remove this comment. We have JNI me
David Trainor- moved to gerrit 2012/09/24 23:39:57 Done.
149 // ----------------------------------------------------------------------------
150
151 static jint Init(JNIEnv* env, jobject obj) {
152 TabBaseAndroidImpl* tab = new TabBaseAndroidImpl(env, obj);
153 return reinterpret_cast<jint>(tab);
154 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698