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..37f1a3361fc5460b31d42ce7c9d02f5875c20b71 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,11 +66,21 @@ 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 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)); |
| @@ -81,6 +93,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 +105,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)); |
|
Daniel Erat
2012/03/01 17:15:40
When I was adding Layer::LAYER_SOLID_COLOR, I thou
Jun Mukai
2012/03/02 03:41:18
Added SetOpacity. Just curious, is this a bug? W
|
| + 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)), |
| + base::TimeDelta::FromMilliseconds(kVisualFeedbackLayerDisplayTimeMs)); |
| +} |