Chromium Code Reviews| 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..2cd1f07ece03d326ec7009d5d932df72a77d7cea 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" |
| @@ -64,6 +66,13 @@ 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 kVisualFeedbackLayerOpacity = 64; |
| + |
| +// How long should the visual feedback layer be displayed? |
| +const uint64_t kVisualFeedbackLayerDisplayTimeMs = 100; |
|
Daniel Erat
2012/02/24 17:23:39
nit: s/uint64_t/int64/ to match the type from Post
Jun Mukai
2012/02/27 02:29:02
Done.
|
| + |
| } // namespace |
| ScreenshotTaker::ScreenshotTaker() { |
| @@ -81,6 +90,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)); |
| @@ -92,3 +102,25 @@ void ScreenshotTaker::HandleTakePartialScreenshot( |
| void ScreenshotTaker::HandleTakeScreenshot(aura::Window* window) { |
| HandleTakePartialScreenshot(window, window->bounds()); |
| } |
| + |
| +void ScreenshotTaker::CloseVisualFeedbackLayer() { |
| + visual_feedback_layer_.reset(); |
| +} |
| + |
| +void ScreenshotTaker::DisplayVisualFeedback(const gfx::Rect& rect) { |
| + visual_feedback_layer_.reset(new ui::Layer(ui::Layer::LAYER_SOLID_COLOR)); |
| + visual_feedback_layer_->SetColor( |
| + SkColorSetA(SK_ColorWHITE, kVisualFeedbackLayerOpacity)); |
| + visual_feedback_layer_->SetBounds(rect); |
| + |
| + ui::Layer* parent = ash::Shell::GetInstance()->GetContainer( |
| + ash::internal::kShellWindowId_OverlayContainer)->layer(); |
| + parent->Add(visual_feedback_layer_.get()); |
| + visual_feedback_layer_->SetVisible(true); |
| + |
| + MessageLoopForUI::current()->PostDelayedTask( |
| + FROM_HERE, |
| + base::Bind(&ScreenshotTaker::CloseVisualFeedbackLayer, |
| + base::Unretained(this)), |
| + kVisualFeedbackLayerDisplayTimeMs); |
|
Daniel Erat
2012/02/24 17:23:39
nit: mind changing this to instead be base::TimeDe
Jun Mukai
2012/02/27 02:29:02
Done.
|
| +} |