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 "android_webview/native/aw_contents.h" | 5 #include "android_webview/native/aw_contents.h" |
6 | 6 |
7 #include <sys/system_properties.h> | 7 #include <sys/system_properties.h> |
8 | 8 |
9 #include "android_webview/browser/aw_browser_main_parts.h" | 9 #include "android_webview/browser/aw_browser_main_parts.h" |
10 #include "android_webview/browser/net_disk_cache_remover.h" | 10 #include "android_webview/browser/net_disk_cache_remover.h" |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
142 | 142 |
143 } // namespace | 143 } // namespace |
144 | 144 |
145 // static | 145 // static |
146 AwContents* AwContents::FromWebContents(WebContents* web_contents) { | 146 AwContents* AwContents::FromWebContents(WebContents* web_contents) { |
147 return AwContentsUserData::GetContents(web_contents); | 147 return AwContentsUserData::GetContents(web_contents); |
148 } | 148 } |
149 | 149 |
150 AwContents::AwContents(JNIEnv* env, | 150 AwContents::AwContents(JNIEnv* env, |
151 jobject obj, | 151 jobject obj, |
152 jobject web_contents_delegate, | 152 jobject web_contents_delegate) |
153 bool private_browsing) | |
154 : java_ref_(env, obj), | 153 : java_ref_(env, obj), |
155 web_contents_delegate_( | 154 web_contents_delegate_( |
156 new AwWebContentsDelegate(env, web_contents_delegate)), | 155 new AwWebContentsDelegate(env, web_contents_delegate)), |
157 view_visible_(false), | 156 view_visible_(false), |
158 compositor_visible_(false), | 157 compositor_visible_(false), |
159 is_composite_pending_(false), | 158 is_composite_pending_(false), |
160 last_scroll_x_(0), last_scroll_y_(0), | 159 last_scroll_x_(0), last_scroll_y_(0), |
161 last_frame_context_(NULL) { | 160 last_frame_context_(NULL) { |
162 android_webview::AwBrowserDependencyFactory* dependency_factory = | 161 android_webview::AwBrowserDependencyFactory* dependency_factory = |
163 android_webview::AwBrowserDependencyFactory::GetInstance(); | 162 android_webview::AwBrowserDependencyFactory::GetInstance(); |
164 | 163 |
165 // TODO(joth): rather than create and set the WebContents here, expose the | 164 // TODO(joth): rather than create and set the WebContents here, expose the |
166 // factory method to java side and have that orchestrate the construction | 165 // factory method to java side and have that orchestrate the construction |
167 // order. | 166 // order. |
168 SetWebContents(dependency_factory->CreateWebContents(private_browsing)); | 167 SetWebContents(dependency_factory->CreateWebContents()); |
169 } | 168 } |
170 | 169 |
171 void AwContents::ResetCompositor() { | 170 void AwContents::ResetCompositor() { |
172 if (UseCompositorDirectDraw()) { | 171 if (UseCompositorDirectDraw()) { |
173 compositor_.reset(content::Compositor::Create(this)); | 172 compositor_.reset(content::Compositor::Create(this)); |
174 if (scissor_clip_layer_.get()) | 173 if (scissor_clip_layer_.get()) |
175 AttachLayerTree(); | 174 AttachLayerTree(); |
176 } else { | 175 } else { |
177 LOG(WARNING) << "Running on unsupported device: using null Compositor"; | 176 LOG(WARNING) << "Running on unsupported device: using null Compositor"; |
178 compositor_.reset(new NullCompositor); | 177 compositor_.reset(new NullCompositor); |
(...skipping 450 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
629 jobject obj, | 628 jobject obj, |
630 jobject delegate) { | 629 jobject delegate) { |
631 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 630 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
632 InterceptNavigationDelegate::Associate( | 631 InterceptNavigationDelegate::Associate( |
633 web_contents_.get(), | 632 web_contents_.get(), |
634 make_scoped_ptr(new InterceptNavigationDelegate(env, delegate))); | 633 make_scoped_ptr(new InterceptNavigationDelegate(env, delegate))); |
635 } | 634 } |
636 | 635 |
637 static jint Init(JNIEnv* env, | 636 static jint Init(JNIEnv* env, |
638 jobject obj, | 637 jobject obj, |
639 jobject web_contents_delegate, | 638 jobject web_contents_delegate) { |
640 jboolean private_browsing) { | 639 AwContents* tab = new AwContents(env, obj, web_contents_delegate); |
641 AwContents* tab = new AwContents(env, obj, web_contents_delegate, | |
642 private_browsing); | |
643 return reinterpret_cast<jint>(tab); | 640 return reinterpret_cast<jint>(tab); |
644 } | 641 } |
645 | 642 |
646 bool RegisterAwContents(JNIEnv* env) { | 643 bool RegisterAwContents(JNIEnv* env) { |
647 return RegisterNativesImpl(env) >= 0; | 644 return RegisterNativesImpl(env) >= 0; |
648 } | 645 } |
649 | 646 |
650 jint AwContents::FindAllSync(JNIEnv* env, jobject obj, jstring search_string) { | 647 jint AwContents::FindAllSync(JNIEnv* env, jobject obj, jstring search_string) { |
651 return GetFindHelper()->FindAllSync( | 648 return GetFindHelper()->FindAllSync( |
652 ConvertJavaStringToUTF16(env, search_string)); | 649 ConvertJavaStringToUTF16(env, search_string)); |
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
860 | 857 |
861 void AwContents::FocusFirstNode(JNIEnv* env, jobject obj) { | 858 void AwContents::FocusFirstNode(JNIEnv* env, jobject obj) { |
862 web_contents_->FocusThroughTabTraversal(false); | 859 web_contents_->FocusThroughTabTraversal(false); |
863 } | 860 } |
864 | 861 |
865 jint AwContents::ReleasePopupWebContents(JNIEnv* env, jobject obj) { | 862 jint AwContents::ReleasePopupWebContents(JNIEnv* env, jobject obj) { |
866 return reinterpret_cast<jint>(pending_contents_.release()); | 863 return reinterpret_cast<jint>(pending_contents_.release()); |
867 } | 864 } |
868 | 865 |
869 } // namespace android_webview | 866 } // namespace android_webview |
OLD | NEW |