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

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: use ui::Layer instead of custom view 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..60be970c991da5dc8511ae447b5cae99379c8195 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,9 @@
#include "chrome/browser/ui/window_snapshot/window_snapshot.h"
#include "content/public/browser/browser_thread.h"
#include "ui/aura/window.h"
+#include "ui/gfx/canvas.h"
+#include "ui/views/widget/widget.h"
+#include "ui/views/widget/widget_delegate.h"
Daniel Erat 2012/02/23 14:32:13 you don't need these includes anymore; you should
Jun Mukai 2012/02/24 00:38:28 Done.
#if defined(OS_CHROMEOS)
#include "chrome/browser/chromeos/login/user_manager.h"
@@ -64,6 +69,38 @@ void SaveScreenshot(bool is_logged_in,
}
}
+// How opaque should the window that we flash onscreen to provide visual
Daniel Erat 2012/02/23 14:32:13 nit: s/window/layer here and in the const variable
Jun Mukai 2012/02/24 00:38:28 Done.
+// feedback after the screenshot is taken be?
+const unsigned char kVisualFeedbackWindowOpacity = 64;
+
+// How long should the visual feedback window be displayed?
+const uint64_t kVisualFeedbackWindowDisplayTimeMs = 100;
+
+void CleanupFeedbackView(ui::Layer* layer) {
Daniel Erat 2012/02/23 14:32:13 s/CleanupFeedbackView/CloseFeedbackLayer/ ?
Jun Mukai 2012/02/24 00:38:28 Done.
+ DCHECK(layer);
+ layer->SetVisible(false);
+ MessageLoopForUI::current()->DeleteSoon(FROM_HERE, layer);
Daniel Erat 2012/02/23 14:32:13 you can delete it immediately instead of setting i
Jun Mukai 2012/02/24 00:38:28 Done.
+}
+
+// Flashes the screen to provide visual feedback that a screenshot has
+// been taken.
+void DisplayVisualFeedback(const gfx::Rect& rect) {
+ ui::Layer* layer = new ui::Layer(ui::Layer::LAYER_SOLID_COLOR);
Daniel Erat 2012/02/23 14:32:13 put this in a scoped_ptr in ScreenshotTaker so it
Jun Mukai 2012/02/24 00:38:28 Done.
+ layer->SetColor(SkColorSetA(SK_ColorWHITE, kVisualFeedbackWindowOpacity));
+ layer->SetBounds(rect);
+
+ ui::Layer* parent = ash::Shell::GetInstance()->GetContainer(
+ ash::internal::kShellWindowId_OverlayContainer)->layer();
+ parent->Add(layer);
+ parent->StackAtTop(layer);
Daniel Erat 2012/02/23 14:32:13 i guess it doesn't hurt to be explicit, but i'm pr
Jun Mukai 2012/02/24 00:38:28 Done.
+ layer->SetVisible(true);
+
+ MessageLoopForUI::current()->PostDelayedTask(
+ FROM_HERE,
+ base::Bind(&CleanupFeedbackView, base::Unretained(layer)),
+ kVisualFeedbackWindowDisplayTimeMs);
+}
+
} // namespace
ScreenshotTaker::ScreenshotTaker() {
@@ -81,6 +118,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