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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
45 | 45 |
46 std::string GetScreenshotFileName(bool use_24hour_clock) { | 46 std::string GetScreenshotFileName(bool use_24hour_clock) { |
47 base::Time::Exploded now; | 47 base::Time::Exploded now; |
48 base::Time::Now().LocalExplode(&now); | 48 base::Time::Now().LocalExplode(&now); |
49 | 49 |
50 // We don't use base/i18n/time_formatting.h here because it doesn't | 50 // We don't use base/i18n/time_formatting.h here because it doesn't |
51 // support our format. Don't use ICU either to avoid i18n file names | 51 // support our format. Don't use ICU either to avoid i18n file names |
52 // for non-English locales. | 52 // for non-English locales. |
53 // TODO(mukai): integrate this logic somewhere time_formatting.h | 53 // TODO(mukai): integrate this logic somewhere time_formatting.h |
54 std::string file_name = base::StringPrintf( | 54 std::string file_name = base::StringPrintf( |
55 "Screenshot_%d-%02d-%02d_", now.year, now.month, now.day_of_month); | 55 "Screenshot %d-%02d-%02d ", now.year, now.month, now.day_of_month); |
56 | 56 |
57 if (use_24hour_clock) { | 57 if (use_24hour_clock) { |
58 file_name.append(base::StringPrintf( | 58 file_name.append(base::StringPrintf( |
59 "%02d:%02d:%02d.png", now.hour, now.minute, now.second)); | 59 "%d:%02d:%02d.png", now.hour, now.minute, now.second)); |
Daniel Erat
2012/05/18 19:32:51
24-hour times retain a leading zero: http://en.wik
Jun Mukai
2012/05/18 20:21:30
Gosh, thanks for pointing... Fixed.
| |
60 } else { | 60 } else { |
61 int hour = now.hour; | 61 int hour = now.hour; |
62 if (hour > 12) { | 62 if (hour > 12) { |
63 hour -= 12; | 63 hour -= 12; |
64 } else if (hour == 0) { | 64 } else if (hour == 0) { |
65 hour = 12; | 65 hour = 12; |
66 } | 66 } |
67 file_name.append(base::StringPrintf( | 67 file_name.append(base::StringPrintf( |
68 "%02d:%02d:%02d_", hour, now.minute, now.second)); | 68 "%d:%02d:%02d ", hour, now.minute, now.second)); |
69 file_name.append((now.hour >= 12) ? "PM" : "AM"); | 69 file_name.append((now.hour >= 12) ? "PM" : "AM"); |
70 file_name.append(".png"); | 70 file_name.append(".png"); |
71 } | 71 } |
72 | 72 |
73 return file_name; | 73 return file_name; |
74 } | 74 } |
75 | 75 |
76 // |is_logged_in| is used only for ChromeOS. Otherwise it is always true. | 76 // |is_logged_in| is used only for ChromeOS. Otherwise it is always true. |
77 void SaveScreenshot(bool is_logged_in, | 77 void SaveScreenshot(bool is_logged_in, |
78 bool use_24hour_clock, | 78 bool use_24hour_clock, |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
162 ash::internal::kShellWindowId_OverlayContainer)->layer(); | 162 ash::internal::kShellWindowId_OverlayContainer)->layer(); |
163 parent->Add(visual_feedback_layer_.get()); | 163 parent->Add(visual_feedback_layer_.get()); |
164 visual_feedback_layer_->SetVisible(true); | 164 visual_feedback_layer_->SetVisible(true); |
165 | 165 |
166 MessageLoopForUI::current()->PostDelayedTask( | 166 MessageLoopForUI::current()->PostDelayedTask( |
167 FROM_HERE, | 167 FROM_HERE, |
168 base::Bind(&ScreenshotTaker::CloseVisualFeedbackLayer, | 168 base::Bind(&ScreenshotTaker::CloseVisualFeedbackLayer, |
169 base::Unretained(this)), | 169 base::Unretained(this)), |
170 base::TimeDelta::FromMilliseconds(kVisualFeedbackLayerDisplayTimeMs)); | 170 base::TimeDelta::FromMilliseconds(kVisualFeedbackLayerDisplayTimeMs)); |
171 } | 171 } |
OLD | NEW |