Chromium Code Reviews| 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/test/base/ui_test_utils.h" | 5 #include "chrome/test/base/ui_test_utils.h" |
| 6 | 6 |
| 7 #include "base/file_path.h" | 7 #include "base/file_path.h" |
| 8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 117 bool succeeded = false; | 117 bool succeeded = false; |
| 118 FilePath out_path(GetSnapshotFileName(directory)); | 118 FilePath out_path(GetSnapshotFileName(directory)); |
| 119 | 119 |
| 120 MONITORINFO monitor_info = {}; | 120 MONITORINFO monitor_info = {}; |
| 121 monitor_info.cbSize = sizeof(monitor_info); | 121 monitor_info.cbSize = sizeof(monitor_info); |
| 122 HMONITOR main_monitor = MonitorFromWindow(NULL, MONITOR_DEFAULTTOPRIMARY); | 122 HMONITOR main_monitor = MonitorFromWindow(NULL, MONITOR_DEFAULTTOPRIMARY); |
| 123 if (GetMonitorInfo(main_monitor, &monitor_info)) { | 123 if (GetMonitorInfo(main_monitor, &monitor_info)) { |
| 124 RECT& rect = monitor_info.rcMonitor; | 124 RECT& rect = monitor_info.rcMonitor; |
| 125 | 125 |
| 126 std::vector<unsigned char> png_data; | 126 std::vector<unsigned char> png_data; |
| 127 if (browser::GrabWindowSnapshot(NULL, &png_data, | 127 if (browser::GrabWindowSnapshotIfPermitted(NULL, &png_data, |
| 128 gfx::Rect(rect.right - rect.left, | 128 gfx::Rect(rect.right - rect.left, |
| 129 rect.bottom - rect.top)) && | 129 rect.bottom - rect.top)) && |
|
Mattias Nissler (ping if slow)
2012/07/13 15:23:42
align parameters
qfel
2012/07/16 09:11:12
Ah! It's line no. 34's fault.
Done.
| |
| 130 png_data.size() <= INT_MAX) { | 130 png_data.size() <= INT_MAX) { |
| 131 int bytes = static_cast<int>(png_data.size()); | 131 int bytes = static_cast<int>(png_data.size()); |
| 132 int written = file_util::WriteFile( | 132 int written = file_util::WriteFile( |
| 133 out_path, reinterpret_cast<char*>(&png_data[0]), bytes); | 133 out_path, reinterpret_cast<char*>(&png_data[0]), bytes); |
| 134 succeeded = (written == bytes); | 134 succeeded = (written == bytes); |
| 135 } | 135 } |
| 136 } | 136 } |
| 137 | 137 |
| 138 if (succeeded && screenshot_path != NULL) | 138 if (succeeded && screenshot_path != NULL) |
| 139 *screenshot_path = out_path; | 139 *screenshot_path = out_path; |
| 140 | 140 |
| 141 return succeeded; | 141 return succeeded; |
| 142 } | 142 } |
| 143 | 143 |
| 144 bool SaveScreenSnapshotToDesktop(FilePath* screenshot_path) { | 144 bool SaveScreenSnapshotToDesktop(FilePath* screenshot_path) { |
| 145 FilePath desktop; | 145 FilePath desktop; |
| 146 | 146 |
| 147 return PathService::Get(chrome::DIR_USER_DESKTOP, &desktop) && | 147 return PathService::Get(chrome::DIR_USER_DESKTOP, &desktop) && |
| 148 SaveScreenSnapshotToDirectory(desktop, screenshot_path); | 148 SaveScreenSnapshotToDirectory(desktop, screenshot_path); |
| 149 } | 149 } |
| 150 | 150 |
| 151 } // namespace ui_test_utils | 151 } // namespace ui_test_utils |
| OLD | NEW |