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

Side by Side Diff: chrome/browser/android/tab/thumbnail_tab_helper_android.cc

Issue 1391893003: NOT FOR REVIEW: Aura on Android (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 2 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
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/thumbnail_tab_helper_android.h" 5 #include "chrome/browser/android/tab/thumbnail_tab_helper_android.h"
6 6
7 #include "base/android/jni_android.h" 7 #include "base/android/jni_android.h"
8 #include "base/android/jni_string.h" 8 #include "base/android/jni_string.h"
9 #include "base/memory/ref_counted.h" 9 #include "base/memory/ref_counted.h"
10 #include "chrome/browser/history/top_sites_factory.h" 10 #include "chrome/browser/history/top_sites_factory.h"
(...skipping 12 matching lines...) Expand all
23 #include "url/gurl.h" 23 #include "url/gurl.h"
24 24
25 // static 25 // static
26 bool RegisterThumbnailTabHelperAndroid(JNIEnv* env) { 26 bool RegisterThumbnailTabHelperAndroid(JNIEnv* env) {
27 return RegisterNativesImpl(env); 27 return RegisterNativesImpl(env);
28 } 28 }
29 29
30 static void InitThumbnailHelper(JNIEnv* env, 30 static void InitThumbnailHelper(JNIEnv* env,
31 jclass clazz, 31 jclass clazz,
32 jobject jweb_contents) { 32 jobject jweb_contents) {
33 #if !defined(USE_AURA)
33 content::WebContents* web_contents = 34 content::WebContents* web_contents =
34 content::WebContents::FromJavaWebContents(jweb_contents); 35 content::WebContents::FromJavaWebContents(jweb_contents);
35 DCHECK(web_contents); 36 DCHECK(web_contents);
36 37
37 // Don't allow ThumbnailTabHelper to take thumbnail snapshots. 38 // Don't allow ThumbnailTabHelper to take thumbnail snapshots.
38 // Currently the process is driven from Tab, but long term will 39 // Currently the process is driven from Tab, but long term will
39 // move into a Android specific tab helper. 40 // move into a Android specific tab helper.
40 // Bug: crbug.com/157431 41 // Bug: crbug.com/157431
41 ThumbnailTabHelper* thumbnail_tab_helper = 42 ThumbnailTabHelper* thumbnail_tab_helper =
42 ThumbnailTabHelper::FromWebContents(web_contents); 43 ThumbnailTabHelper::FromWebContents(web_contents);
43 if (thumbnail_tab_helper) 44 if (thumbnail_tab_helper)
44 thumbnail_tab_helper->set_enabled(false); 45 thumbnail_tab_helper->set_enabled(false);
46 #endif
45 } 47 }
46 48
47 static jboolean ShouldUpdateThumbnail( 49 static jboolean ShouldUpdateThumbnail(
48 JNIEnv* env, jclass clazz, jobject jprofile, jstring jurl) { 50 JNIEnv* env, jclass clazz, jobject jprofile, jstring jurl) {
49 Profile* profile = ProfileAndroid::FromProfileAndroid(jprofile); 51 Profile* profile = ProfileAndroid::FromProfileAndroid(jprofile);
50 52
51 GURL url(base::android::ConvertJavaStringToUTF8(env, jurl)); 53 GURL url(base::android::ConvertJavaStringToUTF8(env, jurl));
52 scoped_refptr<thumbnails::ThumbnailService> thumbnail_service = 54 scoped_refptr<thumbnails::ThumbnailService> thumbnail_service =
53 ThumbnailServiceFactory::GetForProfile(profile); 55 ThumbnailServiceFactory::GetForProfile(profile);
54 return (thumbnail_service.get() != NULL && 56 return (thumbnail_service.get() != NULL &&
55 thumbnail_service->ShouldAcquirePageThumbnail(url)); 57 thumbnail_service->ShouldAcquirePageThumbnail(url));
56 } 58 }
57 59
58 static void UpdateThumbnail(JNIEnv* env, 60 static void UpdateThumbnail(JNIEnv* env,
59 jclass clazz, 61 jclass clazz,
60 jobject jweb_contents, 62 jobject jweb_contents,
61 jobject bitmap, 63 jobject bitmap,
62 jboolean jat_top) { 64 jboolean jat_top) {
65 #if !defined(USE_AURA)
63 content::WebContents* web_contents = 66 content::WebContents* web_contents =
64 content::WebContents::FromJavaWebContents(jweb_contents); 67 content::WebContents::FromJavaWebContents(jweb_contents);
65 DCHECK(web_contents); 68 DCHECK(web_contents);
66 69
67 Profile* profile = Profile::FromBrowserContext( 70 Profile* profile = Profile::FromBrowserContext(
68 web_contents->GetBrowserContext()); 71 web_contents->GetBrowserContext());
69 72
70 gfx::JavaBitmap bitmap_lock(bitmap); 73 gfx::JavaBitmap bitmap_lock(bitmap);
71 SkBitmap sk_bitmap; 74 SkBitmap sk_bitmap;
72 gfx::Size size = bitmap_lock.size(); 75 gfx::Size size = bitmap_lock.size();
(...skipping 15 matching lines...) Expand all
88 // Compute the thumbnail score. 91 // Compute the thumbnail score.
89 ThumbnailScore score; 92 ThumbnailScore score;
90 score.at_top = jat_top; 93 score.at_top = jat_top;
91 score.boring_score = color_utils::CalculateBoringScore(sk_bitmap); 94 score.boring_score = color_utils::CalculateBoringScore(sk_bitmap);
92 score.good_clipping = true; 95 score.good_clipping = true;
93 score.load_completed = !web_contents->IsLoading(); 96 score.load_completed = !web_contents->IsLoading();
94 97
95 gfx::Image image = gfx::Image::CreateFrom1xBitmap(sk_bitmap); 98 gfx::Image image = gfx::Image::CreateFrom1xBitmap(sk_bitmap);
96 const GURL& url = web_contents->GetURL(); 99 const GURL& url = web_contents->GetURL();
97 ts->SetPageThumbnail(url, image, score); 100 ts->SetPageThumbnail(url, image, score);
101 #endif
98 } 102 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698