OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/ui/views/ash/screenshot_taker.h" | 5 #include "chrome/browser/ui/views/ash/screenshot_taker.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "ash/shell.h" | 9 #include "ash/shell.h" |
10 #include "ash/shell_window_ids.h" | 10 #include "ash/shell_window_ids.h" |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
110 rect, | 110 rect, |
111 base::Bind(&TakeScreenshot, base::Unretained(window), rect)); | 111 base::Bind(&TakeScreenshot, base::Unretained(window), rect)); |
112 } | 112 } |
113 | 113 |
114 void ScreenshotTaker::HandleTakeScreenshot(aura::Window* window) { | 114 void ScreenshotTaker::HandleTakeScreenshot(aura::Window* window) { |
115 HandleTakePartialScreenshot(window, window->bounds()); | 115 HandleTakePartialScreenshot(window, window->bounds()); |
116 } | 116 } |
117 | 117 |
118 void ScreenshotTaker::CloseVisualFeedbackLayer(const base::Closure& task) { | 118 void ScreenshotTaker::CloseVisualFeedbackLayer(const base::Closure& task) { |
119 visual_feedback_layer_.reset(); | 119 visual_feedback_layer_.reset(); |
120 // Hide the visual feedback immediately because |task| may take a long time | 120 task.Run(); |
121 // to finish. | |
122 MessageLoopForUI::current()->PostTask(FROM_HERE, task); | |
123 } | 121 } |
124 | 122 |
125 void ScreenshotTaker::DisplayVisualFeedback(const gfx::Rect& rect, | 123 void ScreenshotTaker::DisplayVisualFeedback(const gfx::Rect& rect, |
126 const base::Closure& task) { | 124 const base::Closure& task) { |
127 visual_feedback_layer_.reset(new ui::Layer(ui::LAYER_SOLID_COLOR)); | 125 visual_feedback_layer_.reset(new ui::Layer(ui::LAYER_SOLID_COLOR)); |
128 visual_feedback_layer_->SetColor(SK_ColorWHITE); | 126 visual_feedback_layer_->SetColor(SK_ColorWHITE); |
129 visual_feedback_layer_->SetOpacity(kVisualFeedbackLayerOpacity); | 127 visual_feedback_layer_->SetOpacity(kVisualFeedbackLayerOpacity); |
130 visual_feedback_layer_->SetBounds(rect); | 128 visual_feedback_layer_->SetBounds(rect); |
131 | 129 |
132 ui::Layer* parent = ash::Shell::GetInstance()->GetContainer( | 130 ui::Layer* parent = ash::Shell::GetInstance()->GetContainer( |
133 ash::internal::kShellWindowId_OverlayContainer)->layer(); | 131 ash::internal::kShellWindowId_OverlayContainer)->layer(); |
134 parent->Add(visual_feedback_layer_.get()); | 132 parent->Add(visual_feedback_layer_.get()); |
135 visual_feedback_layer_->SetVisible(true); | 133 visual_feedback_layer_->SetVisible(true); |
136 | 134 |
137 MessageLoopForUI::current()->PostDelayedTask( | 135 MessageLoopForUI::current()->PostDelayedTask( |
138 FROM_HERE, | 136 FROM_HERE, |
139 base::Bind(&ScreenshotTaker::CloseVisualFeedbackLayer, | 137 base::Bind(&ScreenshotTaker::CloseVisualFeedbackLayer, |
140 base::Unretained(this), | 138 base::Unretained(this), |
141 task), | 139 task), |
142 base::TimeDelta::FromMilliseconds(kVisualFeedbackLayerDisplayTimeMs)); | 140 base::TimeDelta::FromMilliseconds(kVisualFeedbackLayerDisplayTimeMs)); |
143 } | 141 } |
OLD | NEW |