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

Unified Diff: chrome/browser/thumbnails/thumbnail_tab_helper.h

Issue 11985003: Refactored-out the code of thumbnaling algorithm from thumbnail_tab_helper. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Another round of updates from OWNER's review. Created 7 years, 11 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/thumbnails/thumbnail_tab_helper.h
diff --git a/chrome/browser/thumbnails/thumbnail_tab_helper.h b/chrome/browser/thumbnails/thumbnail_tab_helper.h
index bba24ce21a965161d63fe147e5d68f690c1ffb9a..bb8e8635c0aa5976a5974fdd9aac74f31e471151 100644
--- a/chrome/browser/thumbnails/thumbnail_tab_helper.h
+++ b/chrome/browser/thumbnails/thumbnail_tab_helper.h
@@ -6,62 +6,22 @@
#define CHROME_BROWSER_THUMBNAILS_THUMBNAIL_TAB_HELPER_H_
#include "base/basictypes.h"
-#include "chrome/common/thumbnail_score.h"
+#include "chrome/browser/thumbnails/thumbnailing_context.h"
#include "content/public/browser/notification_observer.h"
#include "content/public/browser/notification_registrar.h"
#include "content/public/browser/web_contents_observer.h"
#include "content/public/browser/web_contents_user_data.h"
-class GURL;
-class Profile;
-class SkBitmap;
-
namespace content {
class RenderViewHost;
class RenderWidgetHost;
}
-namespace skia {
-class PlatformBitmap;
-}
-
class ThumbnailTabHelper
: public content::NotificationObserver,
public content::WebContentsObserver,
public content::WebContentsUserData<ThumbnailTabHelper> {
public:
- // The result of clipping. This can be used to determine if the
- // generated thumbnail is good or not.
- enum ClipResult {
- // Clipping is not done yet.
- kUnprocessed,
- // The source image is smaller.
- kSourceIsSmaller,
- // Wider than tall by twice or more, clip horizontally.
- kTooWiderThanTall,
- // Wider than tall, clip horizontally.
- kWiderThanTall,
- // Taller than wide, clip vertically.
- kTallerThanWide,
- // The source and destination aspect ratios are identical.
- kNotClipped,
- };
-
- // Holds the information needed for processing a thumbnail.
- struct ThumbnailingContext : base::RefCountedThreadSafe<ThumbnailingContext> {
- ThumbnailingContext(content::WebContents* web_contents,
- bool load_interrupted);
-
- content::BrowserContext* browser_context;
- GURL url;
- ClipResult clip_result;
- ThumbnailScore score;
-
- private:
- ~ThumbnailingContext();
- friend class base::RefCountedThreadSafe<ThumbnailingContext>;
- };
-
virtual ~ThumbnailTabHelper();
// Enables or disables the function of taking thumbnails.
@@ -69,24 +29,6 @@ class ThumbnailTabHelper
// continues to receive the notifications from the web contents.
void set_enabled(bool enabled) { enabled_ = enabled; }
- // Calculates how "boring" a thumbnail is. The boring score is the
- // 0,1 ranged percentage of pixels that are the most common
- // luma. Higher boring scores indicate that a higher percentage of a
- // bitmap are all the same brightness.
- // Statically exposed for use by tests only.
- static double CalculateBoringScore(const SkBitmap& bitmap);
-
- // Gets the clipped bitmap from |bitmap| per the aspect ratio of the
- // desired width and the desired height. For instance, if the input
- // bitmap is vertically long (ex. 400x900) and the desired size is
- // square (ex. 100x100), the clipped bitmap will be the top half of the
- // input bitmap (400x400).
- // Statically exposed for use by tests only.
- static SkBitmap GetClippedBitmap(const SkBitmap& bitmap,
- int desired_width,
- int desired_height,
- ClipResult* clip_result);
-
private:
explicit ThumbnailTabHelper(content::WebContents* contents);
friend class content::WebContentsUserData<ThumbnailTabHelper>;
@@ -104,26 +46,6 @@ class ThumbnailTabHelper
// Update the thumbnail of the given tab contents if necessary.
void UpdateThumbnailIfNecessary(content::WebContents* web_contents);
- // Update the thumbnail of the given tab.
- static void UpdateThumbnail(ThumbnailingContext* context,
- const SkBitmap& bitmap);
-
- // Asynchronously updates the thumbnail of the given tab. This must be called
- // on the UI thread.
- void AsyncUpdateThumbnail(content::WebContents* web_contents);
-
- // Called when the bitmap for generating a thumbnail is ready after the
- // AsyncUpdateThumbnail invocation. This runs on the UI thread.
- static void UpdateThumbnailWithBitmap(ThumbnailingContext* context,
- const SkBitmap& bitmap);
-
- // Called when the canvas for generating a thumbnail is ready after the
- // AsyncUpdateThumbnail invocation. This runs on the UI thread.
- static void UpdateThumbnailWithCanvas(
- ThumbnailingContext* context,
- skia::PlatformBitmap* temp_bitmap,
- bool result);
-
// Called when a render view host was created for a WebContents.
void RenderViewHostCreated(content::RenderViewHost* renderer);
« no previous file with comments | « chrome/browser/thumbnails/thumbnail_service_impl.cc ('k') | chrome/browser/thumbnails/thumbnail_tab_helper.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698