| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 #import "chrome/browser/cocoa/tabpose_window.h" | 5 #import "chrome/browser/cocoa/tabpose_window.h" |
| 6 | 6 |
| 7 #import <QuartzCore/QuartzCore.h> | 7 #import <QuartzCore/QuartzCore.h> |
| 8 | 8 |
| 9 #include "app/resource_bundle.h" | 9 #include "app/resource_bundle.h" |
| 10 #include "base/mac_util.h" | 10 #include "base/mac_util.h" |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 98 // Starts the fetch. | 98 // Starts the fetch. |
| 99 void LoadThumbnail(); | 99 void LoadThumbnail(); |
| 100 | 100 |
| 101 private: | 101 private: |
| 102 friend class base::RefCountedThreadSafe<ThumbnailLoader>; | 102 friend class base::RefCountedThreadSafe<ThumbnailLoader>; |
| 103 ~ThumbnailLoader() { | 103 ~ThumbnailLoader() { |
| 104 ResetPaintingObserver(); | 104 ResetPaintingObserver(); |
| 105 } | 105 } |
| 106 | 106 |
| 107 void DidReceiveBitmap(const SkBitmap& bitmap) { | 107 void DidReceiveBitmap(const SkBitmap& bitmap) { |
| 108 DCHECK(ChromeThread::CurrentlyOn(ChromeThread::UI)); | 108 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 109 ResetPaintingObserver(); | 109 ResetPaintingObserver(); |
| 110 [layer_ setThumbnail:bitmap]; | 110 [layer_ setThumbnail:bitmap]; |
| 111 } | 111 } |
| 112 | 112 |
| 113 void ResetPaintingObserver() { | 113 void ResetPaintingObserver() { |
| 114 if (rwh_->painting_observer() != NULL) { | 114 if (rwh_->painting_observer() != NULL) { |
| 115 DCHECK(rwh_->painting_observer() == | 115 DCHECK(rwh_->painting_observer() == |
| 116 g_browser_process->GetThumbnailGenerator()); | 116 g_browser_process->GetThumbnailGenerator()); |
| 117 rwh_->set_painting_observer(NULL); | 117 rwh_->set_painting_observer(NULL); |
| 118 } | 118 } |
| 119 } | 119 } |
| 120 | 120 |
| 121 gfx::Size size_; | 121 gfx::Size size_; |
| 122 RenderWidgetHost* rwh_; // weak | 122 RenderWidgetHost* rwh_; // weak |
| 123 ThumbnailLayer* layer_; // weak, owns us | 123 ThumbnailLayer* layer_; // weak, owns us |
| 124 base::ScopedCallbackFactory<ThumbnailLoader> factory_; | 124 base::ScopedCallbackFactory<ThumbnailLoader> factory_; |
| 125 | 125 |
| 126 DISALLOW_COPY_AND_ASSIGN(ThumbnailLoader); | 126 DISALLOW_COPY_AND_ASSIGN(ThumbnailLoader); |
| 127 }; | 127 }; |
| 128 | 128 |
| 129 void ThumbnailLoader::LoadThumbnail() { | 129 void ThumbnailLoader::LoadThumbnail() { |
| 130 DCHECK(ChromeThread::CurrentlyOn(ChromeThread::UI)); | 130 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 131 ThumbnailGenerator* generator = g_browser_process->GetThumbnailGenerator(); | 131 ThumbnailGenerator* generator = g_browser_process->GetThumbnailGenerator(); |
| 132 if (!generator) // In unit tests. | 132 if (!generator) // In unit tests. |
| 133 return; | 133 return; |
| 134 | 134 |
| 135 // As mentioned in ThumbnailLayer's -drawInContext:, it's sufficient to have | 135 // As mentioned in ThumbnailLayer's -drawInContext:, it's sufficient to have |
| 136 // thumbnails at the zoomed-out pixel size for all but the thumbnail the user | 136 // thumbnails at the zoomed-out pixel size for all but the thumbnail the user |
| 137 // clicks on in the end. But we don't don't which thumbnail that will be, so | 137 // clicks on in the end. But we don't don't which thumbnail that will be, so |
| 138 // keep it simple and request full thumbnails for everything. | 138 // keep it simple and request full thumbnails for everything. |
| 139 // TODO(thakis): Request smaller thumbnails for users with many tabs. | 139 // TODO(thakis): Request smaller thumbnails for users with many tabs. |
| 140 gfx::Size page_size(size_); // Logical size the renderer renders at. | 140 gfx::Size page_size(size_); // Logical size the renderer renders at. |
| (...skipping 1276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1417 tile.set_tab_contents(contents); | 1417 tile.set_tab_contents(contents); |
| 1418 ThumbnailLayer* thumbLayer = [allThumbnailLayers_ objectAtIndex:index]; | 1418 ThumbnailLayer* thumbLayer = [allThumbnailLayers_ objectAtIndex:index]; |
| 1419 [thumbLayer setTabContents:contents]; | 1419 [thumbLayer setTabContents:contents]; |
| 1420 } | 1420 } |
| 1421 | 1421 |
| 1422 - (void)tabStripModelDeleted { | 1422 - (void)tabStripModelDeleted { |
| 1423 [self close]; | 1423 [self close]; |
| 1424 } | 1424 } |
| 1425 | 1425 |
| 1426 @end | 1426 @end |
| OLD | NEW |