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

Unified Diff: chrome/browser/ui/views/ash/screenshot_taker.cc

Issue 9874030: Revert http://codereview.chromium.org/9838043/ (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 9 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
« no previous file with comments | « chrome/browser/ui/views/ash/screenshot_taker.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 1f874f1be47b8e454461b54dbe81d69f0ef75a33..ce4f2b1017109a8cc3b3d7a25df613fdc4d03274 100644
--- a/chrome/browser/ui/views/ash/screenshot_taker.cc
+++ b/chrome/browser/ui/views/ash/screenshot_taker.cc
@@ -66,8 +66,23 @@ void SaveScreenshot(bool is_logged_in,
}
}
-// Actually takes the screenshot.
-void TakeScreenshot(aura::Window* window, const gfx::Rect& rect) {
+// 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) {
DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
scoped_refptr<RefCountedBytes> png_data(new RefCountedBytes);
@@ -78,6 +93,7 @@ void TakeScreenshot(aura::Window* window, const gfx::Rect& rect) {
#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));
@@ -86,42 +102,15 @@ void TakeScreenshot(aura::Window* window, const gfx::Rect& rect) {
}
}
-// 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(const base::Closure& task) {
+void ScreenshotTaker::CloseVisualFeedbackLayer() {
visual_feedback_layer_.reset();
- task.Run();
}
-void ScreenshotTaker::DisplayVisualFeedback(const gfx::Rect& rect,
- const base::Closure& task) {
+void ScreenshotTaker::DisplayVisualFeedback(const gfx::Rect& rect) {
visual_feedback_layer_.reset(new ui::Layer(ui::LAYER_SOLID_COLOR));
visual_feedback_layer_->SetColor(SK_ColorWHITE);
visual_feedback_layer_->SetOpacity(kVisualFeedbackLayerOpacity);
@@ -135,7 +124,6 @@ void ScreenshotTaker::DisplayVisualFeedback(const gfx::Rect& rect,
MessageLoopForUI::current()->PostDelayedTask(
FROM_HERE,
base::Bind(&ScreenshotTaker::CloseVisualFeedbackLayer,
- base::Unretained(this),
- task),
+ base::Unretained(this)),
base::TimeDelta::FromMilliseconds(kVisualFeedbackLayerDisplayTimeMs));
}
« no previous file with comments | « chrome/browser/ui/views/ash/screenshot_taker.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698