Index: chrome/browser/ui/views/aura/screenshot_taker.cc |
diff --git a/chrome/browser/ui/views/aura/screenshot_taker.cc b/chrome/browser/ui/views/aura/screenshot_taker.cc |
index c004e9c736fb66c4022d03da8cd7c0549332872e..6ee4169c3df9bae87bb17374f38706fa8727ab02 100644 |
--- a/chrome/browser/ui/views/aura/screenshot_taker.cc |
+++ b/chrome/browser/ui/views/aura/screenshot_taker.cc |
@@ -6,6 +6,8 @@ |
#include <string> |
+#include "ash/shell.h" |
+#include "ash/shell_window_ids.h" |
#include "base/bind.h" |
#include "base/file_path.h" |
#include "base/file_util.h" |
@@ -17,6 +19,7 @@ |
#include "chrome/browser/ui/window_snapshot/window_snapshot.h" |
#include "content/public/browser/browser_thread.h" |
#include "ui/aura/window.h" |
+#include "ui/gfx/compositor/layer.h" |
#if defined(OS_CHROMEOS) |
#include "chrome/browser/chromeos/login/user_manager.h" |
@@ -64,6 +67,37 @@ 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 unsigned char kVisualFeedbackWindowOpacity = 64; |
Daniel Erat
2012/02/24 00:48:46
nit: s/Window/Layer/ in variable name
Jun Mukai
2012/02/24 02:24:55
Done.
|
+ |
+// How long should the visual feedback window be displayed? |
+const uint64_t kVisualFeedbackWindowDisplayTimeMs = 100; |
Daniel Erat
2012/02/24 00:48:46
s/Window/Layer/
Jun Mukai
2012/02/24 02:24:55
Done.
|
+ |
+void CloseFeedbackLayer(ui::Layer* layer) { |
+ DCHECK(layer); |
+ layer->SetVisible(false); |
Daniel Erat
2012/02/24 00:48:46
nit: unneeded; deleting it makes it invisible :-)
Jun Mukai
2012/02/24 02:24:55
Done.
|
+ delete layer; |
+} |
+ |
+// Flashes the screen to provide visual feedback that a screenshot has |
+// been taken. |
+void DisplayVisualFeedback(const gfx::Rect& rect) { |
+ scoped_ptr<ui::Layer> layer(new ui::Layer(ui::Layer::LAYER_SOLID_COLOR)); |
+ layer->SetColor(SkColorSetA(SK_ColorWHITE, kVisualFeedbackWindowOpacity)); |
+ layer->SetBounds(rect); |
+ |
+ ui::Layer* parent = ash::Shell::GetInstance()->GetContainer( |
+ ash::internal::kShellWindowId_OverlayContainer)->layer(); |
+ parent->Add(layer.get()); |
+ layer->SetVisible(true); |
+ |
+ MessageLoopForUI::current()->PostDelayedTask( |
+ FROM_HERE, |
+ base::Bind(&CloseFeedbackLayer, base::Unretained(layer.release())), |
Daniel Erat
2012/02/24 00:48:46
i meant that you could make these functions instea
Jun Mukai
2012/02/24 02:24:55
Ah, thank you for the explanation. Done.
|
+ kVisualFeedbackWindowDisplayTimeMs); |
+} |
+ |
} // namespace |
ScreenshotTaker::ScreenshotTaker() { |
@@ -81,6 +115,7 @@ 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)); |