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

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

Issue 364793005: Implementation of GetFavicon for current tab. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Scaled favicon image to 16x16 size Created 6 years, 5 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
« no previous file with comments | « chrome/browser/android/tab_android.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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"
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
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/gfx/android/java_bitmap.h"
53 #include "ui/gfx/favicon_size.h"
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
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 SkBitmap favicon = favicon_tab_helper->GetFavicon().AsBitmap();
534
535 if (!favicon.isNull()) {
536 if (favicon.width() != gfx::kFaviconSize ||
537 favicon.height() != gfx::kFaviconSize)
538 favicon =
539 skia::ImageOperations::Resize(favicon,
540 skia::ImageOperations::RESIZE_BEST,
541 gfx::kFaviconSize,
542 gfx::kFaviconSize);
543 bitmap = gfx::ConvertToJavaBitmap(&favicon);
David Trainor- moved to gerrit 2014/07/09 20:34:51 I think this is still incorrect. It looks like yo
544 }
545 return bitmap;
546 }
547
520 prerender::PrerenderManager* TabAndroid::GetPrerenderManager() const { 548 prerender::PrerenderManager* TabAndroid::GetPrerenderManager() const {
521 Profile* profile = GetProfile(); 549 Profile* profile = GetProfile();
522 if (!profile) 550 if (!profile)
523 return NULL; 551 return NULL;
524 return prerender::PrerenderManagerFactory::GetForProfile(profile); 552 return prerender::PrerenderManagerFactory::GetForProfile(profile);
525 } 553 }
526 554
527 static void Init(JNIEnv* env, jobject obj) { 555 static void Init(JNIEnv* env, jobject obj) {
528 TRACE_EVENT0("native", "TabAndroid::Init"); 556 TRACE_EVENT0("native", "TabAndroid::Init");
529 // This will automatically bind to the Java object and pass ownership there. 557 // This will automatically bind to the Java object and pass ownership there.
530 new TabAndroid(env, obj); 558 new TabAndroid(env, obj);
531 } 559 }
532 560
533 bool TabAndroid::RegisterTabAndroid(JNIEnv* env) { 561 bool TabAndroid::RegisterTabAndroid(JNIEnv* env) {
534 return RegisterNativesImpl(env); 562 return RegisterNativesImpl(env);
535 } 563 }
OLDNEW
« no previous file with comments | « chrome/browser/android/tab_android.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698