| 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 "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/debug/trace_event.h" | 10 #include "base/debug/trace_event.h" |
| 11 #include "chrome/browser/android/chrome_web_contents_delegate_android.h" | 11 #include "chrome/browser/android/chrome_web_contents_delegate_android.h" |
| 12 #include "chrome/browser/browser_about_handler.h" | 12 #include "chrome/browser/browser_about_handler.h" |
| 13 #include "chrome/browser/chrome_notification_types.h" | 13 #include "chrome/browser/chrome_notification_types.h" |
| 14 #include "chrome/browser/content_settings/tab_specific_content_settings.h" | 14 #include "chrome/browser/content_settings/tab_specific_content_settings.h" |
| 15 #include "chrome/browser/favicon/favicon_tab_helper.h" | 15 #include "chrome/browser/favicon/favicon_tab_helper.h" |
| 16 #include "chrome/browser/google/google_url_tracker_factory.h" | 16 #include "chrome/browser/google/google_url_tracker_factory.h" |
| 17 #include "chrome/browser/infobars/infobar_service.h" | 17 #include "chrome/browser/infobars/infobar_service.h" |
| 18 #include "chrome/browser/prerender/prerender_contents.h" | 18 #include "chrome/browser/prerender/prerender_contents.h" |
| 19 #include "chrome/browser/prerender/prerender_manager.h" | 19 #include "chrome/browser/prerender/prerender_manager.h" |
| 20 #include "chrome/browser/prerender/prerender_manager_factory.h" | 20 #include "chrome/browser/prerender/prerender_manager_factory.h" |
| 21 #include "chrome/browser/printing/print_view_manager_basic.h" | 21 #include "chrome/browser/printing/print_view_manager_basic.h" |
| 22 #include "chrome/browser/profiles/profile.h" | 22 #include "chrome/browser/profiles/profile.h" |
| 23 #include "chrome/browser/profiles/profile_android.h" | 23 #include "chrome/browser/profiles/profile_android.h" |
| 24 #include "chrome/browser/search/instant_service.h" | 24 #include "chrome/browser/search/instant_service.h" |
| 25 #include "chrome/browser/search/instant_service_factory.h" | 25 #include "chrome/browser/search/instant_service_factory.h" |
| 26 #include "chrome/browser/search/search.h" | 26 #include "chrome/browser/search/search.h" |
| 27 #include "chrome/browser/sessions/session_tab_helper.h" | 27 #include "chrome/browser/sessions/session_tab_helper.h" |
| 28 #include "chrome/browser/sessions/tab_restore_service.h" |
| 29 #include "chrome/browser/sessions/tab_restore_service_factory.h" |
| 28 #include "chrome/browser/sync/glue/synced_tab_delegate_android.h" | 30 #include "chrome/browser/sync/glue/synced_tab_delegate_android.h" |
| 29 #include "chrome/browser/tab_contents/tab_util.h" | 31 #include "chrome/browser/tab_contents/tab_util.h" |
| 30 #include "chrome/browser/ui/android/content_settings/popup_blocked_infobar_deleg
ate.h" | 32 #include "chrome/browser/ui/android/content_settings/popup_blocked_infobar_deleg
ate.h" |
| 31 #include "chrome/browser/ui/android/context_menu_helper.h" | 33 #include "chrome/browser/ui/android/context_menu_helper.h" |
| 32 #include "chrome/browser/ui/android/infobars/infobar_container_android.h" | 34 #include "chrome/browser/ui/android/infobars/infobar_container_android.h" |
| 33 #include "chrome/browser/ui/android/tab_model/tab_model.h" | 35 #include "chrome/browser/ui/android/tab_model/tab_model.h" |
| 34 #include "chrome/browser/ui/android/tab_model/tab_model_list.h" | 36 #include "chrome/browser/ui/android/tab_model/tab_model_list.h" |
| 35 #include "chrome/browser/ui/android/window_android_helper.h" | 37 #include "chrome/browser/ui/android/window_android_helper.h" |
| 36 #include "chrome/browser/ui/blocked_content/popup_blocker_tab_helper.h" | 38 #include "chrome/browser/ui/blocked_content/popup_blocker_tab_helper.h" |
| 37 #include "chrome/browser/ui/search/instant_search_prerenderer.h" | 39 #include "chrome/browser/ui/search/instant_search_prerenderer.h" |
| (...skipping 634 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 672 return bitmap; | 674 return bitmap; |
| 673 } | 675 } |
| 674 | 676 |
| 675 prerender::PrerenderManager* TabAndroid::GetPrerenderManager() const { | 677 prerender::PrerenderManager* TabAndroid::GetPrerenderManager() const { |
| 676 Profile* profile = GetProfile(); | 678 Profile* profile = GetProfile(); |
| 677 if (!profile) | 679 if (!profile) |
| 678 return NULL; | 680 return NULL; |
| 679 return prerender::PrerenderManagerFactory::GetForProfile(profile); | 681 return prerender::PrerenderManagerFactory::GetForProfile(profile); |
| 680 } | 682 } |
| 681 | 683 |
| 684 // static |
| 685 void TabAndroid::CreateHistoricalTabFromContents(WebContents* web_contents) { |
| 686 DCHECK(web_contents); |
| 687 |
| 688 TabRestoreService* service = |
| 689 TabRestoreServiceFactory::GetForProfile( |
| 690 Profile::FromBrowserContext(web_contents->GetBrowserContext())); |
| 691 if (!service) |
| 692 return; |
| 693 |
| 694 // Exclude internal pages from being marked as recent when they are closed. |
| 695 const GURL& tab_url = web_contents->GetURL(); |
| 696 if (tab_url.SchemeIs(content::kChromeUIScheme) || |
| 697 tab_url.SchemeIs(chrome::kChromeNativeScheme) || |
| 698 tab_url.SchemeIs(url::kAboutScheme)) { |
| 699 return; |
| 700 } |
| 701 |
| 702 // TODO(jcivelli): is the index important? |
| 703 service->CreateHistoricalTab(web_contents, -1); |
| 704 } |
| 705 |
| 706 void TabAndroid::CreateHistoricalTab(JNIEnv* env, jobject obj) { |
| 707 TabAndroid::CreateHistoricalTabFromContents(web_contents()); |
| 708 } |
| 709 |
| 682 static void Init(JNIEnv* env, jobject obj) { | 710 static void Init(JNIEnv* env, jobject obj) { |
| 683 TRACE_EVENT0("native", "TabAndroid::Init"); | 711 TRACE_EVENT0("native", "TabAndroid::Init"); |
| 684 // This will automatically bind to the Java object and pass ownership there. | 712 // This will automatically bind to the Java object and pass ownership there. |
| 685 new TabAndroid(env, obj); | 713 new TabAndroid(env, obj); |
| 686 } | 714 } |
| 687 | 715 |
| 716 // static |
| 688 bool TabAndroid::RegisterTabAndroid(JNIEnv* env) { | 717 bool TabAndroid::RegisterTabAndroid(JNIEnv* env) { |
| 689 return RegisterNativesImpl(env); | 718 return RegisterNativesImpl(env); |
| 690 } | 719 } |
| OLD | NEW |