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 task.Run(); | 120 // Hide the visual feedback immediately because |task| may take a long time |
| 121 // to finish. |
| 122 MessageLoopForUI::current()->PostTask(FROM_HERE, task); |
121 } | 123 } |
122 | 124 |
123 void ScreenshotTaker::DisplayVisualFeedback(const gfx::Rect& rect, | 125 void ScreenshotTaker::DisplayVisualFeedback(const gfx::Rect& rect, |
124 const base::Closure& task) { | 126 const base::Closure& task) { |
125 visual_feedback_layer_.reset(new ui::Layer(ui::LAYER_SOLID_COLOR)); | 127 visual_feedback_layer_.reset(new ui::Layer(ui::LAYER_SOLID_COLOR)); |
126 visual_feedback_layer_->SetColor(SK_ColorWHITE); | 128 visual_feedback_layer_->SetColor(SK_ColorWHITE); |
127 visual_feedback_layer_->SetOpacity(kVisualFeedbackLayerOpacity); | 129 visual_feedback_layer_->SetOpacity(kVisualFeedbackLayerOpacity); |
128 visual_feedback_layer_->SetBounds(rect); | 130 visual_feedback_layer_->SetBounds(rect); |
129 | 131 |
130 ui::Layer* parent = ash::Shell::GetInstance()->GetContainer( | 132 ui::Layer* parent = ash::Shell::GetInstance()->GetContainer( |
131 ash::internal::kShellWindowId_OverlayContainer)->layer(); | 133 ash::internal::kShellWindowId_OverlayContainer)->layer(); |
132 parent->Add(visual_feedback_layer_.get()); | 134 parent->Add(visual_feedback_layer_.get()); |
133 visual_feedback_layer_->SetVisible(true); | 135 visual_feedback_layer_->SetVisible(true); |
134 | 136 |
135 MessageLoopForUI::current()->PostDelayedTask( | 137 MessageLoopForUI::current()->PostDelayedTask( |
136 FROM_HERE, | 138 FROM_HERE, |
137 base::Bind(&ScreenshotTaker::CloseVisualFeedbackLayer, | 139 base::Bind(&ScreenshotTaker::CloseVisualFeedbackLayer, |
138 base::Unretained(this), | 140 base::Unretained(this), |
139 task), | 141 task), |
140 base::TimeDelta::FromMilliseconds(kVisualFeedbackLayerDisplayTimeMs)); | 142 base::TimeDelta::FromMilliseconds(kVisualFeedbackLayerDisplayTimeMs)); |
141 } | 143 } |
OLD | NEW |