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

Side by Side Diff: chrome/browser/ui/ash/screenshot_taker.cc

Issue 10802046: Ignores screenshot taking invocations if it's too close to the previous one. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 5 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/ui/ash/screenshot_taker.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/ash/screenshot_taker.h" 5 #include "chrome/browser/ui/ash/screenshot_taker.h"
6 6
7 #include <climits> 7 #include <climits>
8 #include <string> 8 #include <string>
9 9
10 #include "ash/shell.h" 10 #include "ash/shell.h"
(...skipping 15 matching lines...) Expand all
26 #include "chrome/common/pref_names.h" 26 #include "chrome/common/pref_names.h"
27 #include "content/public/browser/browser_thread.h" 27 #include "content/public/browser/browser_thread.h"
28 #include "ui/aura/root_window.h" 28 #include "ui/aura/root_window.h"
29 #include "ui/aura/window.h" 29 #include "ui/aura/window.h"
30 30
31 #if defined(OS_CHROMEOS) 31 #if defined(OS_CHROMEOS)
32 #include "chrome/browser/chromeos/login/user_manager.h" 32 #include "chrome/browser/chromeos/login/user_manager.h"
33 #endif 33 #endif
34 34
35 namespace { 35 namespace {
36 const int kScreenshotMinimumIntervalInMS = 500;
37
36 bool ShouldUse24HourClock() { 38 bool ShouldUse24HourClock() {
37 #if defined(OS_CHROMEOS) 39 #if defined(OS_CHROMEOS)
38 Profile* profile = ProfileManager::GetDefaultProfileOrOffTheRecord(); 40 Profile* profile = ProfileManager::GetDefaultProfileOrOffTheRecord();
39 if (profile) { 41 if (profile) {
40 PrefService* pref_service = profile->GetPrefs(); 42 PrefService* pref_service = profile->GetPrefs();
41 if (pref_service) { 43 if (pref_service) {
42 return pref_service->GetBoolean(prefs::kUse24HourClock); 44 return pref_service->GetBoolean(prefs::kUse24HourClock);
43 } 45 }
44 } 46 }
45 #endif 47 #endif
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 ScreenshotTaker::ScreenshotTaker() { 137 ScreenshotTaker::ScreenshotTaker() {
136 } 138 }
137 139
138 ScreenshotTaker::~ScreenshotTaker() { 140 ScreenshotTaker::~ScreenshotTaker() {
139 } 141 }
140 142
141 void ScreenshotTaker::HandleTakePartialScreenshot( 143 void ScreenshotTaker::HandleTakePartialScreenshot(
142 aura::Window* window, const gfx::Rect& rect) { 144 aura::Window* window, const gfx::Rect& rect) {
143 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); 145 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
144 146
147 aura::RootWindow* root_window = window->GetRootWindow();
sky 2012/07/20 16:13:31 Do we really care about what root window this came
Jun Mukai 2012/07/20 17:07:32 This method is invoked several times for a single
148 base::Time now = base::Time::Now();
149 std::map<aura::RootWindow*, base::Time>::const_iterator iter =
150 last_screenshot_timestamps_.find(root_window);
151 if (iter != last_screenshot_timestamps_.end()) {
152 base::Time last = iter->second;
153 // Ignore if the command is issued too closely to the last command.
154 if (now - last <= base::TimeDelta::FromMilliseconds(
155 kScreenshotMinimumIntervalInMS))
156 return;
157 }
158 last_screenshot_timestamps_[root_window] = now;
159
145 scoped_refptr<base::RefCountedBytes> png_data(new base::RefCountedBytes); 160 scoped_refptr<base::RefCountedBytes> png_data(new base::RefCountedBytes);
146 161
147 bool is_logged_in = true; 162 bool is_logged_in = true;
148 #if defined(OS_CHROMEOS) 163 #if defined(OS_CHROMEOS)
149 is_logged_in = chromeos::UserManager::Get()->IsUserLoggedIn(); 164 is_logged_in = chromeos::UserManager::Get()->IsUserLoggedIn();
150 #endif 165 #endif
151 166
152 FilePath screenshot_directory; 167 FilePath screenshot_directory;
153 if (is_logged_in) { 168 if (is_logged_in) {
154 DownloadPrefs* download_prefs = DownloadPrefs::FromBrowserContext( 169 DownloadPrefs* download_prefs = DownloadPrefs::FromBrowserContext(
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
193 ash::internal::kShellWindowId_OverlayContainer)->layer(); 208 ash::internal::kShellWindowId_OverlayContainer)->layer();
194 parent->Add(visual_feedback_layer_.get()); 209 parent->Add(visual_feedback_layer_.get());
195 visual_feedback_layer_->SetVisible(true); 210 visual_feedback_layer_->SetVisible(true);
196 211
197 MessageLoopForUI::current()->PostDelayedTask( 212 MessageLoopForUI::current()->PostDelayedTask(
198 FROM_HERE, 213 FROM_HERE,
199 base::Bind(&ScreenshotTaker::CloseVisualFeedbackLayer, 214 base::Bind(&ScreenshotTaker::CloseVisualFeedbackLayer,
200 base::Unretained(this)), 215 base::Unretained(this)),
201 base::TimeDelta::FromMilliseconds(kVisualFeedbackLayerDisplayTimeMs)); 216 base::TimeDelta::FromMilliseconds(kVisualFeedbackLayerDisplayTimeMs));
202 } 217 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/ash/screenshot_taker.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698