Index: chrome/browser/ui/views/ash/screenshot_taker.cc |
diff --git a/chrome/browser/ui/views/ash/screenshot_taker.cc b/chrome/browser/ui/views/ash/screenshot_taker.cc |
index b5f78289ca467c3f33281d786ba65ebca508d913..1657409ab7d4491df66b307632e0465e2504d18d 100644 |
--- a/chrome/browser/ui/views/ash/screenshot_taker.cc |
+++ b/chrome/browser/ui/views/ash/screenshot_taker.cc |
@@ -66,23 +66,8 @@ void SaveScreenshot(bool is_logged_in, |
} |
} |
-// How opaque should the layer that we flash onscreen to provide visual |
-// feedback after the screenshot is taken be? |
-const float kVisualFeedbackLayerOpacity = 0.25f; |
- |
-// How long should the visual feedback layer be displayed? |
-const int64 kVisualFeedbackLayerDisplayTimeMs = 100; |
- |
-} // namespace |
- |
-ScreenshotTaker::ScreenshotTaker() { |
-} |
- |
-ScreenshotTaker::~ScreenshotTaker() { |
-} |
- |
-void ScreenshotTaker::HandleTakePartialScreenshot( |
- aura::Window* window, const gfx::Rect& rect) { |
+// Actually takes the screenshot. |
+void TakeScreenshot(aura::Window* window, const gfx::Rect& rect) { |
DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); |
scoped_refptr<RefCountedBytes> png_data(new RefCountedBytes); |
@@ -93,7 +78,6 @@ void ScreenshotTaker::HandleTakePartialScreenshot( |
#endif |
if (browser::GrabWindowSnapshot(window, &png_data->data(), rect)) { |
- DisplayVisualFeedback(rect); |
content::BrowserThread::PostTask( |
content::BrowserThread::FILE, FROM_HERE, |
base::Bind(&SaveScreenshot, is_logged_in, png_data)); |
@@ -102,15 +86,42 @@ void ScreenshotTaker::HandleTakePartialScreenshot( |
} |
} |
+// How opaque should the layer that we flash onscreen to provide visual |
+// feedback after the screenshot is taken be? |
+const float kVisualFeedbackLayerOpacity = 0.25f; |
+ |
+// How long should the visual feedback layer be displayed? |
+const int64 kVisualFeedbackLayerDisplayTimeMs = 100; |
+ |
+} // namespace |
+ |
+ScreenshotTaker::ScreenshotTaker() { |
+} |
+ |
+ScreenshotTaker::~ScreenshotTaker() { |
+} |
+ |
+void ScreenshotTaker::HandleTakePartialScreenshot(aura::Window* window, |
+ const gfx::Rect& rect) { |
+ // browser::GrabWindowSnapshot takes ~100msec and making visual feedback after |
+ // that leads noticeable delay. To prevent this delay, we just make the |
+ // visual effect first, and then run the actual task of taking screenshot. |
+ DisplayVisualFeedback( |
+ rect, |
+ base::Bind(&TakeScreenshot, base::Unretained(window), rect)); |
+} |
+ |
void ScreenshotTaker::HandleTakeScreenshot(aura::Window* window) { |
HandleTakePartialScreenshot(window, window->bounds()); |
} |
-void ScreenshotTaker::CloseVisualFeedbackLayer() { |
+void ScreenshotTaker::CloseVisualFeedbackLayer(const base::Closure& task) { |
visual_feedback_layer_.reset(); |
+ task.Run(); |
} |
-void ScreenshotTaker::DisplayVisualFeedback(const gfx::Rect& rect) { |
+void ScreenshotTaker::DisplayVisualFeedback(const gfx::Rect& rect, |
+ const base::Closure& task) { |
visual_feedback_layer_.reset(new ui::Layer(ui::Layer::LAYER_SOLID_COLOR)); |
visual_feedback_layer_->SetColor(SK_ColorWHITE); |
visual_feedback_layer_->SetOpacity(kVisualFeedbackLayerOpacity); |
@@ -124,6 +135,7 @@ void ScreenshotTaker::DisplayVisualFeedback(const gfx::Rect& rect) { |
MessageLoopForUI::current()->PostDelayedTask( |
FROM_HERE, |
base::Bind(&ScreenshotTaker::CloseVisualFeedbackLayer, |
- base::Unretained(this)), |
+ base::Unretained(this), |
+ task), |
base::TimeDelta::FromMilliseconds(kVisualFeedbackLayerDisplayTimeMs)); |
} |