OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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_android.h" | 5 #include "chrome/browser/android/tab_android.h" |
6 | 6 |
7 #include "base/android/jni_android.h" | 7 #include "base/android/jni_android.h" |
8 #include "base/android/jni_array.h" | 8 #include "base/android/jni_array.h" |
9 #include "base/android/jni_string.h" | 9 #include "base/android/jni_string.h" |
10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
280 | 280 |
281 // Only allows the browser-initiated navigation to use POST. | 281 // Only allows the browser-initiated navigation to use POST. |
282 if (params->uses_post && !params->is_renderer_initiated) { | 282 if (params->uses_post && !params->is_renderer_initiated) { |
283 load_url_params->load_type = | 283 load_url_params->load_type = |
284 NavigationController::LOAD_TYPE_BROWSER_INITIATED_HTTP_POST; | 284 NavigationController::LOAD_TYPE_BROWSER_INITIATED_HTTP_POST; |
285 load_url_params->browser_initiated_post_data = | 285 load_url_params->browser_initiated_post_data = |
286 params->browser_initiated_post_data; | 286 params->browser_initiated_post_data; |
287 } | 287 } |
288 } | 288 } |
289 | 289 |
| 290 bool TabAndroid::HasOfflinePages() const { |
| 291 if (!offline_pages::IsOfflinePagesEnabled()) |
| 292 return false; |
| 293 offline_pages::OfflinePageModel* offline_page_model = |
| 294 offline_pages::OfflinePageModelFactory::GetForBrowserContext( |
| 295 GetProfile()); |
| 296 return !offline_page_model->GetAllPages().empty(); |
| 297 } |
| 298 |
| 299 void TabAndroid::ShowOfflinePages() { |
| 300 JNIEnv* env = base::android::AttachCurrentThread(); |
| 301 Java_Tab_showOfflinePages(env, weak_java_tab_.get(env).obj()); |
| 302 } |
| 303 |
290 void TabAndroid::SwapTabContents(content::WebContents* old_contents, | 304 void TabAndroid::SwapTabContents(content::WebContents* old_contents, |
291 content::WebContents* new_contents, | 305 content::WebContents* new_contents, |
292 bool did_start_load, | 306 bool did_start_load, |
293 bool did_finish_load) { | 307 bool did_finish_load) { |
294 JNIEnv* env = base::android::AttachCurrentThread(); | 308 JNIEnv* env = base::android::AttachCurrentThread(); |
295 Java_Tab_swapWebContents( | 309 Java_Tab_swapWebContents( |
296 env, | 310 env, |
297 weak_java_tab_.get(env).obj(), | 311 weak_java_tab_.get(env).obj(), |
298 new_contents->GetJavaWebContents().obj(), | 312 new_contents->GetJavaWebContents().obj(), |
299 did_start_load, | 313 did_start_load, |
(...skipping 609 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
909 static void Init(JNIEnv* env, const JavaParamRef<jobject>& obj) { | 923 static void Init(JNIEnv* env, const JavaParamRef<jobject>& obj) { |
910 TRACE_EVENT0("native", "TabAndroid::Init"); | 924 TRACE_EVENT0("native", "TabAndroid::Init"); |
911 // This will automatically bind to the Java object and pass ownership there. | 925 // This will automatically bind to the Java object and pass ownership there. |
912 new TabAndroid(env, obj); | 926 new TabAndroid(env, obj); |
913 } | 927 } |
914 | 928 |
915 // static | 929 // static |
916 bool TabAndroid::RegisterTabAndroid(JNIEnv* env) { | 930 bool TabAndroid::RegisterTabAndroid(JNIEnv* env) { |
917 return RegisterNativesImpl(env); | 931 return RegisterNativesImpl(env); |
918 } | 932 } |
OLD | NEW |