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 14 matching lines...) Expand all Loading... | |
39 #include "components/google/core/browser/google_url_tracker.h" | 40 #include "components/google/core/browser/google_url_tracker.h" |
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" |
50 #include "skia/ext/image_operations.h" | |
49 #include "third_party/WebKit/public/platform/WebReferrerPolicy.h" | 51 #include "third_party/WebKit/public/platform/WebReferrerPolicy.h" |
52 #include "ui/base/resource/resource_bundle.h" | |
53 #include "ui/gfx/android/java_bitmap.h" | |
54 #include "ui/gfx/favicon_size.h" | |
55 #include "ui/gfx/image/image_skia.h" | |
50 | 56 |
51 TabAndroid* TabAndroid::FromWebContents(content::WebContents* web_contents) { | 57 TabAndroid* TabAndroid::FromWebContents(content::WebContents* web_contents) { |
52 CoreTabHelper* core_tab_helper = CoreTabHelper::FromWebContents(web_contents); | 58 CoreTabHelper* core_tab_helper = CoreTabHelper::FromWebContents(web_contents); |
53 if (!core_tab_helper) | 59 if (!core_tab_helper) |
54 return NULL; | 60 return NULL; |
55 | 61 |
56 CoreTabHelperDelegate* core_delegate = core_tab_helper->delegate(); | 62 CoreTabHelperDelegate* core_delegate = core_tab_helper->delegate(); |
57 if (!core_delegate) | 63 if (!core_delegate) |
58 return NULL; | 64 return NULL; |
59 | 65 |
(...skipping 444 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
504 printing::PrintViewManagerBasic::CreateForWebContents(web_contents()); | 510 printing::PrintViewManagerBasic::CreateForWebContents(web_contents()); |
505 printing::PrintViewManagerBasic* print_view_manager = | 511 printing::PrintViewManagerBasic* print_view_manager = |
506 printing::PrintViewManagerBasic::FromWebContents(web_contents()); | 512 printing::PrintViewManagerBasic::FromWebContents(web_contents()); |
507 if (print_view_manager == NULL) | 513 if (print_view_manager == NULL) |
508 return false; | 514 return false; |
509 | 515 |
510 print_view_manager->PrintNow(); | 516 print_view_manager->PrintNow(); |
511 return true; | 517 return true; |
512 } | 518 } |
513 | 519 |
520 ScopedJavaLocalRef<jobject> TabAndroid::GetFavicon(JNIEnv* env, jobject obj) { | |
521 ScopedJavaLocalRef<jobject> bitmap; | |
522 FaviconTabHelper* favicon_tab_helper = | |
523 FaviconTabHelper::FromWebContents(web_contents_.get()); | |
524 if (!favicon_tab_helper) | |
525 return bitmap; | |
526 if (!favicon_tab_helper->FaviconIsValid()) | |
527 return bitmap; | |
528 | |
529 SkBitmap favicon = | |
530 favicon_tab_helper->GetFavicon() | |
531 .AsImageSkia() | |
532 .GetRepresentation( | |
533 ResourceBundle::GetSharedInstance().GetMaxScaleFactor()) | |
534 .sk_bitmap(); | |
535 | |
536 if (!favicon.isNull()) { | |
David Trainor- moved to gerrit
2014/07/21 18:18:17
If this is null use the default gfx::Image::AsBitm
Jitu( very slow this week)
2014/07/24 14:08:21
Done.
| |
537 if (favicon.width() != gfx::kFaviconSize || | |
538 favicon.height() != gfx::kFaviconSize) | |
David Trainor- moved to gerrit
2014/07/21 18:18:17
This scaling is still wrong it'll still scale to 1
Jitu( very slow this week)
2014/07/24 14:08:21
Done.
| |
539 favicon = | |
540 skia::ImageOperations::Resize(favicon, | |
541 skia::ImageOperations::RESIZE_BEST, | |
542 gfx::kFaviconSize, | |
543 gfx::kFaviconSize); | |
544 | |
545 bitmap = gfx::ConvertToJavaBitmap(&favicon); | |
546 } | |
547 return bitmap; | |
548 } | |
549 | |
514 prerender::PrerenderManager* TabAndroid::GetPrerenderManager() const { | 550 prerender::PrerenderManager* TabAndroid::GetPrerenderManager() const { |
515 Profile* profile = GetProfile(); | 551 Profile* profile = GetProfile(); |
516 if (!profile) | 552 if (!profile) |
517 return NULL; | 553 return NULL; |
518 return prerender::PrerenderManagerFactory::GetForProfile(profile); | 554 return prerender::PrerenderManagerFactory::GetForProfile(profile); |
519 } | 555 } |
520 | 556 |
521 static void Init(JNIEnv* env, jobject obj) { | 557 static void Init(JNIEnv* env, jobject obj) { |
522 TRACE_EVENT0("native", "TabAndroid::Init"); | 558 TRACE_EVENT0("native", "TabAndroid::Init"); |
523 // This will automatically bind to the Java object and pass ownership there. | 559 // This will automatically bind to the Java object and pass ownership there. |
524 new TabAndroid(env, obj); | 560 new TabAndroid(env, obj); |
525 } | 561 } |
526 | 562 |
527 bool TabAndroid::RegisterTabAndroid(JNIEnv* env) { | 563 bool TabAndroid::RegisterTabAndroid(JNIEnv* env) { |
528 return RegisterNativesImpl(env); | 564 return RegisterNativesImpl(env); |
529 } | 565 } |
OLD | NEW |