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

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: 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..ba44b9b3a9553a04a2cd5f919c97564f0952bfd4 100644
--- a/chrome/browser/ui/views/aura/screenshot_taker.cc
+++ b/chrome/browser/ui/views/aura/screenshot_taker.cc
@@ -13,10 +13,15 @@
#include "base/memory/ref_counted_memory.h"
#include "base/stringprintf.h"
#include "base/time.h"
+#include "ash/shell.h"
Daniel Erat 2012/02/22 17:22:06 alphabetize these
Jun Mukai 2012/02/23 03:28:58 Done.
+#include "ash/shell_window_ids.h"
#include "chrome/browser/download/download_util.h"
#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"
#if defined(OS_CHROMEOS)
#include "chrome/browser/chromeos/login/user_manager.h"
@@ -64,6 +69,68 @@ void SaveScreenshot(bool is_logged_in,
}
}
+// How opaque should the window that we flash onscreen to provide visual
+// 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;
+
+// The view of making visual feedback for screenshot, i.e.: flashing the screen.
Daniel Erat 2012/02/22 17:22:06 // Flashes the screen to provide visual feedback t
Jun Mukai 2012/02/23 03:28:58 Done.
+class VisualFeedbackView : public views::WidgetDelegateView {
Daniel Erat 2012/02/22 17:22:06 not sure how much to care about this, but it'd be
Jun Mukai 2012/02/23 03:28:58 Done.
+ public:
+ VisualFeedbackView();
+
+ private:
+ // Overridden from View:
+ virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE;
+
+ DISALLOW_COPY_AND_ASSIGN(VisualFeedbackView);
+};
+
+VisualFeedbackView::VisualFeedbackView() {
Daniel Erat 2012/02/22 17:22:06 define this inline in the class declaration?
Jun Mukai 2012/02/23 03:28:58 removed the class itself and use ui::Layer instead
+}
+
+void VisualFeedbackView::OnPaint(gfx::Canvas* canvas) {
+ // All white.
Daniel Erat 2012/02/22 17:22:06 delete unnecessary comment
Jun Mukai 2012/02/23 03:28:58 removed the class itself.
+ canvas->FillRect(bounds(), SK_ColorWHITE);
+}
+
+void CleanupFeedbackView(aura::Window* window) {
+ DCHECK(window);
+ window->Hide();
+ MessageLoopForUI::current()->DeleteSoon(FROM_HERE, window);
+}
+
+// Makes the actual visual feedback, i.e.: flashing the screen. It's
+// achieved by creating a transparent white window and removing it
+// 100msec later.
+void MakeVisualFeedback(const gfx::Rect& rect) {
Daniel Erat 2012/02/22 17:22:06 nit: s/MakeVisualFeedback/DisplayVisualFeedback/
Jun Mukai 2012/02/23 03:28:58 Done.
+ views::Widget* widget = new views::Widget;
+ VisualFeedbackView* view = new VisualFeedbackView();
+
+ views::Widget::InitParams params(
+ views::Widget::InitParams::TYPE_WINDOW_FRAMELESS);
+ params.transparent = true;
+ params.delegate = view;
+ params.parent = ash::Shell::GetInstance()->GetContainer(
+ ash::internal::kShellWindowId_OverlayContainer);
+
+ widget->Init(params);
+ widget->SetContentsView(view);
+ widget->SetBounds(rect);
+ widget->GetNativeView()->SetName("ScreenshotVisualFeedback");
+ widget->SetOpacity(kVisualFeedbackWindowOpacity);
+ widget->StackAtTop();
+ widget->Show();
+
+ MessageLoopForUI::current()->PostDelayedTask(
+ FROM_HERE,
+ base::Bind(&CleanupFeedbackView,
+ base::Unretained(widget->GetNativeView())),
+ kVisualFeedbackWindowDisplayTimeMs);
+}
+
} // namespace
ScreenshotTaker::ScreenshotTaker() {
@@ -81,6 +148,7 @@ void ScreenshotTaker::HandleTakePartialScreenshot(
#endif
if (browser::GrabWindowSnapshot(window, &png_data->data(), rect)) {
+ MakeVisualFeedback(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