Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(122)

Side by Side Diff: chrome/browser/android/tab_android.cc

Issue 496733005: Some favicon cleanup/upstreaming (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Addressed comments Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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"
(...skipping 585 matching lines...) Expand 10 before | Expand all | Expand 10 after
596 return true; 596 return true;
597 } 597 }
598 598
599 ScopedJavaLocalRef<jobject> TabAndroid::GetFavicon(JNIEnv* env, jobject obj) { 599 ScopedJavaLocalRef<jobject> TabAndroid::GetFavicon(JNIEnv* env, jobject obj) {
600 ScopedJavaLocalRef<jobject> bitmap; 600 ScopedJavaLocalRef<jobject> bitmap;
601 FaviconTabHelper* favicon_tab_helper = 601 FaviconTabHelper* favicon_tab_helper =
602 FaviconTabHelper::FromWebContents(web_contents_.get()); 602 FaviconTabHelper::FromWebContents(web_contents_.get());
603 603
604 if (!favicon_tab_helper) 604 if (!favicon_tab_helper)
605 return bitmap; 605 return bitmap;
606 if (!favicon_tab_helper->FaviconIsValid()) 606
607 return bitmap; 607 // If the favicon isn't valid, it will return a default bitmap.
608 608
609 SkBitmap favicon = 609 SkBitmap favicon =
610 favicon_tab_helper->GetFavicon() 610 favicon_tab_helper->GetFavicon()
611 .AsImageSkia() 611 .AsImageSkia()
612 .GetRepresentation( 612 .GetRepresentation(
613 ResourceBundle::GetSharedInstance().GetMaxScaleFactor()) 613 ResourceBundle::GetSharedInstance().GetMaxScaleFactor())
614 .sk_bitmap(); 614 .sk_bitmap();
615 615
616 if (favicon.empty()) { 616 if (favicon.empty()) {
617 favicon = favicon_tab_helper->GetFavicon().AsBitmap(); 617 favicon = favicon_tab_helper->GetFavicon().AsBitmap();
(...skipping 10 matching lines...) Expand all
628 skia::ImageOperations::RESIZE_BEST, 628 skia::ImageOperations::RESIZE_BEST,
629 target_size_dip, 629 target_size_dip,
630 target_size_dip); 630 target_size_dip);
631 } 631 }
632 632
633 bitmap = gfx::ConvertToJavaBitmap(&favicon); 633 bitmap = gfx::ConvertToJavaBitmap(&favicon);
634 } 634 }
635 return bitmap; 635 return bitmap;
636 } 636 }
637 637
638 jboolean TabAndroid::IsFaviconValid(JNIEnv* env, jobject jobj) {
639 return web_contents() &&
640 FaviconTabHelper::FromWebContents(web_contents())->FaviconIsValid();
641 }
642
638 prerender::PrerenderManager* TabAndroid::GetPrerenderManager() const { 643 prerender::PrerenderManager* TabAndroid::GetPrerenderManager() const {
639 Profile* profile = GetProfile(); 644 Profile* profile = GetProfile();
640 if (!profile) 645 if (!profile)
641 return NULL; 646 return NULL;
642 return prerender::PrerenderManagerFactory::GetForProfile(profile); 647 return prerender::PrerenderManagerFactory::GetForProfile(profile);
643 } 648 }
644 649
645 static void Init(JNIEnv* env, jobject obj) { 650 static void Init(JNIEnv* env, jobject obj) {
646 TRACE_EVENT0("native", "TabAndroid::Init"); 651 TRACE_EVENT0("native", "TabAndroid::Init");
647 // This will automatically bind to the Java object and pass ownership there. 652 // This will automatically bind to the Java object and pass ownership there.
648 new TabAndroid(env, obj); 653 new TabAndroid(env, obj);
649 } 654 }
650 655
651 bool TabAndroid::RegisterTabAndroid(JNIEnv* env) { 656 bool TabAndroid::RegisterTabAndroid(JNIEnv* env) {
652 return RegisterNativesImpl(env); 657 return RegisterNativesImpl(env);
653 } 658 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698