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

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

Issue 9430041: Makes the visual feedback for taking screenshot. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Fix based on comments Created 8 years, 10 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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));
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698