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/google/google_url_tracker_factory.h" | 16 #include "chrome/browser/google/google_url_tracker_factory.h" |
16 #include "chrome/browser/infobars/infobar_service.h" | 17 #include "chrome/browser/infobars/infobar_service.h" |
17 #include "chrome/browser/prerender/prerender_contents.h" | 18 #include "chrome/browser/prerender/prerender_contents.h" |
18 #include "chrome/browser/prerender/prerender_manager.h" | 19 #include "chrome/browser/prerender/prerender_manager.h" |
19 #include "chrome/browser/prerender/prerender_manager_factory.h" | 20 #include "chrome/browser/prerender/prerender_manager_factory.h" |
20 #include "chrome/browser/printing/print_view_manager_basic.h" | 21 #include "chrome/browser/printing/print_view_manager_basic.h" |
21 #include "chrome/browser/profiles/profile.h" | 22 #include "chrome/browser/profiles/profile.h" |
22 #include "chrome/browser/profiles/profile_android.h" | 23 #include "chrome/browser/profiles/profile_android.h" |
23 #include "chrome/browser/search/search.h" | 24 #include "chrome/browser/search/search.h" |
24 #include "chrome/browser/sessions/session_tab_helper.h" | 25 #include "chrome/browser/sessions/session_tab_helper.h" |
(...skipping 15 matching lines...) Expand all Loading... | |
40 #include "components/google/core/browser/google_util.h" | 41 #include "components/google/core/browser/google_util.h" |
41 #include "components/infobars/core/infobar_container.h" | 42 #include "components/infobars/core/infobar_container.h" |
42 #include "components/url_fixer/url_fixer.h" | 43 #include "components/url_fixer/url_fixer.h" |
43 #include "content/public/browser/android/content_view_core.h" | 44 #include "content/public/browser/android/content_view_core.h" |
44 #include "content/public/browser/navigation_entry.h" | 45 #include "content/public/browser/navigation_entry.h" |
45 #include "content/public/browser/notification_service.h" | 46 #include "content/public/browser/notification_service.h" |
46 #include "content/public/browser/user_metrics.h" | 47 #include "content/public/browser/user_metrics.h" |
47 #include "content/public/browser/web_contents.h" | 48 #include "content/public/browser/web_contents.h" |
48 #include "jni/Tab_jni.h" | 49 #include "jni/Tab_jni.h" |
49 #include "third_party/WebKit/public/platform/WebReferrerPolicy.h" | 50 #include "third_party/WebKit/public/platform/WebReferrerPolicy.h" |
51 #include "ui/gfx/android/java_bitmap.h" | |
52 | |
53 using gfx::ConvertToJavaBitmap; | |
50 | 54 |
51 TabAndroid* TabAndroid::FromWebContents(content::WebContents* web_contents) { | 55 TabAndroid* TabAndroid::FromWebContents(content::WebContents* web_contents) { |
52 CoreTabHelper* core_tab_helper = CoreTabHelper::FromWebContents(web_contents); | 56 CoreTabHelper* core_tab_helper = CoreTabHelper::FromWebContents(web_contents); |
53 if (!core_tab_helper) | 57 if (!core_tab_helper) |
54 return NULL; | 58 return NULL; |
55 | 59 |
56 CoreTabHelperDelegate* core_delegate = core_tab_helper->delegate(); | 60 CoreTabHelperDelegate* core_delegate = core_tab_helper->delegate(); |
57 if (!core_delegate) | 61 if (!core_delegate) |
58 return NULL; | 62 return NULL; |
59 | 63 |
(...skipping 450 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
510 printing::PrintViewManagerBasic::CreateForWebContents(web_contents()); | 514 printing::PrintViewManagerBasic::CreateForWebContents(web_contents()); |
511 printing::PrintViewManagerBasic* print_view_manager = | 515 printing::PrintViewManagerBasic* print_view_manager = |
512 printing::PrintViewManagerBasic::FromWebContents(web_contents()); | 516 printing::PrintViewManagerBasic::FromWebContents(web_contents()); |
513 if (print_view_manager == NULL) | 517 if (print_view_manager == NULL) |
514 return false; | 518 return false; |
515 | 519 |
516 print_view_manager->PrintNow(); | 520 print_view_manager->PrintNow(); |
517 return true; | 521 return true; |
518 } | 522 } |
519 | 523 |
524 ScopedJavaLocalRef<jobject> TabAndroid::GetFavicon(JNIEnv* env, jobject obj) { | |
525 ScopedJavaLocalRef<jobject> bitmap; | |
526 FaviconTabHelper* favicon_tab_helper = | |
527 FaviconTabHelper::FromWebContents(web_contents_.get()); | |
528 if (!favicon_tab_helper) | |
529 return bitmap; | |
530 if (!favicon_tab_helper->FaviconIsValid()) | |
531 return bitmap; | |
532 | |
533 const SkBitmap& favicon = favicon_tab_helper->GetFavicon().AsBitmap(); | |
534 if(favicon.getSize() > 0) | |
535 bitmap = ConvertToJavaBitmap(&favicon); | |
536 | |
537 return bitmap; | |
Bernhard Bauer
2014/07/02 13:32:28
The downstream version of this code will try to ge
| |
538 } | |
Bernhard Bauer
2014/07/02 13:32:28
Nit: empty line afterwards.
Jitu( very slow this week)
2014/07/02 13:54:55
Done.
| |
520 prerender::PrerenderManager* TabAndroid::GetPrerenderManager() const { | 539 prerender::PrerenderManager* TabAndroid::GetPrerenderManager() const { |
521 Profile* profile = GetProfile(); | 540 Profile* profile = GetProfile(); |
522 if (!profile) | 541 if (!profile) |
523 return NULL; | 542 return NULL; |
524 return prerender::PrerenderManagerFactory::GetForProfile(profile); | 543 return prerender::PrerenderManagerFactory::GetForProfile(profile); |
525 } | 544 } |
526 | 545 |
527 static void Init(JNIEnv* env, jobject obj) { | 546 static void Init(JNIEnv* env, jobject obj) { |
528 TRACE_EVENT0("native", "TabAndroid::Init"); | 547 TRACE_EVENT0("native", "TabAndroid::Init"); |
529 // This will automatically bind to the Java object and pass ownership there. | 548 // This will automatically bind to the Java object and pass ownership there. |
530 new TabAndroid(env, obj); | 549 new TabAndroid(env, obj); |
531 } | 550 } |
532 | 551 |
533 bool TabAndroid::RegisterTabAndroid(JNIEnv* env) { | 552 bool TabAndroid::RegisterTabAndroid(JNIEnv* env) { |
534 return RegisterNativesImpl(env); | 553 return RegisterNativesImpl(env); |
535 } | 554 } |
OLD | NEW |