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

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: Addressed nits, rebased. Created 8 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 | 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 "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,
29 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
47 private:
48 TabBaseAndroidImpl* tab_android_impl_;
49
50 DISALLOW_COPY_AND_ASSIGN(ChromeWebContentsDelegateRenderAndroid);
51 };
52 } // namespace
53
54 TabBaseAndroidImpl::TabBaseAndroidImpl(JNIEnv* env,
55 jobject obj,
56 WebContents* web_contents)
57 : web_contents_(web_contents),
58 tab_layer_(WebKit::WebLayer::create()) {
59 }
60
61 TabBaseAndroidImpl::~TabBaseAndroidImpl() {
62 }
63
64 void TabBaseAndroidImpl::Destroy(JNIEnv* env, jobject obj) {
65 delete this;
66 }
67
68 browser_sync::SyncedTabDelegate* TabBaseAndroidImpl::GetSyncedTabDelegate() {
69 NOTIMPLEMENTED();
70 return NULL;
71 }
72
73 void TabBaseAndroidImpl::OnReceivedHttpAuthRequest(jobject auth_handler,
74 const string16& host,
75 const string16& realm) {
76 NOTIMPLEMENTED();
77 }
78
79 void TabBaseAndroidImpl::ShowContextMenu(
80 const content::ContextMenuParams& params) {
81 NOTIMPLEMENTED();
82 }
83
84 void TabBaseAndroidImpl::ShowCustomContextMenu(
85 const content::ContextMenuParams& params,
86 const base::Callback<void(int)>& callback) {
87 NOTIMPLEMENTED();
88 }
89
90 void TabBaseAndroidImpl::ShowSelectFileDialog(
91 const base::android::ScopedJavaLocalRef<jobject>& select_file) {
92 NOTIMPLEMENTED();
93 }
94
95 void TabBaseAndroidImpl::AddShortcutToBookmark(
96 const GURL& url, const string16& title, const SkBitmap& skbitmap,
97 int r_value, int g_value, int b_value) {
98 NOTIMPLEMENTED();
99 }
100
101 void TabBaseAndroidImpl::RunExternalProtocolDialog(const GURL& url) {
102 NOTIMPLEMENTED();
103 }
104
105 bool TabBaseAndroidImpl::RegisterTabBaseAndroidImpl(JNIEnv* env) {
106 return RegisterNativesImpl(env);
107 }
108
109 void TabBaseAndroidImpl::InitWebContentsDelegate(
110 JNIEnv* env,
111 jobject obj,
112 jobject web_contents_delegate) {
113 web_contents_delegate_.reset(
114 new ChromeWebContentsDelegateRenderAndroid(this,
115 env,
116 web_contents_delegate));
117 web_contents_->SetDelegate(web_contents_delegate_.get());
118 }
119
120 ScopedJavaLocalRef<jstring> TabBaseAndroidImpl::FixupUrl(JNIEnv* env,
121 jobject obj,
122 jstring url) {
123 GURL fixed_url(URLFixerUpper::FixupURL(ConvertJavaStringToUTF8(env, url),
124 std::string()));
125
126 std::string fixed_spec;
127 if (fixed_url.is_valid())
128 fixed_spec = fixed_url.spec();
129
130 return ConvertUTF8ToJavaString(env, fixed_spec);
131 }
132
133 static jint Init(JNIEnv* env,
134 jobject obj,
135 jint web_contents_ptr) {
136 TabBaseAndroidImpl* tab = new TabBaseAndroidImpl(
137 env,
138 obj,
139 reinterpret_cast<WebContents*>(web_contents_ptr));
140 return reinterpret_cast<jint>(tab);
141 }
OLDNEW
« no previous file with comments | « chrome/browser/android/tab_base_android_impl.h ('k') | chrome/browser/chrome_content_browser_client.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698